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/color-gradients.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,7 +58,7 @@ This tutorial uses the [p5.js Web Editor](https://editor.p5js.org/) and is desig
58
58
- See this [example sketch](https://editor.p5js.org/Msqcoding/sketches/mLfhMChZW) that sets up your webcam to display on the canvas.
59
59
- Visit the p5.reference pages for [`.position()`](/reference/p5.Element/position) and [`p5.Element`](/reference/p5/p5.Element) to learn more.
60
60
- Create a function to take a snapshot with your webcam.
61
-
- Declare a global [Boolean](/reference/p5/boolean) variable called `snapped` and assign it a value of `false`.
61
+
- Declare a global [Boolean](/reference/p5/Boolean) variable called `snapped` and assign it a value of `false`.
62
62
- This variable will keep track of when a snapshot is taken and is known as a [state](https://developer.mozilla.org/en-US/docs/Glossary/State_machine) variable.
63
63
- Visit the MDN glossary for [state machine](https://developer.mozilla.org/en-US/docs/Glossary/State_machine) for more information about states.
64
64
- Define a function called `takeSnap()` below your `setup()` function.
Copy file name to clipboardExpand all lines: src/content/tutorials/en/conditionals-and-interactivity.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -471,7 +471,7 @@ if (sunHeight < horizon) {
471
471
472
472
In the code above, we see that if the sun is above the horizon, `sunHeight < horizon `returns `true`, and the code `background("lightblue")` runs. When `sunHeight` is NOT less than the horizon the code block after the `else` keyword, `background(0)`, runs. Although both ways of writing the code have the same visual effect, sometimes it can be clearer and more efficient to use if-else, especially when two different code blocks can be controlled.
473
473
474
-
Visit the p5.js reference page for [`if`](/reference/p5/if-else) and [`Boolean`](/reference/p5/boolean) to learn more.
474
+
Visit the p5.js reference page for [`if`](/reference/p5/if) and [`Boolean`](/reference/p5/Boolean) to learn more.
Copy file name to clipboardExpand all lines: src/content/tutorials/en/coordinates-and-transformations.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,7 +49,7 @@ function draw() {
49
49
50
50

51
51
52
-
You can call [`debugMode()`](https://p5js.org/reference/#/p5/debugMode) in your `setup()` function to add a grid on the x- and z-axes and the red-green-blue x, y, and z arrows to your sketch, similar to the illustration above.
52
+
You can call [`debugMode()`](https://p5js.org/reference/p5/debugMode) in your `setup()` function to add a grid on the x- and z-axes and the red-green-blue x, y, and z arrows to your sketch, similar to the illustration above.
53
53
54
54
55
55
## Transformations: Position and Size of 3D Shapes
Copy file name to clipboardExpand all lines: src/content/tutorials/en/field-guide-to-debugging.mdx
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -244,7 +244,7 @@ function draw() {
244
244
<Column>
245
245
#### Solution:
246
246
247
-
The programmer solved the problem by adding a parenthesis between the last argument and a semicolon. They discovered this by visiting the p5.js reference page for [`rect()`](https://p5js.org/reference/#/p5/rect) and comparing code.
247
+
The programmer solved the problem by adding a parenthesis between the last argument and a semicolon. They discovered this by visiting the p5.js reference page for [`rect()`](https://p5js.org/reference/p5/rect) and comparing code.
248
248
249
249
#### Pro Tips:
250
250
@@ -283,7 +283,7 @@ p5.js says: [sketch.js, line 9] circle() was expecting at least 3 arguments but
283
283
284
284
#### Bug:
285
285
286
-
According to the message in the console, [`circle()`](https://p5js.org/reference/#/p5/circle) only received 2 inputs when it expected 3. The message also specifies that the error is on line 9 of the sketch.
286
+
According to the message in the console, [`circle()`](https://p5js.org/reference/p5/circle) only received 2 inputs when it expected 3. The message also specifies that the error is on line 9 of the sketch.
287
287
288
288
</Column>
289
289
<Column>
@@ -306,9 +306,9 @@ function draw() {
306
306
<Column>
307
307
#### Solution:
308
308
309
-
The programmer solved the problem by adding a third argument in [`circle()`](https://p5js.org/reference/#/p5/circle).
309
+
The programmer solved the problem by adding a third argument in [`circle()`](https://p5js.org/reference/p5/circle).
310
310
311
-
They discovered this by visiting the p5.js reference page for [`circle()`](https://p5js.org/reference/#/p5/circle) and comparing code.
311
+
They discovered this by visiting the p5.js reference page for [`circle()`](https://p5js.org/reference/p5/circle) and comparing code.
312
312
313
313
#### Pro Tips:
314
314
@@ -376,9 +376,9 @@ function draw() {
376
376
<Column>
377
377
#### Solution:
378
378
379
-
The programmer solved the problem by adding a *closing curly bracket* (`}`) on line 11 to close the [`draw()`](https://p5js.org/reference/#/p5/draw) function.
379
+
The programmer solved the problem by adding a *closing curly bracket* (`}`) on line 11 to close the [`draw()`](https://p5js.org/reference/p5/draw) function.
380
380
381
-
They discovered this by visiting the p5.js reference page for [`draw()`](https://p5js.org/reference/#/p5/draw) and comparing code.
381
+
They discovered this by visiting the p5.js reference page for [`draw()`](https://p5js.org/reference/p5/draw) and comparing code.
382
382
383
383
#### Pro Tips:
384
384
@@ -489,7 +489,7 @@ p5.js says: [sketch.js, line 10] circle() was expecting Number for the first par
489
489
490
490
#### Bug:
491
491
492
-
According to the message in the console, the programmer made an error on line 10 - the [circle()](https://p5js.org/reference/#/p5/circle) function needs a [number](https://p5js.org/reference/#/p5/number) as the first parameter, but it was given a [string](https://p5js.org/reference/#/p5/string).
492
+
According to the message in the console, the programmer made an error on line 10 - the [circle()](https://p5js.org/reference/p5/circle) function needs a [number](https://p5js.org/reference/p5/number) as the first parameter, but it was given a [string](https://p5js.org/reference/p5/string).
493
493
494
494
</Column>
495
495
<Column>
@@ -516,7 +516,7 @@ function draw() {
516
516
517
517
#### Solution:
518
518
519
-
The programmer solved the problem by noticing that the variable `myX` was initialized with `"forty-five"`, which cannot be recognized as a [number](https://p5js.org/reference/#/p5/number). p5.js thinks it’s just a word with a [string](https://p5js.org/reference/#/p5/string) data type.
519
+
The programmer solved the problem by noticing that the variable `myX` was initialized with `"forty-five"`, which cannot be recognized as a [number](https://p5js.org/reference/p5/number). p5.js thinks it’s just a word with a [string](https://p5js.org/reference/p5/string) data type.
520
520
521
521
#### Pro Tip:
522
522
@@ -589,7 +589,7 @@ function draw() {
589
589
590
590
#### Solution:
591
591
592
-
The programmer solved the problem by declaring `localVariable` outside of [`setup()`](https://p5js.org/reference/#/p5/setup) and [`draw()`](https://p5js.org/reference/#/p5/draw) and initializing it in [`setup()`](https://p5js.org/reference/#/p5/setup).
592
+
The programmer solved the problem by declaring `localVariable` outside of [`setup()`](https://p5js.org/reference/p5/setup) and [`draw()`](https://p5js.org/reference/p5/draw) and initializing it in [`setup()`](https://p5js.org/reference/p5/setup).
Copy file name to clipboardExpand all lines: src/content/tutorials/en/intro-to-shaders.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,7 +95,7 @@ A shader program consists of two parts, a **vertex shader** and a **fragment sha
95
95
96
96
</table>
97
97
98
-
{/* Note for contributors: Images/gifs generated from https://editor.p5js.org/davepagurek/sketches/gs-DbLzqV */}
98
+
{/* Note for contributors: Images/gifs generated from https://editor.p5js.org/davepagurek/sketches/gs-DbLzqV */}
99
99
100
100
Each of these live in separate files and are loaded into p5.js using the `loadShader()` function. Once a shader is loaded, it can be used within `setup()` or `draw()`. The following example will show how to set up a basic shader within p5.js:
101
101
@@ -671,7 +671,7 @@ In p5.js, a filter is something that looks at all the pixels on the canvas and t
671
671
672
672
Filter shaders only need a fragment shader. Vertex shaders are primarily responsible for positioning shapes, and filters always apply to the whole canvas, so p5.js provides a default vertex shader for you. Rather than using `loadShader`, you use `createFilterShader(src)`, passing in a string with your shader source code.
673
673
674
-
There are a number of `uniform`s that will be available to you in a filter shader, and you can read about all of them [in the `createFilterShader` documentation.](https://p5js.org/reference/#/p5/createFilterShader) There are two main ones to know about to get started:
674
+
There are a number of `uniform`s that will be available to you in a filter shader, and you can read about all of them [in the `createFilterShader` documentation.](https://p5js.org/reference/p5/createFilterShader) There are two main ones to know about to get started:
675
675
676
676
-`uniform sampler2D tex0` is a texture containing the contents of the canvas.
677
677
-`varying vec2 vTexCoord` contains the coordinates on the canvas of the current pixel, ranging from 0 to 1.
Copy file name to clipboardExpand all lines: src/content/tutorials/en/layered-rendering-with-framebuffers.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,7 +73,7 @@ Final image with focal blur using color + depth
73
73
74
74
</table>
75
75
76
-
{/*Note for contributors: Image generated from https://editor.p5js.org/davepagurek/sketches/OUBu-yXuk*/}
76
+
{/*Note for contributors: Image generated from https://editor.p5js.org/davepagurek/sketches/OUBu-yXuk*/}
77
77
78
78
## Using a `p5.Framebuffer`
79
79
@@ -366,7 +366,7 @@ function draw() {
366
366
`} />
367
367
368
368
<Callout>
369
-
Lots of music player software uses feedback to create audio visualizations. Try using feedback in a sketch that [reacts to music!](https://p5js.org/reference/#/p5.Amplitude)
369
+
Lots of music player software uses feedback to create audio visualizations. Try using feedback in a sketch that [reacts to music!](https://p5js.org/reference/p5.sound/p5.Amplitude)
370
370
</Callout>
371
371
372
372
Here are some tips that will help as you create more advanced feedback effects.
@@ -541,7 +541,7 @@ function draw() {
541
541
}
542
542
`} />
543
543
544
-
If you want to customize how close to or far from the camera an object needs to be to get depth values of 0 or 1, specify near and far values in [`perspective()`](https://p5js.org/reference/#/p5/perspective).
544
+
If you want to customize how close to or far from the camera an object needs to be to get depth values of 0 or 1, specify near and far values in [`perspective()`](https://p5js.org/reference/p5/perspective).
545
545
546
546
*Depth-based blur shaders are more advanced and are beyond the scope of this tutorial.*
Copy file name to clipboardExpand all lines: src/content/tutorials/en/repeating-with-loops.mdx
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,8 +36,8 @@ In this tutorial, you will:
36
36
37
37
- Draw and update repetitive tasks and shapes using *for loops*
38
38
- Use custom functions to update variables and program states and make changes in the program as the sketch runs.
39
-
- Use [conditional statements](/reference/p5/if-else) and `random()` to generate different outcomes
40
-
- Run and stop your sketch using mouse triggers and [Boolean variables](/reference/p5/boolean)
39
+
- Use [conditional statements](/reference/p5/if) and `random()` to generate different outcomes
40
+
- Run and stop your sketch using mouse triggers and [Boolean variables](/reference/p5/Boolean)
41
41
- Store the positions of the caterpillars in an array
42
42
43
43
### What you’ll need
@@ -162,7 +162,7 @@ function draw() {
162
162
}
163
163
`} />
164
164
165
-
### [If-statements](/reference/p5/if-else)
165
+
### [If-statements](/reference/p5/if)
166
166
167
167
If-statements, like the one applied above, refer to blocks of code that are executed only when a given condition is true. It is normally written:
168
168
@@ -174,7 +174,7 @@ if (<condition>) {
174
174
175
175
The condition is specified inside the parentheses of the if-statement. The curly brackets `{ }` mark the start and end of the block of code. In Step 2, the condition `circX > finishLine` stops `draw()` from running again when the x-coordinate of the circle is greater than the value of `finishLine` by calling `noLoop()`.
176
176
177
-
Visit the p5.js reference for [if](/reference/p5/if-else) to learn more.
177
+
Visit the p5.js reference for [if](/reference/p5/if) to learn more.
Copy file name to clipboardExpand all lines: src/content/tutorials/en/responding-to-inputs.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -381,7 +381,7 @@ function checkSelf() {
381
381
- It sets the initial direction to the right with `snake.xSpeed = 1` and `snake.ySpeed = 0`,
382
382
- It creates an empty array to manage the snake’s body, creates a head segment with the current position, and adds it to the body array.
383
383
384
-
The `checkEdges()` function uses [if-statements](/reference/p5/if-else) to check if the snake has reached the right edge (`cols`), if the snake has reached the left edge (`-1`), if the snake has reached the top edge (`-1`), and if the snake has reached the bottom edge (`rows`). Whenever any of the conditions are met, it sets `gameOver` to `true`. This creates the rule in the game where if the snake reaches any edge, the game is over. The `moveSnake()` function updates the snake’s position based on its current speed. It updates the x and y positions by adding its `xSpeed` and `ySpeed`, respectively. Refer to the [Conditions and Interactivity](/tutorials/conditionals-and-interactivity/) tutorial to review the syntax for if-statements and updating variables.
384
+
The `checkEdges()` function uses [if-statements](/reference/p5/if) to check if the snake has reached the right edge (`cols`), if the snake has reached the left edge (`-1`), if the snake has reached the top edge (`-1`), and if the snake has reached the bottom edge (`rows`). Whenever any of the conditions are met, it sets `gameOver` to `true`. This creates the rule in the game where if the snake reaches any edge, the game is over. The `moveSnake()` function updates the snake’s position based on its current speed. It updates the x and y positions by adding its `xSpeed` and `ySpeed`, respectively. Refer to the [Conditions and Interactivity](/tutorials/conditionals-and-interactivity/) tutorial to review the syntax for if-statements and updating variables.
385
385
386
386
- The `updateBody()` function updates the positions of the snake’s body segments. It does this by iterating through the snake `body` array starting from the end, updating each body segment’s position to match the position of the segment in front of it. Then it updates the head’s position to the snake’s current position. Refer to the [Repeating with Loops](/tutorials/repeating-with-loops) tutorial to review the syntax for loops and iteration.
387
387
- The `drawSnake()` function renders the snake on the canvas. It sets the color to green, iterates through each body segment, and draws a square on the canvas at its position.
0 commit comments