xxxxxxxxxx
// tribute to Monderian
// recreating https://www.piet-mondrian.org/assets/img/paintings/tableau-ii.jpg
// trial 1: suggestion by ChatGPT
// schien@mail.ncku.edu.tw
function setup() {
createCanvas(400, 400); // Define the canvas size
noLoop(); // Only draw once
rectMode(CORNER); // Set rectangle drawing mode to start from the top-left corner
}
function draw() {
background(255); // Set the background to white
// Colors for the rectangles
let red = color(255, 0, 0);
let blue = color(0, 0, 255);
let yellow = color(255, 255, 0);
let white = color(255, 255, 255);
// Define the positions and sizes of the rectangles
fill(red); // Set color to red
rect(0, 0, 200, 200); // Draw red rectangle in the top left
fill(blue); // Set color to blue
rect(200, 0, 200, 100); // Draw blue rectangle on the top right
fill(yellow); // Set color to yellow
rect(200, 100, 200, 100); // Draw yellow rectangle on the bottom right
fill(white); // Set color to white
rect(0, 200, 200, 200); // Draw white rectangle on the bottom left
// Drawing the black lines (borders between the rectangles)
stroke(0); // Set stroke color to black
strokeWeight(5); // Set the line thickness
// Vertical lines
line(200, 0, 200, height); // Vertical line between left and right rectangles
// Horizontal lines
line(0, 200, width, 200); // Horizontal line between top and bottom rectangles
}