xxxxxxxxxx
// This is the suggested starting sketch for the "Random Rectangles Challenge"
// It is a JavaScript file using the p5 library. We call it a p5 "sketch".
//
// You can read the challenge details here:
// https://www.notion.so/neillzero/Challenge-Random-Rectangles-e14b3c5beb4a45d1b58bed639b89a787
//
// About "comments"
// These lines to the right of a // are "comments" for human readers!
// The computer ignores them.
// Feel FREE to delete these comments and add your own to describe YOUR sketch.
//This "setup" function is called once, at start
function setup() {
createCanvas(600, 600); // width and height, in pixels
background('gray');
}
// We put our drawing commands in this "draw" function.
// It will be called automatically, up to 60 times per second!
function draw() {
fill("orange")
drawRandomRect()
// fill('darkorange'); // Colour-in the next shapes, this colour, please!
// // noStroke(); // Don't outline the next shapes, please.
// //Draw a rectangle positioned at x: 200, y: 100,
// //and with a width of 300 and height of 150
// rect(200, 100, 300, 150);
// //draw another rectangle elsewhere
// rect(50, 200, 100, 100);
}
function drawRandomRect() {
//goal: draw a rectangle of random size, position and colour
//start with: draw an orange rectangle of size 300,
//150 at random position
//second stage: random sizes between 0 and 300 for both width and height
rect(random(width), random(height), random(300), random(150));
}