This built-in function runs only once when the program starts and is usually where you put createCanvas().
What is setup()?
The parameters (x, y, w, h) inside the ellipse() function stand for these four measurements.
What are x-position, y-position, width, and height?
Which keyword is used to create a variable in JavaScript?
Let
What statement allows a program to make decisions?
An if statement
The Rule of Thirds divides a canvas into this total number of equal rectangles using two horizontal and two vertical lines.
What is nine?
Unlike setup(), this function runs continuously in a cycle, allowing you to animate shapes across the screen.
What is draw()?
What are the coordinates of the top-left corner of the canvas?
(0,0)
What variable stores the mouse's x-position?
mouseX
What symbol checks if two values are equal?
==
Instead of placing your main focal point dead-center, the Rule of Thirds suggests placing it along the grid lines or on one of these four spots where lines cross.
What are intersections (or power points)?
In p5.js, the coordinate (0, 0) is located in this specific corner of the canvas.
What is the top-left corner?
Adding a fourth number to fill(255, 0, 0, 100) controls this visual property, also known as opacity.
What is alpha (or transparency)?
Calling random(10, 50) will return a number between 10 and 50, including decimals, unless you wrap it inside this rounding function.
What is floor() (or round() / int())?
What does a loop do?
Repeats code
In a 600-pixel-wide p5.js canvas, your two vertical Rule of Thirds grid lines should be drawn at these two x coordinates.
What are 200 and 400 (or width / 3 and (width / 3) * 2)?
Using two forward slashes (//) allows you to leave these in your code, which the computer completely ignores when running the sketch.
What are comments?
What shape does ellipse(50, 50, 40, 40) create?
An oval
This control structure lets your code make a decision, running a block of code only when a specific condition inside parentheses is true.
What is an if statement (or conditional)?
What happens when an if statement's condition is true?
The code inside the if statement runs.
When coding a landscape in p5.js, placing the horizon line along the bottom third line gives visual emphasis to this part of the scene.
What is the sky?
If you want a shape to have an outline, you use stroke(), but if you want to remove the outline completely, you call this function.
What is noStroke()?
This function requires six numbers—representing three pairs of (x, y) coordinates—to draw a three-sided polygon.
What is triangle()?
To make a variable named x increase by 5 every single frame, you can write x = x + 5; or use this shorter compound assignment operator.
What is x += 5;?
Give an example of when you might use a loop in animation.
To continuously move an object across the screen.
Using dynamic math like width / 3 instead of a hard-coded number ensures your composition stays accurate even if you change this function's arguments.
What is createCanvas()?