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
@@ -304,22 +305,33 @@ Once your project is saved, you can share it!
304
305
### Step 2: Install the p5.js library extension
305
306
306
307
- Open VS Code and navigate to the extensions manager on the left toolbar.
307
-
- Type [*p5.vscode*](https://marketplace.visualstudio.com/items?itemName=samplavigne.p5-vscode) in the search bar, select the extension, and click the install button.
308
-
- Familiarize yourself with details for this extension [here](https://github.com/antiboredom/p5.vscode/blob/master/README.md).
308
+
- Type [*p5.js 2.x Project Generator*](https://marketplace.visualstudio.com/items?itemName=Irti.p5js-project-generator) in the search bar, select the extension, and click the install button.
309
+
- Familiarize yourself with details for this extension [here](https://github.com/IrtizaNasar/p5-2.vscode/blob/main/README.md).
309
310
311
+
**This extension provides:**
312
+
- Quick project setup with p5.js 2.0
313
+
- IntelliSense and autocomplete for p5.js functions
314
+
- Online/offline library options
315
+
- Parameter hints for most p5.js functions
310
316
311
317
### Step 3: Create a p5.js project
312
318
313
-
- Click on *View* on the top toolbar and select Command Palette.
314
-
- Type *Create p5.js Project* in the search bar and select the folder on your machine in which you would like to save your project.
319
+
#### Method 1 - From Command Palette:
320
+
- Click on *View* on the top toolbar and select Command Palette or Press `Ctrl+Shift+P` (or `Cmd+Shift+P` on macOS)
321
+
- Type *Create a new p5.js 2.x Project* in the search bar and select the folder on your machine in which you would like to create your project.
322
+
- Follow the prompts to configure your project
315
323
324
+
#### Method 2 - From Explorer Context Menu:
325
+
- Right-click on a folder in the Explorer
326
+
- Select "Create p5.js 2.x Project Here"
327
+
- Follow the prompts to configure your project
316
328
317
-
### Step 4: View your first sketch
329
+
### Step 4: Preview your sketch
318
330
319
331
To view the preview for your code:
320
332
321
-
- Right click on the *index.html* file in the *VSCODE* tab on the left Explorer panel.
322
-
- Select *Open Live Server*.
333
+
- Right click on the `index.html` file in the *VSCODE* tab on the left Explorer panel.
334
+
- Select *Open Live Server* (this will start a local development server).
323
335
- A window will open in your default browser with the output of your project.
324
336
325
337
A *p5.js sketch* is a text file with code written in the *JavaScript* programming language. *JavaScript* is a programming language used to make web pages interactive. p5.js is a library written in *JavaScript* – which is why it ends in “*.js*” for *JavaScript*. With p5.js, you can create programs that are colorful and animated, with features that users can interact with! To learn more about some of the things you can do with p5.js, watch the [p5.js Welcome Video!](https://hello.p5js.org/) To learn more about JavaScript, you can visit [this resource.](https://developer.mozilla.org/en-US/docs/Web/JavaScript)
@@ -328,19 +340,19 @@ The editor begins with the following code in the *sketch.js* file and preview:
328
340
329
341
<EditableSketchcode={`
330
342
function setup() {
331
-
createCanvas(400, 400);
343
+
createCanvas(800, 600);
332
344
}
333
345
function draw() {
334
346
background(220);
335
347
}
336
348
`} />
337
349
338
-
The code above creates a canvas element in the preview that is 400 pixels wide and 400 pixels high. It also sets the background to a shade of gray.
350
+
The code above creates a canvas element in the preview that is 800 pixels wide and 600 pixels high. It also sets the background to a shade of gray.
339
351
340
352
341
353
#### `createCanvas()`
342
354
343
-
Computer screens are made up of tiny lights called *pixels*, which are the smallest elements that make up any image. The line of code that creates a canvas in the preview window is [`createCanvas(400, 400)`](/reference/p5/createCanvas). Without this line of code, there will be no canvas to draw on! The numbers 400, 400 correspond to the width and the height of the canvas in pixels. These numbers are also known as *arguments* for the [`createCanvas()`](/reference/p5/createCanvas) function.
355
+
Computer screens are made up of tiny lights called *pixels*, which are the smallest elements that make up any image. The line of code that creates a canvas in the preview window is [`createCanvas(800, 600)`](/reference/p5/createCanvas). Without this line of code, there will be no canvas to draw on! The numbers 800, 600 correspond to the width and the height of the canvas in pixels. These numbers are also known as *arguments* for the [`createCanvas()`](/reference/p5/createCanvas) function.
344
356
345
357
Any values that you place within parentheses of a function are called *arguments*: any value used to customize functions. [`createCanvas()`](/reference/p5/createCanvas) appears within the [`setup()`](/reference/p5/setup) function to create an HTML canvas element that you can draw on.
346
358
@@ -350,16 +362,16 @@ To learn more, visit the [p5.js reference](/reference/) pages for [`setup()`](/r
350
362
### Step 5: Change the color of the canvas
351
363
352
364
- Change the background color of your canvas by changing the *argument* for the [`background()`](/reference/p5/background) function.
353
-
- Change `background(220);` to `background("aqua");` and press *Play*.
365
+
- Change `background(220);` to `background("yellow");` and press *Play*.
354
366
355
367
Your code should look like this:
356
368
357
369
<EditableSketchcode={`
358
370
function setup() {
359
-
createCanvas(400, 400);
371
+
createCanvas(800, 600);
360
372
}
361
373
function draw() {
362
-
background("aqua");
374
+
background("yellow");
363
375
}
364
376
`} />
365
377
@@ -386,12 +398,13 @@ Your code should look like this:
386
398
387
399
<EditableSketchcode={`
388
400
function setup() {
389
-
createCanvas(400, 400);
401
+
createCanvas(800, 600);
390
402
}
391
403
function draw() {
392
-
background(220);
393
-
//circle in the center with a width of 100
394
-
circle(200,200,100);
404
+
// Set background color to yellow as shown in Step 5
405
+
background("yellow");
406
+
//Draw a circle in the center with a width of 100
407
+
circle(400,400,100);
395
408
}
396
409
`} />
397
410
@@ -400,7 +413,7 @@ function draw() {
400
413
401
414
You can draw shapes on the canvas by typing specific commands for shapes within the curly brackets `{}` after [`function draw()`](/reference/p5/draw).
402
415
403
-
The sketch above draws a circle on the canvas by calling the [`circle()`](/reference/p5/circle) function within [`draw()`](/reference/p5/draw). The first two *arguments* – `200, 200` – place the circle in the center of the canvas, and the last *argument* – `100` – indicates that the circle is 100 pixels wide. The comments embedded in the sketch in the lines above the [`circle()`](/reference/p5/circle)``function describe what the code does. To learn more, visit the [p5.js reference](/reference/) pages for [`draw()`](/reference/p5/draw) and [`circle()`](/reference/p5/circle).
416
+
The sketch above draws a circle on the canvas by calling the [`circle()`](/reference/p5/circle) function within [`draw()`](/reference/p5/draw). The first two *arguments* – `400, 400` – place the circle in the center of the canvas, and the last *argument* – `100` – indicates that the circle is 100 pixels wide. The comments embedded in the sketch in the lines above the [`circle()`](/reference/p5/circle)``function describe what the code does. To learn more, visit the [p5.js reference](/reference/) pages for [`draw()`](/reference/p5/draw) and [`circle()`](/reference/p5/circle).
404
417
405
418
406
419
### Step 7: Create!
@@ -425,18 +438,19 @@ Your code should look like this:
425
438
426
439
<EditableSketchcode={`
427
440
function setup() {
428
-
createCanvas(400, 400);
441
+
createCanvas(800, 600);
429
442
}
430
443
function draw() {
431
-
background(220);
444
+
// Set background color to yellow as shown in Step 5
445
+
background("yellow");
432
446
//when mouse button is pressed, circles turn black
433
447
if (mouseIsPressed === true) {
434
448
fill(0);
435
449
} else {
436
450
fill(255);
437
451
}
438
452
439
-
//white circles drawn at mouse position
453
+
//Draw a white circle at mouse position (mouseX, mouseY) with a width of 100 similar to Step 6
0 commit comments