57
loading...
This website collects cookies to deliver better user experience
<canvas id='mainCanvas'>Displayed if canvas isn't supported.</canvas>
canvas.width = window.innerWidth
canvas.height = window.innerHeight
ctx = canvas.getRenderContext('2d')
let rectWidth = 5
let rectHeight = 5
ctx.fillStyle = 'black'
ctx.rect( canvas.width/2, canvas.height/2, rectWidth, rectHeight)
ctx.fill()
function render(){
point.x += (Math.random()-.5)*5
point.y += (Math.random() -.5)*5
ctx.rect( point.x, point.y, 5, 5)
ctx.fill()
window.requestAnimationFrame(render);
}
ctx.fillStyle = `rgba(${time%255}, ${time%50}, ${time%127}, 1)`
let points = []
for(let i = 0; i < numPoints; i++){
let point = {x: canvas.width/numPoints*i,
y: canvas.height/2}
points.push(point)
}
points.forEach( (point, i) =>{
ctx.beginPath()
point.x += (Math.random()-.5)*5
point.y += (Math.random() -.5)*5
ctx.rect( point.x, point.y, 5, 5)
ctx.fill()
})