From d0867343856568fec2ca3c4dca6555bae1c52548 Mon Sep 17 00:00:00 2001 From: UltraQbik Date: Sun, 25 Aug 2024 17:49:01 +0300 Subject: I hate JS --- www/scripts/test.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'www') diff --git a/www/scripts/test.js b/www/scripts/test.js index a48327c..e9afd91 100644 --- a/www/scripts/test.js +++ b/www/scripts/test.js @@ -1,9 +1,14 @@ const canvas = document.getElementById("JSCanvas"); const ctx = canvas.getContext("2d"); -ctx.strokeStyle = "blue" -ctx.beginPath(); -ctx.moveTo(0, 0); -ctx.lineTo(511, 511); -ctx.stroke(); +function draw() { + ctx.strokeStyle = "#" + Math.floor(Math.random() * 16777216).toString(16).padStart(6, '0') + ctx.beginPath(); + ctx.moveTo(Math.random() * 511, Math.random() * 511); + ctx.lineTo(Math.random() * 511, Math.random() * 511); + ctx.stroke(); +} +for (let i = 0; i < 50; i++) { + draw() +} -- cgit 1.4.1