mirror of
https://github.com/Findus23/RainbowRoad.git
synced 2024-09-13 09:03:51 +02:00
simplify code
This commit is contained in:
parent
703667e3fa
commit
107cbae49d
2 changed files with 6 additions and 11 deletions
|
@ -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)
|
||||
//
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue