P5.js Flashcards

Learn about P5.js coding (33 cards)

1
Q

What is P5.js?

A

P5.js is a JavaScript library designed for creative coding.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or False: P5.js is primarily used for data analysis.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Fill in the blank: P5.js is built on top of ______.

A

JavaScript

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What function is used to set up the initial environment in P5.js?

A

setup()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What function is called repeatedly to create animations in P5.js?

A

draw()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the size() function do in P5.js?

A

It sets the dimensions of the canvas.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which function would you use to change the background color in P5.js?

A

background()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

True or False: P5.js supports 3D graphics.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What keyword is used to declare a variable in P5.js?

A

var, let, or const

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the purpose of the draw() function?

A

To continuously execute the lines of code contained inside its block.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which function is used to draw a rectangle in P5.js?

A

rect()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does the fill() function do?

A

It sets the color used for shapes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is an array in P5.js?

A

A data structure that can hold multiple values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you create a comment in P5.js?

A

// This is a comment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does the noLoop() function do?

A

It stops the draw() function from looping.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

True or False: P5.js can only create static images.

17
Q

What is the purpose of the mousePressed() function?

A

It executes code when the mouse is pressed.

18
Q

Which function is used to change the stroke color of shapes?

19
Q

What does the text() function do?

A

It displays text on the canvas.

20
Q

How do you create a new P5.js sketch?

A

By writing code within the setup() and draw() functions.

21
Q

What is the purpose of the keyPressed() function?

A

It executes code when a key is pressed.

22
Q

Fill in the blank: To create a circle in P5.js, you use the ______ function.

23
Q

What does the noFill() function do?

A

It disables filling shapes with color.

24
Q

How can you change the size of a shape in P5.js?

A

By changing the parameters of the shape function (e.g., rect(), ellipse()).

25
What is a sketch in P5.js?
A project created using the P5.js library.
26
True or False: P5.js has built-in functions for sound.
True
27
What is the function to load images in P5.js?
loadImage()
28
What is the purpose of the createCanvas() function?
To create a drawing canvas.
29
Fill in the blank: To create a line in P5.js, you use the ______ function.
line()
30
What does the image() function do?
It displays an image on the canvas.
31
Which function is used to reset the sketch in P5.js?
clear()
32
What is the purpose of the random() function?
To generate a random number.
33
How do you access the P5.js reference documentation?
By visiting the P5.js website.