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: _curriculum/01-01_Lessons.md
+7-9Lines changed: 7 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,15 +7,13 @@ published: true
7
7
gallery: # Below is for including an image gallery
8
8
---
9
9
10
-
# Getting Started
11
-
12
-
## 1. Setting Up Your Environment
10
+
## Setting Up Your Environment
13
11
14
12
To begin writing code using [p5.js](https://p5js.org/), you need to set up the coding environment to write and save your programs. [Processing Foundation](https://processingfoundation.org/) provides the [p5.js Editor](https://editor.p5js.org/), a website where programmers can write, test, share, and remix p5.js programs without needing to download or install a code editor on a computer.
15
13
16
14
<iframewidth="560"height="315"src="https://www.youtube.com/embed/MXs1cOlidWs?si=h8uilatDVzeLCl_a"title="YouTube video player"frameborder="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"referrerpolicy="strict-origin-when-cross-origin"allowfullscreen></iframe>
17
15
18
-
### What you will need
16
+
####What you will need
19
17
20
18
- Access to the internet and the latest version of a desktop browser such as:
21
19
- Chrome (recommended)
@@ -24,14 +22,14 @@ To begin writing code using [p5.js](https://p5js.org/), you need to set up the c
24
22
- Edge
25
23
- A desktop computer, laptop, or Chromebook
26
24
27
-
###1A. Opening the p5.js Editor
25
+
#### A. Opening the p5.js Editor
28
26
29
27
1. Open the latest version of Chrome or Firefox browser on your computer and visit the [p5.js Editor](https://editor.p5js.org/) website.
30
28
1. Click the “Sign up” link on the top right of the web page.
@@ -67,15 +65,15 @@ Create an account on the [p5.js Editor](https://editor.p5js.org/) using one of t
67
65

68
66

69
67
70
-
###1D. Renaming, saving, and sharing sketches
68
+
#### D. Renaming, saving, and sharing sketches
71
69
72
70
1. By default, the [p5.js Editor](https://editor.p5js.org/) will generate a playful name for your first sketch. You can rename your sketch by clicking on the pencil icon above the text editor and typing in a name for your project. 
73
71
1. Save projects by clicking on File in the top toolbar and selecting Save. Alternatively, you can use the shortcut keys Control+S (PC) or Command+S (Mac).  
74
72
75
73
**Tip:** Make sure you are logged in to your account, or you will not be able to save the sketch. Saving projects frequently helps ensure that code isn’t lost if something happens to your computer, browser, or internet connection while you're coding.
76
74
{: .notice--success}
77
75
78
-
###1E. Sharing, downloading, and deleting your sketches
76
+
#### E. Sharing, downloading, and deleting your sketches
79
77
80
78
1. Once your project is saved, you can share it! Click on File in the navigation menu, select Share, and copy one of the links provided to share your project in Embed, Fullscreen, and Edit modes.
81
79
1. If you share your project link with a teacher or classmate, you are giving them the permission to view all of your sketches stored on the [p5.js Editor](https://editor.p5js.org/). This is because all sketches stored in the [p5.js Editor](https://editor.p5js.org/) are publicly viewable. Additionally, it’s also possible for your sketches to show up in search engine results.
Copy file name to clipboardExpand all lines: _curriculum/02-01_Lessons.md
+6-138Lines changed: 6 additions & 138 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
# This is the frontmatter
3
3
title: "Lost and Found"# Title and Heading 1
4
-
permalink: /lostAndFound-lessons/ # Give your page a permalink
4
+
permalink: /lostAndFound-lessons/1# Give your page a permalink
5
5
published: true
6
6
7
7
gallery: # Below is for including an image gallery
@@ -22,12 +22,11 @@ gallery: # Below is for including an image gallery
22
22
alt: "cursor creating a drawing of vertical blue lines and stamping red ellipses"
23
23
title: "Digital Drawing Tool Step 4"
24
24
---
25
-
# Lesson Plans & Technical Steps
26
25
27
-
## 1. Shape
26
+
## Shape
28
27
<iframewidth="560"height="315"src="https://www.youtube.com/embed/hISICBkFa4Q?si=U-LWuegXM9xtLfXg"title="YouTube video player"frameborder="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"referrerpolicy="strict-origin-when-cross-origin"allowfullscreen></iframe>
29
28
30
-
#### 1A. p5.js canvas coordinates
29
+
#### A. p5.js canvas coordinates
31
30
By default, every new p5.js sketch you create on the p5.js Editor will contain the following code:
32
31
33
32
```jsx
@@ -62,7 +61,7 @@ function setup(){
62
61
Additionally, it’s not possible to animate canvas size while a sketch is playing.
63
62
{: .notice--success}
64
63
65
-
#### 1B. p5.js coordinate system
64
+
#### B. p5.js coordinate system
66
65
We’re on our way to placing shapes on the canvas. Do you recall the Cartesian coordinate system taught in math classes? Don’t worry, we believe this to be much simpler! The p5.js canvas features an invisible coordinate system that originates from an X position of 0 and a Y location of 0 in the top-left corner.
@@ -72,7 +71,7 @@ As a shape on the canvas moves to the right of this point, its [X-coordinate val
72
71
**Code Snippet:** Explore the p5.js coordinate system with this [pixel ruler tool](https://editor.p5js.org/xinemata/sketches/gjWtrowcK) created by Alp Tugǎn, a p5.js Contributor.
73
72
{: .notice--info}
74
73
75
-
#### 1C. Drawing simple shapes
74
+
#### C. Drawing simple shapes
76
75
Now that we’ve covered the basics of the coordinate system, let’s draw a rectangle on the canvas by using the [rect()](https://p5js.org/reference/p5/rect/) feature!
The ellipse should now be sitting on top of your rectangle. What this tells us is that the order in which you code your shapes matters. [p5.js](https://p5js.org) is built on JavaScript, and JavaScript renders code on the fly from top to bottom. Coding the rectangle first means that the rectangle is drawn first, and then it gets covered by the ellipse, which comes later.
196
-
197
-
### 2. Color
198
-
<iframewidth="560"height="315"src="https://www.youtube.com/embed/fTEvHLLwSBE?si=O-3UMF0ZjaUhQb6M"title="YouTube video player"frameborder="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"referrerpolicy="strict-origin-when-cross-origin"allowfullscreen></iframe>
199
-
200
-
#### Grade 6~8
201
-
##### 2A. Story Behind the Screen
202
-
Look at the screen in front of you right now. Every color you see—bright pinks, glowing greens, stormy blues—is made from just three colors of light: red, green, and blue—also known as RGB.
203
-
204
-
You can’t always see it, but it’s true. If you looked at your phone or computer screen under a microscope (cool science class moment!), you’d see tiny red, green, and blue lights—called pixels—turning on and off in different combinations. That’s how screens make color: by mixing light.
This kind of color mixing is called additive color. It’s different from mixing paint, where adding more makes things darker. With light, adding more actually make things brighter.
In this topic, we'll learn to cast some color spells together using code. You’ll learn how to control the RGB colors in p5.js, a creative coding environment made for artists, designers, and anyone curious about how code can be expressive.
214
-
215
-
##### 2B. Meet RGB
216
-
217
-
Let’s start by updating the [background()](https://p5js.org/reference/p5/background/) in the [p5.js editor](https://editor.p5js.org/):
218
-
219
-
```js
220
-
functionsetup() {
221
-
createCanvas(400, 400);
222
-
}
223
-
224
-
functiondraw() {
225
-
background(255, 0, 0); // r, g, b
226
-
}
227
-
```
228
-
229
-
If you click the Play button, the background of the canvas should be filled in bright red. Let's break this down to better understand what's going on:
230
-
231
-
- RGB ranges from a minimum value of 0, to a maximum value of 255. These numbers control the brightness levels of the red, green, and blue lights.
232
-
- In this case, the sketch is coloring the background in the brightest possible red in RGB. `background(255, 0, 0);` means: full red light, no green light, and no blue light.
233
-
234
-
**Mini-Challenge:** Can you update background() to fill the canvas with the brightest blue possible?
235
-
{: .notice--warning}
236
-
237
-
**Tip**: In the RGB world, `background(255, 255, 0);` creates yellow, `background(255, 0, 255);` creates magenta, and `background(0, 255, 255);` creates cyan.
238
-
{: .notice--success}
239
-
240
-
Play around! What happens with:
241
-
-`background(255, 255, 255)`?
242
-
-`background(0, 0, 0)`?
243
-
244
-
**Tip**: If you only type one number like `background(150)`, it fills the background with a shade of gray. That’s a shortcut for `background(150, 150, 150)`.
245
-
{: .notice--success}
246
-
247
-
---
248
-
249
-
##### 2C. Filling Shapes with Color
250
-
251
-
Let’s add an ellipse and give it color using the [fill()](https://p5js.org/reference/p5/fill/) feature:
252
-
253
-
```js
254
-
functionsetup() {
255
-
createCanvas(400, 400); // w, h
256
-
rectMode(CENTER);
257
-
}
258
-
259
-
functiondraw() {
260
-
background(220);
261
-
fill(255, 255, 0); // r, g, b
262
-
rect(200, 200, 40, 40); // x, y, w, h
263
-
ellipse(200, 200, 40, 40); // x, y, w, h
264
-
}
265
-
```
266
-
267
-
By default, [fill()](https://p5js.org/reference/p5/fill/) recognizes RGB values and sets the color of the shapes you draw. But what if you want to fill the ellipse with a different color? You will need to place another [fill()](https://p5js.org/reference/p5/fill/) right before the ellipse.
Once you feel comfortable with using RGB colors, you have the option of going further by adding a fourth number to [fill()](https://editor.p5js.org/xinemata/sketches/sU7-2LedO) to make something see-through!
287
-
288
-
```js
289
-
fill(255, 0, 0, 100); // r, g, b, alpha
290
-
```
291
-
292
-
The last number is called the alpha value. It also ranges from 0 (fully transparent) to 255 (fully opaque).
293
-
294
-
**Mini-Challenge:** Try overlapping shapes with different alpha values. What kinds of layering effects can you make?
295
-
{: .notice--warning}
296
-
297
-
##### 2D. Draw your favorite snack
298
-
Let’s use everything you’ve learned so far to draw a snack you love. Think about ways you could represent your snack using 2D primitives like ellipses and rectangles. And instead of guessing the RGB values of a color you want to use, play around with this [color picker](https://g.co/kgs/6fssxMC) to choose specific colors. Below is an example of a lollipop:
299
-
300
-

**Tip:** Adding [noStroke()](https://p5js.org/reference/p5/noStroke/) removes the black outline around shapes. [stroke()](https://p5js.org/reference/p5/stroke/) sets the outline to a different color. [strokeWeight()](https://p5js.org/reference/p5/strokeWeight/) alters the thickness of the outline.
306
-
{: .notice--success}
307
-
308
-
#### Grade 9~12
309
-
##### 3. Blend Modes
310
-
311
-
Want your colors to mix in cool ways—like in Photoshop or Instagram filters? Try this:
312
-
313
-
```js
314
-
functionsetup() {
315
-
createCanvas(400, 400);
316
-
blendMode(LIGHTEST); // Try other modes: DARKEST, MULTIPLY, DIFFERENCE
317
-
318
-
fill(255, 0, 0);
319
-
ellipse(150, 200, 200, 200);
320
-
321
-
fill(0, 0, 255);
322
-
ellipse(250, 200, 200, 200);
323
-
}
324
-
```
325
-
326
-
Blend modes change how colors mix when they overlap. Each one creates different visual effects.
194
+
The ellipse should now be sitting on top of your rectangle. What this tells us is that the order in which you code your shapes matters. [p5.js](https://p5js.org) is built on JavaScript, and JavaScript renders code on the fly from top to bottom. Coding the rectangle first means that the rectangle is drawn first, and then it gets covered by the ellipse, which comes later.
0 commit comments