Simple example of https://generativeartistry.com/tutorials/tiled-lines/
Last active
December 13, 2018 08:14
-
-
Save Gazzell/1150bec9234965436e94935ba482ccc1 to your computer and use it in GitHub Desktop.
Maze
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<canvas id='canvas' width='800' height='800'></canvas> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const canvas = document.getElementById("canvas"); | |
const ctx = canvas.getContext("2d"); | |
const width = canvas.width; | |
const height = canvas.height; | |
const size = 20; | |
function drawRandomDiagonal(x, y) { | |
const start0 = Math.random() >= 0.5; | |
if (start0) { | |
ctx.moveTo(x, y); | |
ctx.lineTo(x + size, y + size); | |
} else { | |
ctx.moveTo(x, y + size); | |
ctx.lineTo(x + size, y); | |
} | |
ctx.stroke(); | |
} | |
ctx.lineWidth = 2; | |
for (let x = 0; x < width; x += size) { | |
for (let y = 0; y < height; y += size) { | |
drawRandomDiagonal(x, y); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment