xxxxxxxxxx
72
const lights = []
function setup() {
createCanvas(1000, 1000);
strokeWeight(3)
var count = 0;
for (var y = -50; y < height*1.2 ; y+=150){
for (var x = -50; x < width*1.2; x+=150){
for (var dx of [-1,0,1]){ // = - PI ; dx < PI; dx += -.0001+PI){
for (var dy of [-1,0,1]) //= -PI ; dy < PI; dy += -.0001+PI/4)
{
lights.push([createVector(x, y), createVector(dx, dy)])
lights.push([createVector(x+15, y+5), createVector(dx, dy)])
count+=2
}
}
}
}
print(count)
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
lights.splice(0, lights.length())
var count = 0;
for (var y = -50; y < height*1.2 ; y+=150){
for (var x = -50; x < width*1.2; x+=150){
for (var dx of [-1,0,1]){ // = - PI ; dx < PI; dx += -.0001+PI){
for (var dy of [-1,0,1]) //= -PI ; dy < PI; dy += -.0001+PI/4)
{
lights.push([createVector(x, y), createVector(dx, dy)])
lights.push([createVector(x+15, y+5), createVector(dx, dy)])
count+=2
}
}
}
}
print(count)
}
function draw() {
background(0)
c = true
for (const [i,[l,v]] of lights.entries()) {
if (c){
stroke(255,0,0)
} else{
stroke(0,255,0)
l.add(v)
v.rotate(0.009)
}
point(l.x, l.y)
l.add(v)
v.rotate(0.009)
c = !c
}
}