// I prepared for five background colors and intended to give a different atmosphere in each. // I specified each ranges of size, color, transparency, edging. // Red and black background: I want to represent the color of the KIMONO (Japanese traditional garment) // White background: clarity, Pink background: lovely, Dark blue: activeness and harmony // // Title Cherry Blossom // color[] palette = {#000000, #ffffff, #EABBD0, #0E3F61, #890303}; int mode; int drawFlag = 1; void setup() { size(1280, 720); smooth(); } void draw() { if (drawFlag == 1) { sakuraDraw(); } if (keyPressed) { if (key == 'c' || key == 'C' || key == DELETE || key == BACKSPACE) drawFlag = 1; if (key == 's' || key == 'S') saveFrame("screenshot.png"); } } void sakuraDraw() { float minSize = width*0.016; float maxSize = width*0.1; int alpha = 255; int rmin, rmax, gmin, gmax, bmin, bmax; noStroke(); mode = int(random(5)); background(palette[mode]); drawFlag = 0; rmin=128; rmax=255; gmin=60; gmax=192; bmin=60; bmax=255; if (mode == 1) { gmin=128; gmax=255; bmin=128; } else if (mode == 2) { rmin=180; gmin=100; gmax=230; bmin=100; bmax=230; } else if (mode == 3) { rmin=60; rmax = 240; } else if (mode == 4) { rmin=60; gmax=150; bmax = 192; } for (int i = 0; i < 100; i++) { float x = random(width); float y = random(height); float size = random(minSize, maxSize); int r = int(random(rmin, rmax)); int g = int(random(gmin, gmax)); int b = int(random(bmin, gmax)); if (mode == 1) { alpha = int(random(128, 230)); color cs = color(r/3, g/3, b/3, alpha); stroke(cs); } else if (mode == 2) { size *= 1.5; stroke(#a01980); } else if (mode == 3) { size *= 1.4; } else if (mode == 4) { size *= 1.2; color cs = color(r/3, g/3, b/3, 255); stroke(cs); } float rot = random(72); sakura(x, y, size, r, g, b, alpha, rot*PI/180); } } void sakura(float x, float y, float size, int r, int g, int b, int alpha, float rot) { color c = color(r, g, b, alpha); color cc = color(255, 255, 0, alpha); fill(c); pushMatrix(); translate(x, y); if (rot != 0) { rotate(rot); } for (int i = 0; i < 5; i++) { beginShape(); vertex(0, -size*0.1); vertex(-size*0.05, -size*0.1); bezierVertex(-size*0.34, -size*0.4, -size*0.38, -size*0.7, -size*0.12, -size); vertex(0, -size*0.8); vertex(size*0.12, -size); bezierVertex(size*0.38, -size*0.7, size*0.34, -size*0.4, size*0.05, -size*0.1); vertex(0, -size*0.1); endShape(); fill(cc); ellipse(0, size*0.07, size*0.07, size*0.07); fill(c); rotate(TWO_PI/5.0); } popMatrix(); }