forked from NoahNaiman/Color-Annihilator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNoColor.js
More file actions
30 lines (23 loc) · 830 Bytes
/
Copy pathNoColor.js
File metadata and controls
30 lines (23 loc) · 830 Bytes
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
var canvas = document.createElement('canvas');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
canvas.style.position = "fixed";
canvas.style.zIndex = 10;
canvas.style.pointerEvents = "none";
document.body.insertBefore(canvas, document.body.firstChild);
var c = document.querySelector("canvas")
var ctx = c.getContext('2d');
var width = window.innerWidth;
var height = window.innerHeight;
var rainbow = true;
var interval = setInterval(drawColor, 100);
function drawColor(){
if (rainbow){
var r = Math.round(255*Math.random());
var g = Math.round(255*Math.random());
var b = Math.round(255*Math.random());
var rgb = [r, g, b];
ctx.fillStyle = 'rgb(' + rgb.join(",") + ')';
}
ctx.fillRect((Math.random() * width), (Math.random() * height), Math.round(width/500), Math.round(height/500));
}