You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/tutorials/en/animating-with-media-objects.mdx
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -83,7 +83,7 @@ For more information on these concepts see these tutorials: [Get Started](/tutor
83
83

84
84
85
85
86
-
####Image files
86
+
### Image files
87
87
88
88
Image files store the grid of colored pixels that make up an image. There are a number of different image file types that p5.js can process.. The most common image types are JPEGs, PNGs, or GIFs. You can identify them by the extension found at the end of their filenames: `.jpg`, `.png`, `.gif`.
89
89
@@ -1230,14 +1230,14 @@ function keyPressed() {
1230
1230
```
1231
1231
1232
1232
1233
-
###Conclusion
1233
+
## Conclusion
1234
1234
1235
1235
Congratulations on completing this tutorial! You have now created and [modified a GIF animation](https://editor.p5js.org/joanneamarisa/sketches/PFmWqy0qB) using p5.js. Visit the p5.js Reference pages below to explore other ways to display and manipulate images, pixels, and animated GIFs in p5.js.
1236
1236
1237
1237
Here is [the complete code from this tutorial](https://editor.p5js.org/joanneamarisa/sketches/PFmWqy0qB) for reference.
Copy file name to clipboardExpand all lines: src/content/tutorials/en/get-started.mdx
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -66,7 +66,7 @@ Using the [p5.js Web Editor](https://editor.p5js.org/):
66
66
67
67

68
68
69
-
####Default Code
69
+
### Default Code
70
70
71
71
All p5.js projects include the p5.js library and three files: [`index.html`](https://www.classes.cs.uchicago.edu/archive/2021/spring/11111-1/happycoding/p5js/web-dev.html#:~:text=The%20index.,the%20page%20using%20HTML%20tags!), [style.css](https://happycoding.io/tutorials/p5js/web-dev), and `sketch.js`. Make changes on the canvas by adding code to the sketch.js file. New p5.js projects begin with the following code in the sketch.js file:
Copy file name to clipboardExpand all lines: src/content/tutorials/en/variables-and-change.mdx
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -113,7 +113,7 @@ To keep this text shown, make sure this code appears on the last lines in [`draw
113
113
Visit this [reference](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Writing_style_guide/Code_style_guide/JavaScript#comments) or watch [this video](https://www.youtube.com/watch?v=xJcrPJuem5Q) to learn more about comments.
114
114
115
115
116
-
#####Variables
116
+
### Variables
117
117
118
118
Variables store values in them that we can use in our sketch. **Variables are very helpful when adding elements to your sketch that will change over time.** They can be used in calculations, messages, as function arguments, and so much more!
119
119
@@ -122,7 +122,7 @@ Variables store values in them that we can use in our sketch. **Variables are ve
122
122
In the template above, you use [`mouseX`](/reference/p5/mouseX) and [`mouseY`](/reference/p5/mouseY) to print the x- and y-coordinates of the mouse on the canvas using the [`text()`](/reference/p5/text) function. Variables can be displayed on the canvas alongside text using the [`text()`](/reference/p5/text) function and [string interpolation](https://www.geeksforgeeks.org/string-interpolation-in-javascript/) (example 2).
123
123
124
124
125
-
#####String Interpolation
125
+
### String Interpolation
126
126
127
127
In [Get Started,](/tutorials/get-started) you learned that strings are [data types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures) that are always surrounded by quotation marks (`""`). To use variables and strings together, we can use [template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) to help us! Template literals begin and end with backticks (`\`\``) instead of quotation marks (`""`). You can type any character in between the backticks to generate a string like in [this example](https://editor.p5js.org/Msqcoding/sketches/pfSJLvxOB). You can include a variable in the string using the `${}` placeholder, and by placing the name of the variable inside the curly brackets like in [this example](https://editor.p5js.org/Msqcoding/sketches/8sM-h5Hd9).
128
128
@@ -272,7 +272,7 @@ function draw() {
272
272
In the code above, the cloud is drawn using [`ellipse()`](/reference/p5/ellipse) with `cloudOneX` (which stores the number 50) as its x-coordinate, 50 as a y-coordinate, a width of 80 pixels, and a height of 40 pixels.
273
273
274
274
275
-
#####Custom Variables
275
+
### Custom Variables
276
276
277
277
Custom variables store values, like [numbers](/reference/p5/number) or [strings](/reference/p5/String), that can change later. Since custom variables store values that can change, we can use them to change the x- or y-coordinates and size of shapes on the canvas. When the x- or y-coordinate of a shape changes, it appears to be moving. In this step:
278
278
@@ -289,7 +289,7 @@ Custom variables store values, like [numbers](/reference/p5/number) or [strings]
289
289
Finally, you can use the variable name `cloudOneX` as the argument for the x-coordinate in [`ellipse()`](/reference/p5/ellipse). Since the variable `cloudOneX` has the number 50 stored in it, we can use `cloudOneX` as an argument in any function that requires a number. Here, you used it as the x-coordinate of the white cloud by replacing the number 50 with the variable name `cloudOneX`: `ellipse(cloudOneX, 50, 80, 40);`.
290
290
291
291
292
-
#####Variable Scope
292
+
### Variable Scope
293
293
294
294
A *variable’s scope* describes where the variable can be used in a program. It is often useful to declare custom variables outside of [`setup()`](/reference/p5/setup) and [`draw()`](/reference/p5/draw) because it allows the variables to have a *global scope*. A variable with a *global scope* can be used anywhere in the program. Global variables are often declared on the very first lines of code. This helps programmers get an understanding of what is changing, makes the code easier to maintain, and avoids confusion further down in code. Built-in variables such as [`mouseX`](/reference/p5/mouseX), [`mouseY`](/reference/p5/mouseY), [`width`](/reference/p5/width), and [`height`](/reference/p5/height) do not have to be declared because they are built into the p5.js library, and you can use them anywhere in your code because they have global scope!
295
295
@@ -298,7 +298,7 @@ Variables declared inside of other functions (like [`draw()`](/reference/p5/draw
298
298
Visit these p5.js reference pages to learn more about declaring, initializing, and using custom variables: [`let`](/reference/p5/let), [numbers](/reference/p5/number), & [strings](/reference/p5/String).
299
299
300
300
301
-
#####Using Variables for Animation
301
+
### Using Variables for Animation
302
302
303
303
A shape on the canvas appears to be moving when its x- or y-coordinates change. We can use variables in place for the x- or y-coordinates of anything that appears on the canvas. In the example:
304
304
@@ -530,7 +530,7 @@ When the program runs:
530
530
See [this example](https://editor.p5js.org/p5Master718/sketches/wpAhQK9WN), which displays values for [`frameCount`](/reference/p5/frameCount) and `frameCount % width` as shapes move across the canvas. Visit the [Remainder reference on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Remainder) to learn more!
531
531
532
532
533
-
#####Animation and draw()
533
+
### Animation and draw()
534
534
535
535
The [`draw()`](/reference/p5/draw) function runs code repeatedly and behaves much like a flipbook when animating a series of still drawings.
536
536
@@ -547,7 +547,7 @@ Each time [`draw()`](/reference/p5/draw) reads the lines of code for the backgro
547
547
Visit the p5.js reference for [`draw()`](/reference/p5/draw) for more information.
548
548
549
549
550
-
#####`frameRate()`, `frameCount` and `console.log()`
550
+
### `frameRate()`, `frameCount` and `console.log()`
551
551
552
552
The number of times [`draw()`](/reference/p5/draw) runs is stored in the variable [`frameCount`](/reference/p5/frameCount), and the number of times [`draw()`](/reference/p5/draw) runs in 1 second is known as the *frame rate*. By default, the frame rate is set by your computer, which is about 60 for most computers. This indicates that the code appearing in [`draw()`](/reference/p5/draw) will run about 60 times in a second.
553
553
@@ -897,7 +897,7 @@ When [`draw()`](/reference/p5/draw) runs:
897
897
When [`draw()`](/reference/p5/draw) runs again, the same process occurs, and the shooting star is placed at a new random location within the top half of the canvas. This continues until [`draw()`](/reference/p5/draw) is stopped.
898
898
899
899
900
-
#####Error Messages
900
+
### Error Messages
901
901
902
902
p5.js uses the console to communicate with programmers about lines of code that it does not understand. These are called [error messages.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors) Programmers use this to locate and fix “*bugs*” in their code. Read the [Field Guide to Debugging](/tutorials/field-guide-to-debugging) or watch [this video](https://www.youtube.com/watch?v=LuGsp5KeJMM\&list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA\&index=6) to learn more!
0 commit comments