MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / getLineWidth

Function getLineWidth

apps/start/src/hooks/use-dashed-stroke.tsx:117–137  ·  view source on GitHub ↗
(points: GraphicalItemPoint[])

Source from the content-addressed store, hash-verified

115 const items = props?.formattedGraphicalItems;
116
117 const getLineWidth = (points: GraphicalItemPoint[]) => {
118 const width = points?.reduce((acc, point, index) => {
119 if (!index) return acc;
120
121 const prevPoint = points?.[index - 1];
122
123 const xAxis = point?.x || 0;
124 const prevXAxis = prevPoint?.x || 0;
125 const xWidth = xAxis - prevXAxis;
126
127 const yAxis = point?.y || 0;
128 const prevYAxis = prevPoint?.y || 0;
129 const yWidth = Math.abs(yAxis - prevYAxis);
130
131 const hypotenuse = Math.sqrt(xWidth * xWidth + yWidth * yWidth);
132 acc += hypotenuse;
133 return acc;
134 }, 0);
135
136 return width || 0;
137 };
138
139 items?.forEach((line) => {
140 const linePoints = line?.props?.points;

Callers 1

useStrokeDasharrayFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected