Skip to content

Commit 532447e

Browse files
committed
lint fixes
1 parent 32b8494 commit 532447e

2 files changed

Lines changed: 172 additions & 33 deletions

File tree

src/features/shapes/flow_tile/FlowTile.js

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ export default class FlowTile extends Shape {
119119
tileHeight,
120120
tileStyle,
121121
tileNoise,
122-
tileNoiseScale,
123122
tileStrokeWidth,
124123
seed,
125124
} = state.shape
@@ -252,7 +251,12 @@ export default class FlowTile extends Shape {
252251

253252
drawTile(cx, cy, tileStyle, strokeWidth, showBorder, orientation) {
254253
const bounds = tileBounds(cx, cy)
255-
return tileRenderers[tileStyle](bounds, orientation, strokeWidth, showBorder)
254+
return tileRenderers[tileStyle](
255+
bounds,
256+
orientation,
257+
strokeWidth,
258+
showBorder,
259+
)
256260
}
257261

258262
// Convert multiple disconnected paths into a single continuous drawing path.
@@ -299,10 +303,23 @@ export default class FlowTile extends Shape {
299303
graph.addNode(startNode)
300304
graph.addNode(midNode)
301305
graph.addNode(endNode)
302-
graph.addEdge(startNode, midNode, this.edgeWeight(path[0], path[midIdx]))
303-
graph.addEdge(midNode, endNode, this.edgeWeight(path[midIdx], path[path.length - 1]))
306+
graph.addEdge(
307+
startNode,
308+
midNode,
309+
this.edgeWeight(path[0], path[midIdx]),
310+
)
311+
graph.addEdge(
312+
midNode,
313+
endNode,
314+
this.edgeWeight(path[midIdx], path[path.length - 1]),
315+
)
304316

305-
this.storeSegment(pathSegments, startNode, midNode, path.slice(0, midIdx + 1))
317+
this.storeSegment(
318+
pathSegments,
319+
startNode,
320+
midNode,
321+
path.slice(0, midIdx + 1),
322+
)
306323
this.storeSegment(pathSegments, midNode, endNode, path.slice(midIdx))
307324
} else if (isLongPath) {
308325
// Long path with stroke: endpoints only (avoids inner/outer ribbon crossings)
@@ -311,7 +328,11 @@ export default class FlowTile extends Shape {
311328

312329
graph.addNode(startNode)
313330
graph.addNode(endNode)
314-
graph.addEdge(startNode, endNode, this.edgeWeight(path[0], path[path.length - 1]))
331+
graph.addEdge(
332+
startNode,
333+
endNode,
334+
this.edgeWeight(path[0], path[path.length - 1]),
335+
)
315336

316337
this.storeSegment(pathSegments, startNode, endNode, path)
317338
} else {
@@ -394,7 +415,9 @@ export default class FlowTile extends Shape {
394415
const lowerOdd = lower % 2 === 0 ? lower - 1 : lower
395416
const upperOdd = lowerOdd + 2
396417

397-
return Math.abs(v - lowerOdd) <= Math.abs(v - upperOdd) ? lowerOdd : upperOdd
418+
return Math.abs(v - lowerOdd) <= Math.abs(v - upperOdd)
419+
? lowerOdd
420+
: upperOdd
398421
}
399422

400423
for (const nodeKey of routingGraph.nodeKeys) {
@@ -485,7 +508,14 @@ export default class FlowTile extends Shape {
485508
if (segment) {
486509
this.appendSegment(segment, fromKey, toKey, result)
487510
} else {
488-
this.routeViaGraph(fromKey, toKey, pathSegments, routingGraph, graph, result)
511+
this.routeViaGraph(
512+
fromKey,
513+
toKey,
514+
pathSegments,
515+
routingGraph,
516+
graph,
517+
result,
518+
)
489519
}
490520
}
491521

@@ -495,8 +525,12 @@ export default class FlowTile extends Shape {
495525
// Add segment vertices, handling direction and skipping shared endpoints
496526
appendSegment(segment, fromKey, toKey, result) {
497527
const goingForward = fromKey <= toKey
498-
const shouldReverse = goingForward ? segment.needsReverse : !segment.needsReverse
499-
const vertices = shouldReverse ? [...segment.vertices].reverse() : segment.vertices
528+
const shouldReverse = goingForward
529+
? segment.needsReverse
530+
: !segment.needsReverse
531+
const vertices = shouldReverse
532+
? [...segment.vertices].reverse()
533+
: segment.vertices
500534
const startIdx = result.length === 0 ? 0 : 1
501535

502536
for (let j = startIdx; j < vertices.length; j++) {
@@ -509,7 +543,12 @@ export default class FlowTile extends Shape {
509543
const fromNode = routingGraph.nodeMap[fromKey]
510544
const toNode = routingGraph.nodeMap[toKey]
511545

512-
if (fromNode && toNode && routingGraph.nodeKeys.has(fromKey) && routingGraph.nodeKeys.has(toKey)) {
546+
if (
547+
fromNode &&
548+
toNode &&
549+
routingGraph.nodeKeys.has(fromKey) &&
550+
routingGraph.nodeKeys.has(toKey)
551+
) {
513552
const pathNodes = routingGraph.dijkstraShortestPath(fromKey, toKey)
514553

515554
if (pathNodes && pathNodes.length > 1) {

src/features/shapes/flow_tile/tileRenderers.js

Lines changed: 122 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@ import { arc } from "@/common/geometry"
33
import { getEdgeMidpoints } from "./geometry"
44

55
// Create arc path with exact start/end points and push to paths array
6-
function pushArcPath(paths, radius, startAngle, endAngle, cx, cy, startPt, endPt) {
6+
function pushArcPath(
7+
paths,
8+
radius,
9+
startAngle,
10+
endAngle,
11+
cx,
12+
cy,
13+
startPt,
14+
endPt,
15+
) {
716
const arcPath = arc(radius, startAngle, endAngle, cx, cy)
817

918
arcPath[0] = startPt.clone()
@@ -27,35 +36,99 @@ function drawStrokedArcTile(bounds, orientation, strokeWidth, tileBorder) {
2736
const { left, right, top, bottom } = bounds
2837
const cx = bounds.cx ?? (left + right) / 2
2938
const cy = bounds.cy ?? (top + bottom) / 2
30-
const baseRadius = (bounds.size ?? (right - left)) / 2
39+
const baseRadius = (bounds.size ?? right - left) / 2
3140
const halfStroke = strokeWidth / 2
3241
const innerRadius = baseRadius - halfStroke
3342
const outerRadius = baseRadius + halfStroke
3443

3544
if (orientation === 0) {
3645
// Top-left corner arcs
37-
pushArcPath(paths, innerRadius, Math.PI / 2, 0, left, top,
38-
new Victor(left, cy - halfStroke), new Victor(cx - halfStroke, top))
39-
pushArcPath(paths, outerRadius, Math.PI / 2, 0, left, top,
40-
new Victor(left, cy + halfStroke), new Victor(cx + halfStroke, top))
46+
pushArcPath(
47+
paths,
48+
innerRadius,
49+
Math.PI / 2,
50+
0,
51+
left,
52+
top,
53+
new Victor(left, cy - halfStroke),
54+
new Victor(cx - halfStroke, top),
55+
)
56+
pushArcPath(
57+
paths,
58+
outerRadius,
59+
Math.PI / 2,
60+
0,
61+
left,
62+
top,
63+
new Victor(left, cy + halfStroke),
64+
new Victor(cx + halfStroke, top),
65+
)
4166

4267
// Bottom-right corner arcs
43-
pushArcPath(paths, innerRadius, -Math.PI / 2, -Math.PI, right, bottom,
44-
new Victor(right, cy + halfStroke), new Victor(cx + halfStroke, bottom))
45-
pushArcPath(paths, outerRadius, -Math.PI / 2, -Math.PI, right, bottom,
46-
new Victor(right, cy - halfStroke), new Victor(cx - halfStroke, bottom))
68+
pushArcPath(
69+
paths,
70+
innerRadius,
71+
-Math.PI / 2,
72+
-Math.PI,
73+
right,
74+
bottom,
75+
new Victor(right, cy + halfStroke),
76+
new Victor(cx + halfStroke, bottom),
77+
)
78+
pushArcPath(
79+
paths,
80+
outerRadius,
81+
-Math.PI / 2,
82+
-Math.PI,
83+
right,
84+
bottom,
85+
new Victor(right, cy - halfStroke),
86+
new Victor(cx - halfStroke, bottom),
87+
)
4788
} else {
4889
// Top-right corner arcs
49-
pushArcPath(paths, innerRadius, Math.PI, Math.PI / 2, right, top,
50-
new Victor(cx + halfStroke, top), new Victor(right, cy - halfStroke))
51-
pushArcPath(paths, outerRadius, Math.PI, Math.PI / 2, right, top,
52-
new Victor(cx - halfStroke, top), new Victor(right, cy + halfStroke))
90+
pushArcPath(
91+
paths,
92+
innerRadius,
93+
Math.PI,
94+
Math.PI / 2,
95+
right,
96+
top,
97+
new Victor(cx + halfStroke, top),
98+
new Victor(right, cy - halfStroke),
99+
)
100+
pushArcPath(
101+
paths,
102+
outerRadius,
103+
Math.PI,
104+
Math.PI / 2,
105+
right,
106+
top,
107+
new Victor(cx - halfStroke, top),
108+
new Victor(right, cy + halfStroke),
109+
)
53110

54111
// Bottom-left corner arcs
55-
pushArcPath(paths, innerRadius, 0, -Math.PI / 2, left, bottom,
56-
new Victor(cx - halfStroke, bottom), new Victor(left, cy + halfStroke))
57-
pushArcPath(paths, outerRadius, 0, -Math.PI / 2, left, bottom,
58-
new Victor(cx + halfStroke, bottom), new Victor(left, cy - halfStroke))
112+
pushArcPath(
113+
paths,
114+
innerRadius,
115+
0,
116+
-Math.PI / 2,
117+
left,
118+
bottom,
119+
new Victor(cx - halfStroke, bottom),
120+
new Victor(left, cy + halfStroke),
121+
)
122+
pushArcPath(
123+
paths,
124+
outerRadius,
125+
0,
126+
-Math.PI / 2,
127+
left,
128+
bottom,
129+
new Victor(cx + halfStroke, bottom),
130+
new Victor(left, cy - halfStroke),
131+
)
59132
}
60133

61134
if (tileBorder) {
@@ -75,15 +148,42 @@ function drawArcTile(bounds, orientation, strokeWidth, tileBorder) {
75148

76149
const paths = []
77150
const { left, right, top, bottom } = bounds
78-
const baseRadius = (bounds.size ?? (right - left)) / 2
151+
const baseRadius = (bounds.size ?? right - left) / 2
79152
const { midLeft, midRight, midTop, midBottom } = getEdgeMidpoints(bounds)
80153

81154
if (orientation === 0) {
82155
pushArcPath(paths, baseRadius, Math.PI / 2, 0, left, top, midLeft, midTop)
83-
pushArcPath(paths, baseRadius, -Math.PI / 2, -Math.PI, right, bottom, midRight, midBottom)
156+
pushArcPath(
157+
paths,
158+
baseRadius,
159+
-Math.PI / 2,
160+
-Math.PI,
161+
right,
162+
bottom,
163+
midRight,
164+
midBottom,
165+
)
84166
} else {
85-
pushArcPath(paths, baseRadius, Math.PI, Math.PI / 2, right, top, midTop, midRight)
86-
pushArcPath(paths, baseRadius, 0, -Math.PI / 2, left, bottom, midBottom, midLeft)
167+
pushArcPath(
168+
paths,
169+
baseRadius,
170+
Math.PI,
171+
Math.PI / 2,
172+
right,
173+
top,
174+
midTop,
175+
midRight,
176+
)
177+
pushArcPath(
178+
paths,
179+
baseRadius,
180+
0,
181+
-Math.PI / 2,
182+
left,
183+
bottom,
184+
midBottom,
185+
midLeft,
186+
)
87187
}
88188

89189
if (tileBorder) {

0 commit comments

Comments
 (0)