xxxxxxxxxx
let angle;
let mask;
function setup() {
createCanvas(windowWidth, windowHeight);
angle = PI/4;
let r = min(windowWidth/2, windowHeight/2);
fullscreen();
mask = createGraphics(windowWidth, windowHeight);
mask.background(255);
// mask.ellipse(windowWidth/2, windowHeight/2, r, r);
mask.drawHexa = function(x,y,r){
mask.fill(0);
mask.noStroke();
mask.beginShape();
for (let a = 0; a < TWO_PI; a += TWO_PI / 6) {
let sx = x + cos(a) * r;
let sy = y + sin(a) * r;
mask.vertex(sx, sy);
}
mask.endShape(CLOSE);
mask.noFill();
mask.stroke(0);
mask.beginShape();
for (let a = 0; a < TWO_PI; a += TWO_PI / 6) {
let sx = x + cos(a) * r * 1.1;
let sy = y + sin(a) * r * 1.1;
mask.vertex(sx, sy);
}
mask.endShape(CLOSE);
}
for (let a = 0; a < 3; a ++) {
let sx = windowWidth/4*a+windowWidth/4;
let sy = windowHeight/2;
mask.drawHexa(sx,sy,r/(1+abs(1-a))/2);
}
mask.loadPixels();
for (let i = 0; i < mask.pixels.length; i += 4) {
// set alpha channel to blue level
mask.pixels[i + 3] = mask.pixels[i];
// set pixel color to black
mask.pixels[i] = 0;
mask.pixels[i + 1] = 0;
mask.pixels[i + 2] = 0;
}
mask.updatePixels();
// mask.filter(BLUR, 3);
}
function draw() {
background(0);
let n = noise(frameCount/10);
let intensity = n+.1;
strokeWeight(intensity);
// stroke(210, 70, 50, 60*(1+intensity));
stroke(255, 60*(1+intensity));
let lines= 500;
let xStep = width/lines;
for(let i=1;i<lines;i++){
x=i*xStep;
angle = map(noise((frameCount+i/500)),0,1,-PI/4,PI/4);
push();
translate(x,2*height);
branch(height, angle);
pop();
push();
translate(x, -height);
branch(-height, angle);
pop();
}
image(mask,0,0);
}
function branch(l,a){
if(abs(l) < 4) return;
line(0,0,0,-l);
translate(0,-l);
push();
rotate(a);
branch(l*.45, a);
pop();
}