mirror of
https://github.com/Findus23/RainbowRoad.git
synced 2024-09-19 16:03:52 +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 start = new Vector2d(10, 110)
|
||||||
const end = new Vector2d(110, 60)
|
const end = new Vector2d(110, 60)
|
||||||
const line = new Line(start, end)
|
const line = new Line(start, end)
|
||||||
drawZebraCrossing(ctx, new Line(start, new Vector2d(50, 50)),30, zebraPattern)
|
const numLines = 10;
|
||||||
drawZebraCrossing(ctx, line,30, prideZebraPattern)
|
drawZebraCrossing(ctx, new Line(start, new Vector2d(50, 50)), 30, zebraPattern, numLines)
|
||||||
drawZebraCrossing(ctx, new Line(end, new Vector2d(160, 80)),30, transZebraPattern)
|
drawZebraCrossing(ctx, line, 30, prideZebraPattern, numLines)
|
||||||
drawZebraCrossing(ctx, new Line(new Vector2d(160, 80), new Vector2d(120, 150)),30, nonbinaryZebraPattern)
|
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)
|
// line.draw(ctx)
|
||||||
// const line = new Line(start, end)
|
// const line = new Line(start, end)
|
||||||
//
|
//
|
||||||
|
|
|
@ -36,17 +36,11 @@ export function drawZebraCrossing(
|
||||||
ctx: CanvasRenderingContext2D,
|
ctx: CanvasRenderingContext2D,
|
||||||
line: Line,
|
line: Line,
|
||||||
zebraWidth: number,
|
zebraWidth: number,
|
||||||
pattern: (i: number) => string, numStripes?: number
|
pattern: (i: number) => string, numStripes: number
|
||||||
): void {
|
): void {
|
||||||
const ex = line.vec
|
const ex = line.vec
|
||||||
const ey = line.vec.rotate90deg().toLength(zebraWidth)
|
const ey = line.vec.rotate90deg().toLength(zebraWidth)
|
||||||
const eoff = line.start
|
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 stripeLength = 1
|
||||||
const stripeWidth = stripeLength / numStripes
|
const stripeWidth = stripeLength / numStripes
|
||||||
|
|
Loading…
Reference in a new issue