xxxxxxxxxx
// testing javascript -> p5js by Perplexity AI
// Mondrian composition with red, blue, and yellow
// Sheng-Fen Chien <schien@mail.ncku.edu.tw>
// March 2010
// Q: I want to reduce the size of the red block. How can I do it? Can you show me?
// Grok: To reduce the size of the red block in your p5.js program, you can adjust the parameters in the rect() function call for the red block. Here's how you can modify the code to make the red block smaller:
function setup() {
// Create canvas 465x480
createCanvas(465, 480);
// Set background as black
background(0);
// Draw the red block with reduced size
noStroke();
fill(231, 62, 23);
// Original: rect(120, 0, 465 - 120, 338);
rect(120, 0, 300, 300); // Reduced width and height
// Rest of the code remains the same
// Draw the blue block
fill(82, 90, 165);
rect(0, 353, 108, 480 - 353);
// Draw the yellow block
fill(249, 244, 2);
rect(447, 425, 465 - 447, 480 - 425);
// Draw white blocks
fill(255, 255, 255);
// Left-top white block
rect(0, 0, 108, 135);
// Left-middle white block
rect(0, 155, 108, 338 - 155);
// Bottom-middle white block
rect(120, 353, 437 - 120, 480 - 353);
// Above yellow white block
rect(447, 353, 465 - 447, 407 - 353);
}
function draw() {
// No continuous drawing needed; all shapes are drawn in setup()
}