diff --git a/src/simpledraw.ts b/src/simpledraw.ts index 23fb350..d30f138 100644 --- a/src/simpledraw.ts +++ b/src/simpledraw.ts @@ -17,10 +17,11 @@ function main() { const start = new Vector2d(10, 110) const end = new Vector2d(110, 60) const line = new Line(start, end) - drawZebraCrossing(ctx, new Line(start, new Vector2d(50, 50)),30, zebraPattern) - drawZebraCrossing(ctx, line,30, prideZebraPattern) - drawZebraCrossing(ctx, new Line(end, new Vector2d(160, 80)),30, transZebraPattern) - drawZebraCrossing(ctx, new Line(new Vector2d(160, 80), new Vector2d(120, 150)),30, nonbinaryZebraPattern) + const numLines = 10; + drawZebraCrossing(ctx, new Line(start, new Vector2d(50, 50)), 30, zebraPattern, numLines) + drawZebraCrossing(ctx, line, 30, prideZebraPattern, numLines) + drawZebraCrossing(ctx, new Line(end, new Vector2d(160, 80)), 30, transZebraPattern, numLines) + drawZebraCrossing(ctx, new Line(new Vector2d(160, 80), new Vector2d(120, 150)), 30, nonbinaryZebraPattern, numLines) // line.draw(ctx) // const line = new Line(start, end) // diff --git a/src/zebraUtils.ts b/src/zebraUtils.ts index 5adb024..34437a6 100644 --- a/src/zebraUtils.ts +++ b/src/zebraUtils.ts @@ -36,17 +36,11 @@ export function drawZebraCrossing( ctx: CanvasRenderingContext2D, line: Line, zebraWidth: number, - pattern: (i: number) => string, numStripes?: number + pattern: (i: number) => string, numStripes: number ): void { const ex = line.vec const ey = line.vec.rotate90deg().toLength(zebraWidth) const eoff = line.start -// console.log(line.length()) -// console.log(line.vec) - if (typeof numStripes === "undefined") { - numStripes = Math.floor(line.vec.length() / 6) - } - // console.log(numStripes) const stripeLength = 1 const stripeWidth = stripeLength / numStripes