MCPcopy
hub / github.com/microsoft/SandDance / markStager

Function markStager

packages/vega-deck.gl/src/marks/area.ts:27–84  ·  view source on GitHub ↗
(options: MarkStagerOptions, stage: Stage, scene: Scene, x: number, y: number, groupType: GroupType)

Source from the content-addressed store, hash-verified

25const ty = -1;
26
27const markStager: MarkStager = (options: MarkStagerOptions, stage: Stage, scene: Scene, x: number, y: number, groupType: GroupType) => {
28 const g: GroupItem = {
29 fillOpacity: 1,
30 opacity: 1,
31 strokeOpacity: 1,
32 strokeWidth: 0,
33 depth: 0,
34 ...(<GroupItem>scene.items[0]),
35 };
36
37 const points = scene.items.map((item: GroupItem) => {
38 item = {
39 z: 0,
40 ...item,
41 };
42 item = {
43 x2: item.x,
44 y2: item.y,
45 z2: item.z,
46 ...item,
47 };
48 return [
49 item.x,
50 ty * item.y,
51 item.z,
52 item.x2,
53 ty * item.y2,
54 item.z2,
55 ];
56 });
57
58 const positions: Position3D[] = [];
59
60 const startpoint: Position3D = [points[0][0], points[0][1], points[0][2]];
61 points.forEach(p => {
62 positions.push([p[0], p[1], p[2]]);
63 });
64 points.reverse().forEach(p => {
65 positions.push([p[3], p[4], p[5]]);
66 });
67 positions.push(startpoint);
68
69 const polygon: Polygon = {
70 fillColor: colorFromString(g.fill) || [0, 0, 0, 0],
71 positions,
72 strokeColor: colorFromString(g.stroke) || [0, 0, 0, 0],
73 strokeWidth: g.strokeWidth,
74 depth: g.depth,
75 };
76
77 polygon.fillColor[3] *= g.fillOpacity;
78 polygon.fillColor[3] *= g.opacity;
79
80 polygon.strokeColor[3] *= g.strokeOpacity;
81 polygon.strokeColor[3] *= g.opacity;
82
83 stage.polygonData.push(polygon);
84};

Callers

nothing calls this directly

Calls 2

colorFromStringFunction · 0.90
forEachMethod · 0.45

Tested by

no test coverage detected