xxxxxxxxxx
129
// credit: https://openprocessing.org/sketch/1241664
var colors1 = "aa1155-880044-dd1155-ffee88-00cc99".split("-").map(a=>"#"+a)
var colors2 = "003844-006c67-f194b4-ffb100-ffebc6".split("-").map(a=>"#"+a)
let overAllTexture
function preload(){
overAllTexture = loadImage("canvas.jpg")
}
function setup() {
createCanvas(1920,1080);
background(100);
pixelDensity(4)
// drawingContext.shadowColor = color(0,100)
// drawingContext.shadowOffsetX = 5
// drawingContext.shadowOffsetY = 5
// drawingContext.shadowBlur = 5
}
function divPoly(x,y,r,angle,d,colors){
if (random()<0.3){
colors = random([colors1,colors2])
}
push()
translate(x,y)
rotate(angle)
translate(random(-0.5,0.5)*r/2,
random(-0.5,0.5)*r/2)
rotate(PI/40)
// shearX(0.05)
scale(0.7+random(0,0.1))
// rotate(random(-0.1,0.1))
let cCount = 6
let angSpan = 2*PI/cCount
// fill(0)
let points = []
beginShape()
for(var i=1;i<= cCount;i++){
let ang1 = angSpan*(i-1)
let xx1 = r*cos(ang1)*4/5
let yy1 = r*sin(ang1)*4/5
// let ang2 = angSpan*i
// let xx2 = r*cos(ang2)
// let yy2 = r*sin(ang2)
points.push({x: xx1,y: yy1})
if (random()<0.6){
curveVertex(xx1,yy1)
}else{
// curveVertex(0,0)
// curveVertex(xx1,yy1)
// curveVertex(xx1,yy1)
}
}
// if (random()<0.3){
// strokeWeight(random(10))
// stroke(0)
// }
// noFill()
noStroke()
fill(random(colors))
endShape(CLOSE)
strokeWeight(random(4))
// line(xx1,yy1,xx2,yy2)
if (random()<0.6){
d--
}
noStroke()
points.forEach(p=>{
if (random()<0.6){
noStroke()
stroke(random(colors))
ellipse(p.x*0.5,p.y*0.5,random(sqrt(r)))
line(0,0,p.x/2,p.y/2)
}
for(var i=1;i<5;i++){
if (random()<0.2){
fill(random(colors))
ellipse(p.x*i/5,p.y*i/5,sqrt(r/2*i))
}
}
if (d>0){
divPoly(p.x,p.y,r/random(1.5,2),0,d-1,colors)
}
})
fill(random(colors))
ellipse(0,0,random(sqrt(r)*2))
pop()
}
// function mousePressed(){
// save()
// }
function draw() {
if (frameCount%200==0 || frameCount==1){
fill(random(["#003844","white",'black']) )
rect(0,0,width,height)
noStroke()
divPoly(width/2,height/2,width/1.4,random(-1,1),6,colors1)
// overAllTexture=createGraphics(width,height)
// overAllTexture.loadPixels()
// // noStroke()
// for(var i=0;i<width+50;i++){
// for(var o=0;o<height+50;o++){
// overAllTexture.set(i,o,color(100,noise(i/3,o/3,i*o/50)*random([0,0,40,100])))
// }
// }
// overAllTexture.updatePixels()
push()
blendMode(MULTIPLY)
image(overAllTexture,0,0,width,height)
pop()
}
// ellipse(mouseX, mouseY, 20, 20);
}