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-2
Original file line number
Diff line number
Diff line change
@@ -86,7 +86,7 @@ This tutorial uses the [p5.js Web Editor](https://editor.p5js.org/) and is desig
86
86
snapButton.mouseClicked(takeSnap);
87
87
```
88
88
89
-
Visit the p5.js reference pages for [`createButton()`](/reference/p5/createbutton) and [`mouseClicked()`](/reference/p5/mouseClicked) to learn more.
89
+
Visit the p5.js reference pages for [`createButton()`](/reference/p5/createButton) and [`mouseClicked()`](/reference/p5/mouseClicked) to learn more.
90
90
91
91
By creating an HTML button, we are inserting `<button></button>` inside our sketch page's HTML and are using it to trigger the code for taking a snapshot of our webcam feed.
92
92
@@ -395,4 +395,3 @@ Continue on to the next lesson: [Custom Shapes and Smooth Curves](/tutorials/cus
Copy file name to clipboardExpand all lines: src/content/tutorials/en/conditionals-and-interactivity.mdx
+2-2
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ Controlling the flow of your program is central to the power of computing and ma
41
41
42
42
-[Setting Up Your Environment](/tutorials/setting-up-your-environment)
43
43
-[Get Started Tutorial](/tutorials/get-started)
44
-
-[Variables and Motion Tutorial](/tutorials/variables-and-motion)
44
+
-[Variables and Change Tutorial](/tutorials/variables-and-change/)
45
45
46
46
Before you begin, you should be able to:
47
47
@@ -842,7 +842,7 @@ Notice that if the Boolean expression in the first if statement is `false`, the
842
842
843
843
### Logical Operators: `&&` and `||`
844
844
845
-
Another way to write conditional statements with more than one condition is by using [logical operators](https://p5js.org/examples/control-logical-operators.html). The AND operator (`&&`) is used when *both* conditions must be `true` for a code block to run. The OR operator (`||`) is used when *either* condition must be true for a code block to run.
845
+
Another way to write conditional statements with more than one condition is by using logical operators. The AND operator (`&&`) is used when *both* conditions must be `true` for a code block to run. The OR operator (`||`) is used when *either* condition must be true for a code block to run.
846
846
847
847
We can rewrite the nested conditional in the animated sunrise sketch using the AND (`&&`) logical operator since it requires that `sunHeight` is less than 130 *AND* greater than 480. In the code sample below, Boolean expressions on each side of the operator must be `true` in order for the code in its code block to run:
Copy file name to clipboardExpand all lines: src/content/tutorials/en/custom-geometry.mdx
+1-1
Original file line number
Diff line number
Diff line change
@@ -53,7 +53,7 @@ function draw(){
53
53
54
54
A common issue that can come up with custom models is scaling. Depending on how the model is constructed, it might be a very different size when drawn in p5.js, or be too small to be drawn at all. The `loadModel()` method includes a `normalize` parameter that will resize the model to something that works better in p5.js.
55
55
56
-
*Note that there is currently no support for loading materials and colors from model files. You can add color, materials, and textures manually after loading a model, which you can learn about in the*[*Styling and Appearance*](styling-and-appearance)*tutorial.*
56
+
*Note that there is currently no support for loading materials and colors from model files. You can add color, materials, and textures manually after loading a model.*
Copy file name to clipboardExpand all lines: src/content/tutorials/en/data-structure-garden.mdx
+2-2
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,7 @@ Before you begin, you should be able to:
46
46
- Create and use custom functions
47
47
- Understand how to use for loops to manage repetitive tasks
48
48
49
-
For more information on arrays, loops, and custom functions, visit the [Organizing Code with Functions](/tutorials-organizing-code-with-functions) and [Repeating with Loops](/tutorials/repeating-with-loops) tutorials.
49
+
For more information on arrays, loops, and custom functions, visit the [Organizing Code with Functions](/tutorials/organizing-code-with-functions) and [Repeating with Loops](/tutorials/repeating-with-loops) tutorials.
50
50
51
51
- In the [Variables and Change](/tutorials/variables-and-change) tutorial, you learned how to store data using variables. Variables are useful for storing single values like numbers or text.
52
52
- In the [Animating with Media Objects](/tutorials/animating-with-media-objects) tutorial, you learned to use p5.js’ built-in `p5.Image` and `p5.Graphics` objects. These objects bundle data, like images, together with special functions called [*methods*](https://www.w3schools.com/js/js_object_methods.asp#:~:text=JavaScript%20methods%20are%20actions%20that,property%20containing%20a%20function%20definition.) that enable users to perform operations on that data.
@@ -988,7 +988,7 @@ Throughout this journey, you learned about the fundamental concepts of JavaScrip
988
988
989
989
- Use HTML & CSS with p5.js in the [Creating and Styling HTML](/tutorials/creating-styling-html) tutorial.
990
990
- Use [ml5.js](https://ml5js.org/) with p5.js in the [Abracadabra: Speak With Your Hands](/tutorials/speak-with-your-hands) tutorial.
991
-
- Use [node.js](https://www.w3schools.com/nodejs/nodejs_intro.asp) with p5.js in the [Getting Started with Node.js](/tutorials/getting-started-with-nodejs) and [Melody App](/tutorials/melody-app) tutorials.
991
+
- Use [node.js](https://www.w3schools.com/nodejs/nodejs_intro.asp) with p5.js in the [Getting Started with Node.js](/tutorials/getting-started-with-nodejs) and [Simple Melody App](/tutorials/simple-melody-app/) tutorials.
992
992
993
993
Once again, well done on completing this tutorial. Keep experimenting, keep coding, and most importantly, enjoy learning and creating!
Copy file name to clipboardExpand all lines: src/content/tutorials/en/get-started.mdx
+5-5
Original file line number
Diff line number
Diff line change
@@ -262,7 +262,7 @@ The [`fill()`](/reference/p5/fill) function sets the color for any shape on the
262
262
263
263
264
264
<Callouttitle="Tip">
265
-
In the [p5.js Web Editor](https://editor.p5js.org/), you can search for different colors to use in [`fill()`](/reference/p5/fill), [`stroke()`](/reference/p5/stroke), and [`background()`](/reference/p5/background) by clicking on the small colored box next to the color’s name! Type an [HTML color name](https://www.w3schools.com/tags/ref_colornames.asp) as an *argument*, and the box will appear. Color names are [string](/reference/p5/string) data types and are therefore surrounded by quotation marks (`""`).
265
+
In the [p5.js Web Editor](https://editor.p5js.org/), you can search for different colors to use in [`fill()`](/reference/p5/fill), [`stroke()`](/reference/p5/stroke), and [`background()`](/reference/p5/background) by clicking on the small colored box next to the color’s name! Type an [HTML color name](https://www.w3schools.com/tags/ref_colornames.asp) as an *argument*, and the box will appear. Color names are [string](/reference/p5/String) data types and are therefore surrounded by quotation marks (`""`).
266
266
267
267

268
268
</Callout>
@@ -419,17 +419,17 @@ Visit the reference pages for [`text()`](/reference/p5/text),` `[`textSize()`](/
419
419
420
420
Some functions in p5.js need *arguments* that are *string* data types, while other functions need arguments that are *number* data types.
421
421
422
-
-[Strings](/reference/p5/string): represented by text and always surrounded by quotation marks (`""`)
422
+
-[Strings](/reference/p5/String): represented by text and always surrounded by quotation marks (`""`)
423
423
-[Numbers](/reference/p5/number): represented by a number
424
424
425
425
For example:
426
426
427
427
-[`circle()`](/reference/p5/circle) uses 3 [numbers](/reference/p5/number): a number that represents its x-coordinate, a number that represents its y-coordinate, and a number that represents its size in pixels.
428
-
-[`text()`](/reference/p5/text) uses a [string](/reference/p5/string) that represents the text displayed, and 2 [numbers](/reference/p5/number): a number that represents its x-coordinate and a number that represents its y-coordinate.
429
-
-[`fill()`](/reference/p5/fill), [`stroke()`](/reference/p5/stroke), and [`background()`](/reference/p5/background) use both [numbers](/reference/p5/number) and [strings](/reference/p5/string):
428
+
-[`text()`](/reference/p5/text) uses a [string](/reference/p5/String) that represents the text displayed, and 2 [numbers](/reference/p5/number): a number that represents its x-coordinate and a number that represents its y-coordinate.
429
+
-[`fill()`](/reference/p5/fill), [`stroke()`](/reference/p5/stroke), and [`background()`](/reference/p5/background) use both [numbers](/reference/p5/number) and [strings](/reference/p5/String):
430
430
- 1 number for gray-scale color
431
431
- 3 numbers separated by commas for [RGB colors](https://www.w3schools.com/html/html_colors_rgb.asp)
432
-
- a [string](/reference/p5/string) with an [HTML color name](https://www.w3schools.com/tags/ref_colornames.asp) or [HEX color values](https://www.w3schools.com/html/html_colors_hex.asp)
432
+
- a [string](/reference/p5/String) with an [HTML color name](https://www.w3schools.com/tags/ref_colornames.asp) or [HEX color values](https://www.w3schools.com/html/html_colors_hex.asp)
Copy file name to clipboardExpand all lines: src/content/tutorials/en/getting-started-with-nodejs.mdx
+2-2
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ authors:
15
15
- Nick McIntyre
16
16
---
17
17
18
-
In this guide, we'll explore the fusion of p5.js and [Node.js](http://node.js) to create dynamic applications that save and retrieve user-generated drawings, animations, and sound projects! For example, you can create a [Melody App](/tutorials/melody-app-with-nodejs) where you save files with melodies you create by interacting with the canvas! Node.js allows you to easily save, replay, and edit these files right from your browser!
18
+
In this guide, we'll explore the fusion of p5.js and [Node.js](http://node.js) to create dynamic applications that save and retrieve user-generated drawings, animations, and sound projects! For example, you can create a [Simple Melody App](/tutorials/simple-melody-app/) where you save files with melodies you create by interacting with the canvas! Node.js allows you to easily save, replay, and edit these files right from your browser!
19
19
20
20
21
21

@@ -231,7 +231,7 @@ Now you are ready to build the [Melody App](https://docs.google.com/document/u/0
231
231
232
232
## Next Steps
233
233
234
-
- Read about the [`p5.Oscillator`](/reference/p5.Oscillator) library and play with [this example](https://editor.p5js.org/Msqcoding/sketches/wSFTn9G9E).
234
+
- Read about the [`p5.Oscillator`](/reference/p5.sound/p5.Oscillator/) library and play with [this example](https://editor.p5js.org/Msqcoding/sketches/wSFTn9G9E).
235
235
- Learn how to use [`app.post()`](https://expressjs.com/en/5x/api.html#app.post.method) and [`fs.writeFile()`](https://nodejs.org/en/learn/manipulating-files/writing-files-with-nodejs) to save files users create using your p5.js app by visiting the reference links.
Copy file name to clipboardExpand all lines: src/content/tutorials/en/how-to-optimize-your-sketches.mdx
+2-2
Original file line number
Diff line number
Diff line change
@@ -164,7 +164,7 @@ The sketch runs smoothly with fewer particles, so that change seems to solve the
164
164
165
165
Similarly, I wondered if I needed to simulate the actual laws of physics. In this case, that was important to the project, but for a game, a simplified version of the physics could still work well and greatly improve performance.
166
166
167
-
I could also try to use memory more effectively by modifying the original [`p5.Vector`](/reference/p5.Vector) objects and avoiding calls to `p5.Vector.copy()`. This kind of change requires care. When you update an object that is used elsewhere in your code, you might cause an inadvertent bug.
167
+
I could also try to use memory more effectively by modifying the original [`p5.Vector`](/reference/p5/p5.Vector) objects and avoiding calls to `p5.Vector.copy()`. This kind of change requires care. When you update an object that is used elsewhere in your code, you might cause an inadvertent bug.
168
168
169
169
A great strategy is to make a change and see how it improves performance using `frameRate()` as a benchmarking tool. If the frame rate drops, you know you have a problem. This also allows you to ensure you have not inadvertently introduced a new bug into the code.
170
170
@@ -199,7 +199,7 @@ In my case, I just let the animation run after I clicked record. The profiler ca
199
199
200
200

201
201
202
-
It looks like I was right about the `collisions()` function, which takes 93.4% of the time. It seems like most of that is taken up by using [`p5.Vector`](/reference/p5.Vector) and its `.copy()` method in that loop. Of course, you will need to have nicely named functions for this tool to be helpful. See the [performance features reference](https://developer.chrome.com/docs/devtools/performance/reference/#:~:text=%23%20The%20Bottom%2DUp%20tab,learn%20how%20to%20select%20portions.) page for complete documentation.
202
+
It looks like I was right about the `collisions()` function, which takes 93.4% of the time. It seems like most of that is taken up by using [`p5.Vector`](/reference/p5/p5.Vector) and its `.copy()` method in that loop. Of course, you will need to have nicely named functions for this tool to be helpful. See the [performance features reference](https://developer.chrome.com/docs/devtools/performance/reference/#:~:text=%23%20The%20Bottom%2DUp%20tab,learn%20how%20to%20select%20portions.) page for complete documentation.
203
203
204
204
Once you are satisfied with your level of knowledge of the different choices available to you, it is time to decide how to improve your code.
Copy file name to clipboardExpand all lines: src/content/tutorials/en/layered-rendering-with-framebuffers.mdx
+3-4
Original file line number
Diff line number
Diff line change
@@ -80,7 +80,7 @@ Final image with focal blur using color + depth
80
80
81
81
A `p5.Framebuffer` is a surface you can draw to, similar to the main canvas. Drawing to the main canvas is like drawing on a sheet of paper. When you call `begin()` on a `p5.Framebuffer`, it's like laying a fresh sheet of paper on top of the original, which will collect any new things that get drawn. Calling `end()` on a `p5.Framebuffer` will remove that sheet again so that subsequent drawing will go right to the main canvas again.
82
82
83
-
You can create a `p5.Framebuffer` with the `createFramebuffer()` function. You can optionally pass an object in as a parameter to specify a width and height.By default, `p5.Framebuffer`s are the same size as the main canvas. There are other options you can add to this object to control how color and depth information is stored, which we'll get into later. Check out [the `createFramebuffer()` documentation](/reference/en/p5/createFramebuffer) for the full reference.
83
+
You can create a `p5.Framebuffer` with the `createFramebuffer()` function. You can optionally pass an object in as a parameter to specify a width and height.By default, `p5.Framebuffer`s are the same size as the main canvas. There are other options you can add to this object to control how color and depth information is stored, which we'll get into later. Check out [the `createFramebuffer()` documentation](/reference/p5/createFramebuffer/) for the full reference.
84
84
85
85
You may already be familiar with drawing to `p5.Graphics` objects. Here's a comparison of some code using `p5.Graphics` as a texture, and what the equivalent `p5.Framebuffer` code looks like:
86
86
@@ -544,16 +544,15 @@ function draw() {
544
544
545
545
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).
546
546
547
-
*Depth-based blur shaders are more advanced and are beyond the scope of this tutorial. If you are interested in how they work, you can look at*[*an example of Framebuffer depth blur*](https://p5js.org/examples/3d-blur-using-framebuffer-depth.html)*.*
548
-
547
+
*Depth-based blur shaders are more advanced and are beyond the scope of this tutorial.*
549
548
550
549
<Callout>
551
550
Can you make a moody, rainy scene using a fog shader to add to the atmosphere?
552
551
</Callout>
553
552
554
553
## Conclusion
555
554
556
-
If you're sketching in WebGL mode and need to draw to an image, consider using [`createFramebuffer()`](/reference/en/p5/createFramebuffer) as a way to make your sketch run fast and give everyone the best viewing experience possible.
555
+
If you're sketching in WebGL mode and need to draw to an image, consider using [`createFramebuffer()`](/reference/p5/createFramebuffer) as a way to make your sketch run fast and give everyone the best viewing experience possible.
557
556
558
557
We hope the new techniques framebuffers make possible inspire you and that you create art using them!
0 commit comments