-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
31 lines (25 loc) · 838 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// example
const canvas = document.createElement("canvas");
canvas.id = "myCanvas";
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
canvas.style.zIndex = 8;
canvas.style.position = "absolute";
const body = document.getElementsByTagName("body")[0];
body.appendChild(canvas);
const ctx = canvas.getContext("2d");
function drawArt() {
// example
const width = window.innerWidth;
const height = window.innerHeight;
canvas.width = width;
canvas.height = height;
ctx.clearRect(0, 0, width, height);
ctx.fillStyle = `rgba(${randomM0() * 255}, ${randomM0() * 255}, ${
randomM0() * 255
}, 1)`;
ctx.fillRect(0, 0, width, height);
ctx.fillStyle = "rgba(0, 255, 0, 1)";
ctx.fillRect(m1 * width, m2 * height, m3 * width * 0.5, m4 * height * 0.5);
triggerPreview();
}