<aside> ⚠️ Please include answers as prompted on your student page, under ‘p5.js warm up’
</aside>
I recommend using the p5.js web editor here. Work through each of the examples below.
Place a circle somewhere on the page! See p5.js documentation for help.
function setup() {
createCanvas(400, 400);
}
function draw() {
//place your circle somewhere here
}
setup() and draw() functions do?
//this function runs one
function setup() {
createCanvas(400, 400);
}
function draw() {
fill(random(255), random(255), random(255));
ellipse(width/2, height/2, 50, 50)
}
let x = 0;
function setup() {
createCanvas(500, 500)
background(100);
}
function draw() {
ellipse(x, height/2, 20, 20);
x = x + 1;
}
Taken from p5.js examples
Try this out, no submission
function setup() {
createCanvas(500, 500);
background(230);
strokeWeight(2);
}
function draw() {
if (mouseIsPressed) {
stroke(255);
} else {
stroke(237, 34, 93);
}
line(mouseX - 66, mouseY, mouseX + 66, mouseY);
line(mouseX, mouseY - 66, mouseX, mouseY + 66);
}