xxxxxxxxxx
let palettes = [
{
name: "Day",
colors: ['#7999C4','#31519C','#102756','#E6FFFF'],
},
{
name: "End of Days",
colors: ['#980000','#CB4444','#9B3535','#E5E5E5'],
}
// background, building front, building left, clouds
];
let w,h,x,y,cw,ch,lx,ly,ls,f,fmax,fmin,fh,fw,chance,a,paletteName,colors;
function setup() {
w = 600; h = 600;
createCanvas(w,h);
colorSetup();
setBackground();
fmax=20;
fmin=fmax-5;
strokeWeight(1);
for(let i=0;i<25;i++){
cloud();
}
for(let i=0;i<2;i++){
building();
fmax=fmax-4;
fmin=fmin-4;
}
}
function setBackground(){
// gradient background
for (x = 0; x < w; x++) {
for (y = 0; y < h; y++) {
chance = random(0,1);
stroke(colors[0]);
strokeWeight(random(1,3));
if(chance > .1) { point(x, y);}
}
}
}
function building(){
x = random(0-w/10,w-w/10);
y = h+25; //building x y setup
f=int(random(fmin,fmax));
fh=int(random(30,40));
fw=fh*int(random(5,8));
noStroke();
fill(colors[1]); //base blocks of buildin, left
quad(x+fw*.05,y,x+fw*.05,y-(f*fh-5),x+fw,y-(f*fh+5),x+fw,y-10);
fill(colors[2]); //base blocks of buildin, right
quad(x+fw,y-10,x+fw,y-(f*fh+5),x+fw*1.45,y-(f*fh-5),x+fw*1.45,y);
strokeWeight(1);
stroke('#8C8686');
ls = int(random(5,10));
for(let i=0;i<f;i++){ //floors of building
fill('#D7D7D7');
quad(x,y-fh/2,x,y-fh,x+fw,y-fh*1.5,x+fw,y-fh); //floor, left
lx=x+fw/ls;
ly=y; //line setup and lines on floors
while(lx<x+fw)
{
line(lx,ly-fh*.05,lx,ly-fh*.45);
lx=lx+fw/ls;
ly=ly-fh/(ls*2);
}
stroke('#8C8686');
fill('#6F6F6F')
quad(x+fw,y-fh*1.5,x+fw,y-fh,x+fw*1.5,y-fh/2,x+fw*1.5,y-fh); //floor, right
lx=x+fw;
ly=y; //line setup and lines on floors
stroke('#C4C4C4');
while(lx<x+fw*1.45)
{
line(lx,ly-fh*.85,lx,ly-fh*.55);
lx=lx+fw/ls;
ly=ly+fh/ls;
}
y=y-fh;
}
}
function cloud(){
x = random(0,w);
y = random(0,h-h/2);
cw =int(random(25,50));
ch=cw/2;
stroke(colors[3]);
for(let o=0;o<ch;o++){
for(let i=0;i<cw;i++){
strokeWeight(random(1,10));
chance = random(0,1);
if(chance > .9) { point(x-i, y-o);}
chance = random(0,1);
if(chance > .9) { point(x-i, y+o);}
chance = random(0,1);
if(chance > .9) { point(x+i, y-o)}
chance = random(0,1);
if(chance > .9) { point(x+i, y+o)}
}
cw=cw-2;
}
}
function colorSetup(){
a = int(random(0,palettes.length));
paletteName = palettes[a].name;
colors = palettes[a].colors;
}