Skip to content

Commit f0ad256

Browse files
IrtizaNasarksen0
authored andcommitted
Update VS Code tutorial section with p5.js 2.x Project Generator extension
- Added p5.js 2.x Project Generator extension integration - Updated VS Code setup instructions with extension benefits - Enhanced project creation workflow with two methods - Updated canvas size for better demonstrations
1 parent b47749e commit f0ad256

1 file changed

Lines changed: 35 additions & 21 deletions

File tree

src/content/tutorials/en/setting-up-your-environment.mdx

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ relatedContent:
1313
authors:
1414
- Layla Quiñones
1515
- Jaleesa Trapp
16+
- Shaikh Irtiza Nasar
1617
---
1718

1819
import EditableSketch from "../../../components/EditableSketch/index.astro";
@@ -304,22 +305,33 @@ Once your project is saved, you can share it!
304305
### Step 2: Install the p5.js library extension
305306

306307
- 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).
309310

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
310316

311317
### Step 3: Create a p5.js project
312318

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
315323

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
316328

317-
### Step 4: View your first sketch
329+
### Step 4: Preview your sketch
318330

319331
To view the preview for your code:
320332

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)
323335
- A window will open in your default browser with the output of your project.
324336

325337
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:
328340

329341
<EditableSketch code={`
330342
function setup() {
331-
  createCanvas(400, 400);
343+
  createCanvas(800, 600);
332344
}
333345
function draw() {
334346
  background(220);
335347
}
336348
`} />
337349

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. 
339351

340352

341353
#### `createCanvas()`
342354

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. 
344356

345357
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. 
346358

@@ -350,16 +362,16 @@ To learn more, visit the [p5.js reference](/reference/) pages for [`setup()`](/r
350362
### Step 5: Change the color of the canvas
351363

352364
- 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*.
354366

355367
Your code should look like this:
356368

357369
<EditableSketch code={`
358370
function setup() {
359-
  createCanvas(400, 400);
371+
  createCanvas(800, 600);
360372
}
361373
function draw() {
362-
  background("aqua");
374+
  background("yellow");
363375
}
364376
`} />
365377

@@ -386,12 +398,13 @@ Your code should look like this:
386398

387399
<EditableSketch code={`
388400
function setup() {
389-
  createCanvas(400, 400);
401+
  createCanvas(800, 600);
390402
}
391403
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);
395408
}
396409
`} />
397410

@@ -400,7 +413,7 @@ function draw() {
400413

401414
You can draw shapes on the canvas by typing specific commands for shapes within the curly brackets `{}` after [`function draw()`](/reference/p5/draw)
402415

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).
404417

405418

406419
### Step 7: Create!
@@ -425,18 +438,19 @@ Your code should look like this:
425438

426439
<EditableSketch code={`
427440
function setup() {
428-
  createCanvas(400, 400);
441+
  createCanvas(800, 600);
429442
}
430443
function draw() {
431-
  background(220);
444+
// Set background color to yellow as shown in Step 5
445+
  background("yellow");
432446
  //when mouse button is pressed, circles turn black
433447
if (mouseIsPressed === true) {
434448
    fill(0);
435449
  } else {
436450
    fill(255);
437451
  }
438452
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
440454
  circle(mouseX, mouseY, 100);
441455
}
442456
`} />

0 commit comments

Comments
 (0)