Skip to content

Commit 30e5a5e

Browse files
committed
add default line colors
1 parent 6fcd2e3 commit 30e5a5e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/drawGraphicsToCanvas.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type {
1111
CenterViewbox,
1212
TransformOptions,
1313
} from "./types"
14+
import { defaultColors } from "site/components/InteractiveGraphics/defaultColors"
1415

1516
/**
1617
* Computes a transformation matrix based on a provided viewbox
@@ -215,7 +216,7 @@ export function drawGraphicsToCanvas(
215216

216217
// Draw lines
217218
if (graphics.lines && graphics.lines.length > 0) {
218-
graphics.lines.forEach((line) => {
219+
graphics.lines.forEach((line, lineIndex) => {
219220
if (line.points.length === 0) return
220221

221222
ctx.beginPath()
@@ -228,7 +229,8 @@ export function drawGraphicsToCanvas(
228229
ctx.lineTo(projected.x, projected.y)
229230
}
230231

231-
ctx.strokeStyle = line.strokeColor || "black"
232+
ctx.strokeStyle =
233+
line.strokeColor || defaultColors[lineIndex % defaultColors.length]
232234
if (line.strokeWidth) {
233235
ctx.lineWidth = line.strokeWidth * matrix.a
234236
} else {

0 commit comments

Comments
 (0)