P5.js Flashcards
Learn about P5.js coding (33 cards)
What is P5.js?
P5.js is a JavaScript library designed for creative coding.
True or False: P5.js is primarily used for data analysis.
False
Fill in the blank: P5.js is built on top of ______.
JavaScript
What function is used to set up the initial environment in P5.js?
setup()
What function is called repeatedly to create animations in P5.js?
draw()
What does the size() function do in P5.js?
It sets the dimensions of the canvas.
Which function would you use to change the background color in P5.js?
background()
True or False: P5.js supports 3D graphics.
True
What keyword is used to declare a variable in P5.js?
var, let, or const
What is the purpose of the draw() function?
To continuously execute the lines of code contained inside its block.
Which function is used to draw a rectangle in P5.js?
rect()
What does the fill() function do?
It sets the color used for shapes.
What is an array in P5.js?
A data structure that can hold multiple values.
How do you create a comment in P5.js?
// This is a comment
What does the noLoop() function do?
It stops the draw() function from looping.
True or False: P5.js can only create static images.
False
What is the purpose of the mousePressed() function?
It executes code when the mouse is pressed.
Which function is used to change the stroke color of shapes?
stroke()
What does the text() function do?
It displays text on the canvas.
How do you create a new P5.js sketch?
By writing code within the setup() and draw() functions.
What is the purpose of the keyPressed() function?
It executes code when a key is pressed.
Fill in the blank: To create a circle in P5.js, you use the ______ function.
ellipse()
What does the noFill() function do?
It disables filling shapes with color.
How can you change the size of a shape in P5.js?
By changing the parameters of the shape function (e.g., rect(), ellipse()).