/* Copy of Piet Mondrian's Composition with Red, Blue and Yellow (1930) Processing sketch by Michael Goldwasser This version of the implementation uses variables to define the key x and y coordinates for the sketch. */ size(800, 600); background(255); // white noStroke(); // will do black lines separately smooth(); // softer edges // key coordinates for image lines // (vertical lines, left to right; horizontal, top-to-bottom) float x0 = 0; // left float x1 = 0.065 * width; float x2 = 0.1975 * width; float x3 = 0.475 * width; float x4 = 0.595 * width; float x5 = 0.79 * width; float x6 = 0.8975 * width; float x7 = width; // right float y0 = 0; float y1 = 0.2867 * height; float y2 = 0.6233 * height; float y3 = 0.8167 * height; float y4 = height; // bottom // red sections fill(250, 0, 0); // slightly muted rect(x1, y0, x3-x1, y1-y0); rect(x4, y1, x5-x4, y2-y1); rect(x1, y3, x2-x1, y4-y3); // blue sections fill(0, 0, 240); rect(x3, y0, x5-x3, y1-y0); rect(x5, y1, x6-x5, y2-y1); rect(x2, y2, x4-x2, y3-y2); // yellow sections fill(240, 240, 0); // red+green = yellow rect(x1, y0, x2-x1, y1-y0); rect(x5, y0, x6-x5, y1-y0); rect(x5, y2, x6-x5, y3-y2); rect(x2, y3, x4-x2, y4-y3); // time to draw the thick black lines // (which will cover rectangle edges) stroke(0); // black strokeCap(SQUARE); // clean edge strokeWeight(0.0225*width); // i.e., 9 pixels for width=400 // horizontal lines line(x0, y1, x7, y1); line(x0, y2, x6, y2); line(x1, y3, x7, y3); // vertical lines line(x1, y0, x1, y4); line(x2, y0, x2, y4); line(x3, y0, x3, y2); line(x4, y1, x4, y4); line(x5, y0, x5, y3); line(x6, y0, x6, y4); save("myMondrian.jpg");