xxxxxxxxxx
88
let carpet;
let wall;
let words;
let jewels;
function setup() {
createCanvas(400, 600);
carpet = color( '#700a06' );
wall = color( '#311908' );
words = color( '#f9bf00' );
jewels = [
color( '#53344d' ),
color( '#242b3f' ),
color( '#97591e' ),
color( '#ec6e01' ),
color( '#b29817' ),
color( '#2e3944' ),
color( '#37746e' ),
color( '#f31a5c' ),
color( '#a84f75' ),
color( '#bf303b' )
]
}
function draw() {
background( carpet );
noStroke();
rectMode( CORNER );
fill( wall );
rect( 0, 0, width, height/2 );
fill( 0 );
rect( 0, height/2, width, height/4 );
fill( words );
rect( 50, height/6, width - 100, height/6 );
rect( 120, height/3, width - 240, height/6 );
let num = int(random(8,15));
let things = [];
for( let idx = 0; idx < num; ++idx ) {
things.push( [map(idx,0,num-1,50,width-50) + random(-10,10),
height/2 - 50 + random(10,50)] );
}
things.sort( function( a, b ) { return a[1] - b[1]; } );
// colorMode( HSB, 255 );
for( let j of things ) {
push();
translate( j[0], 200 + j[1] );
rotate( PI );
// fill( random( 255 ), 255, random( 150, 200 ) );
fill( jewels[int(random(jewels.length))] );
blob();
pop();
}
//colorMode( RGB, 255 );
noLoop();
}
function blob()
{
beginShape();
// curveVertex( 0, 0 );
let y = random( -5, 5 );
while( y < 220 ) {
curveVertex( random( -40, -10 ), y );
y += random( 20, 40 );
}
while( y >= 0 ) {
y -= random( 20, 40 );
curveVertex( random( 10, 40 ), y );
}
// curveVertex( 0, random( 0, 20 ) );
endShape( CLOSE );
}
function keyPressed()
{
if( key == ' ' ) {
loop();
} else if( key == 's' ) {
save( 'output.png' );
}
}