From 81ff09d47f2015bc3db8b39392f6474e105a255e Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Wed, 16 Apr 2025 01:20:54 +0530 Subject: [PATCH 01/29] updating computeFaces --- src/webgl/p5.Geometry.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/webgl/p5.Geometry.js b/src/webgl/p5.Geometry.js index 22e3a481c4..66afc38322 100644 --- a/src/webgl/p5.Geometry.js +++ b/src/webgl/p5.Geometry.js @@ -763,17 +763,15 @@ class Geometry { * * let myGeometry; * + * let v0; + * let v1; + * let v2; + * let v3; * function setup() { * createCanvas(100, 100, WEBGL); * * // Create a p5.Geometry object. - * myGeometry = new p5.Geometry(); - * - * // Create p5.Vector objects to position the vertices. - * let v0 = createVector(-40, 0, 0); - * let v1 = createVector(0, -40, 0); - * let v2 = createVector(0, 40, 0); - * let v3 = createVector(40, 0, 0); + * myGeometry = buildGeometry(createShape); * * // Add the vertices to myGeometry's vertices array. * myGeometry.vertices.push(v0, v1, v2, v3); @@ -800,6 +798,15 @@ class Geometry { * // Draw the p5.Geometry object. * model(myGeometry); * } + * + * function createShape() { + * // Create p5.Vector objects to position the vertices. + * v0 = createVector(-40, 0, 0); + * v1 = createVector(0, -40, 0); + * v2 = createVector(0, 40, 0); + * v3 = createVector(40, 0, 0); + * } + * * * * From 77a14926a515c5a3629811c784212e7998356fc2 Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Wed, 16 Apr 2025 18:22:37 +0530 Subject: [PATCH 02/29] fixed vertexNormals --- src/webgl/p5.Geometry.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/webgl/p5.Geometry.js b/src/webgl/p5.Geometry.js index 66afc38322..0ea81da864 100644 --- a/src/webgl/p5.Geometry.js +++ b/src/webgl/p5.Geometry.js @@ -2365,13 +2365,16 @@ function geometry(p5, fn){ * createCanvas(100, 100, WEBGL); * * // Create a p5.Geometry object. - * myGeometry = new p5.Geometry(); - * + * myGeometry = buildGeometry(function(){ + * * // Create p5.Vector objects to position the vertices. * let v0 = createVector(-40, 0, 0); * let v1 = createVector(0, -40, 0); * let v2 = createVector(0, 40, 0); * let v3 = createVector(40, 0, 0); + * + * }); + * * * // Add the vertices to the p5.Geometry object's vertices array. * myGeometry.vertices.push(v0, v1, v2, v3); @@ -2404,7 +2407,6 @@ function geometry(p5, fn){ * * */ - /** * An array that lists which of the geometry's vertices form each of its * faces. From 302e25bdb877b4214e87968e71994b3b9d44c1ed Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Wed, 16 Apr 2025 18:45:02 +0530 Subject: [PATCH 03/29] vertices fixing --- src/webgl/p5.Geometry.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/webgl/p5.Geometry.js b/src/webgl/p5.Geometry.js index 0ea81da864..12bd5fe150 100644 --- a/src/webgl/p5.Geometry.js +++ b/src/webgl/p5.Geometry.js @@ -2196,12 +2196,14 @@ function geometry(p5, fn){ * createCanvas(100, 100, WEBGL); * * // Create a p5.Geometry object. - * myGeometry = new p5.Geometry(); - * + * myGeometry = buildGeometry(function(){ + * * // Create p5.Vector objects to position the vertices. - * let v0 = createVector(-40, 0, 0); - * let v1 = createVector(0, -40, 0); - * let v2 = createVector(40, 0, 0); + * v0 = createVector(-40, 0, 0); + * v1 = createVector(0, -40, 0); + * v2 = createVector(40, 0, 0); + * + * }); * * // Add the vertices to the p5.Geometry object's vertices array. * myGeometry.vertices.push(v0, v1, v2); From ade54acce8ea38a83392bb68e82e448d4535f054 Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Wed, 16 Apr 2025 18:46:43 +0530 Subject: [PATCH 04/29] fixing --- src/webgl/p5.Geometry.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/webgl/p5.Geometry.js b/src/webgl/p5.Geometry.js index 12bd5fe150..5858716129 100644 --- a/src/webgl/p5.Geometry.js +++ b/src/webgl/p5.Geometry.js @@ -2370,10 +2370,10 @@ function geometry(p5, fn){ * myGeometry = buildGeometry(function(){ * * // Create p5.Vector objects to position the vertices. - * let v0 = createVector(-40, 0, 0); - * let v1 = createVector(0, -40, 0); - * let v2 = createVector(0, 40, 0); - * let v3 = createVector(40, 0, 0); + * v0 = createVector(-40, 0, 0); + * v1 = createVector(0, -40, 0); + * v2 = createVector(0, 40, 0); + * v3 = createVector(40, 0, 0); * * }); * From 9df7595164cfe9b7e45ff06e64d100c629234b33 Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Wed, 16 Apr 2025 19:08:36 +0530 Subject: [PATCH 05/29] fixing setAlpha --- src/color/p5.Color.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/color/p5.Color.js b/src/color/p5.Color.js index 886caa6e83..dafc1fa9ab 100644 --- a/src/color/p5.Color.js +++ b/src/color/p5.Color.js @@ -492,7 +492,7 @@ class Color { * } * * - **/ + */ setAlpha(new_alpha, max=[0, 1]) { if(!Array.isArray(max)){ max = [0, max]; From 28cf83f4b59ba010d49dcee47042213096a0568b Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Wed, 16 Apr 2025 20:51:38 +0530 Subject: [PATCH 06/29] fixing-setGreen --- src/color/p5.Color.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/color/p5.Color.js b/src/color/p5.Color.js index dafc1fa9ab..bddd312688 100644 --- a/src/color/p5.Color.js +++ b/src/color/p5.Color.js @@ -381,7 +381,7 @@ class Color { * } * * - **/ + */ setGreen(new_green, max=[0, 1]) { if(!Array.isArray(max)){ max = [0, max]; From 5d2aad13cfc2187beea042df9ed519daa7968cdc Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Wed, 16 Apr 2025 21:06:56 +0530 Subject: [PATCH 07/29] updating fontAscent --- src/type/textCore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/type/textCore.js b/src/type/textCore.js index e4a5a1107f..11c863d650 100644 --- a/src/type/textCore.js +++ b/src/type/textCore.js @@ -1240,7 +1240,7 @@ function textCore(p5, fn) { * createCanvas(300, 300); * background(220); * - * textSize(48); + * textSize(35); * textAlign(LEFT, BASELINE); * textFont('Georgia'); * From 9e7445f94170acfcc107b378ac04ebd8789e7daf Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Wed, 16 Apr 2025 21:21:57 +0530 Subject: [PATCH 08/29] fixing @method pixels --- src/image/pixels.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/image/pixels.js b/src/image/pixels.js index e1d1edd614..ebea101273 100644 --- a/src/image/pixels.js +++ b/src/image/pixels.js @@ -41,6 +41,7 @@ function pixels(p5, fn){ * * function setup() { * createCanvas(100, 100); + * background(128); * * // Load the pixels array. * loadPixels(); From 12a6a17f5fed705fe4f207fd8ca16f058d2549e5 Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Thu, 17 Apr 2025 02:22:36 +0530 Subject: [PATCH 09/29] fixing-getCurrentFrame() --- src/image/p5.Image.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/image/p5.Image.js b/src/image/p5.Image.js index 4b1002012e..b323bced46 100644 --- a/src/image/p5.Image.js +++ b/src/image/p5.Image.js @@ -1637,7 +1637,7 @@ class Image { * * async function setup() { * // Load the image. - * gif = await loadImage('assets/arnott-wallace-wink-loop-forever.gif'); + * gif = await loadImage('assets/arnott-wallace-eye-loop-forever.gif'); * * createCanvas(100, 100); * From 8f017b0556fd958473ab91770b06fb29670d27f6 Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Thu, 17 Apr 2025 02:25:42 +0530 Subject: [PATCH 10/29] fixing numFrames --- src/image/p5.Image.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/image/p5.Image.js b/src/image/p5.Image.js index b323bced46..af3d401696 100644 --- a/src/image/p5.Image.js +++ b/src/image/p5.Image.js @@ -1733,7 +1733,7 @@ class Image { * * async function setup() { * // Load the image. - * gif = await loadImage('assets/arnott-wallace-wink-loop-forever.gif'); + * gif = await loadImage('assets/arnott-wallace-eye-loop-forever.gif'); * * createCanvas(100, 100); * From eaedc0ae24e7fa8c5b85047dfda436ec0f3a8866 Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Thu, 17 Apr 2025 02:28:29 +0530 Subject: [PATCH 11/29] fixing setFrame() --- src/image/p5.Image.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/image/p5.Image.js b/src/image/p5.Image.js index af3d401696..0fad23a429 100644 --- a/src/image/p5.Image.js +++ b/src/image/p5.Image.js @@ -1677,7 +1677,7 @@ class Image { * * async function setup() { * // Load the image. - * gif = await loadImage('assets/arnott-wallace-wink-loop-forever.gif'); + * gif = await loadImage('assets/arnott-wallace-eye-loop-forever.gif'); * * createCanvas(100, 100); * From 2abbd76cf6a1ac36208cb67860ccaf6227622620 Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Thu, 17 Apr 2025 02:48:53 +0530 Subject: [PATCH 12/29] fixing describe() --- src/accessibility/describe.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/accessibility/describe.js b/src/accessibility/describe.js index 79cebe605e..984682ee34 100644 --- a/src/accessibility/describe.js +++ b/src/accessibility/describe.js @@ -75,6 +75,11 @@ function describe(p5, fn){ * *
* + * + * function setup(){ + * createCanvas(100, 100); + * }; + * * function draw() { * background(200); * @@ -96,6 +101,11 @@ function describe(p5, fn){ * *
* + * + * function setup(){ + * createCanvas(100, 100); + * } + * * function draw() { * background(200); * From 7b5d67ce84b50499cd7a579366663220eafefb58 Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Thu, 17 Apr 2025 02:55:05 +0530 Subject: [PATCH 13/29] fixing gridOutputs --- src/accessibility/outputs.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/accessibility/outputs.js b/src/accessibility/outputs.js index a8b445bc28..d45142c3df 100644 --- a/src/accessibility/outputs.js +++ b/src/accessibility/outputs.js @@ -215,6 +215,11 @@ function outputs(p5, fn){ * *
* + * + * function setup() { + * createCanvas(100, 100); + * } + * * function draw() { * // Add the grid description. * gridOutput(); @@ -235,6 +240,11 @@ function outputs(p5, fn){ * *
* + * + * function setup(){ + * createCanvas(100, 100); + * } + * * function draw() { * // Add the grid description and * // display it for debugging. @@ -255,6 +265,7 @@ function outputs(p5, fn){ *
*/ + fn.gridOutput = function(display) { // p5._validateParameters('gridOutput', arguments); //if gridOutput is already true From c3851b3dc7801c87df7ad0837c12a21b495ea22f Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Thu, 17 Apr 2025 03:02:08 +0530 Subject: [PATCH 14/29] fixing text-output --- src/accessibility/outputs.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/accessibility/outputs.js b/src/accessibility/outputs.js index d45142c3df..6fa60e6243 100644 --- a/src/accessibility/outputs.js +++ b/src/accessibility/outputs.js @@ -81,6 +81,11 @@ function outputs(p5, fn){ * *
* + * + * function setup(){ + * createCanvas(100, 100); + * } + * * function draw() { * // Add the text description. * textOutput(); @@ -101,6 +106,11 @@ function outputs(p5, fn){ * *
* + * + * function setup(){ + * createCanvas(100, 100); + * } + * * function draw() { * // Add the text description and * // display it for debugging. From dac7ff27628c9fa8cf8b5c59d0fca55657fe519d Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Thu, 17 Apr 2025 03:19:03 +0530 Subject: [PATCH 15/29] fixing all p5.Camera text orientation --- src/webgl/p5.Camera.js | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/src/webgl/p5.Camera.js b/src/webgl/p5.Camera.js index c6f30660c0..bca2efb2a2 100644 --- a/src/webgl/p5.Camera.js +++ b/src/webgl/p5.Camera.js @@ -71,7 +71,7 @@ class Camera { * fill(0); * * // Display the value of eyeX, rounded to the nearest integer. - * text(`eyeX: ${round(cam.eyeX)}`, 0, 55); + * text(`eyeX: ${round(cam.eyeX)}`, 0, 45); * } * *
@@ -89,9 +89,6 @@ class Camera { * // Create a p5.Camera object. * cam = createCamera(); * - * // Set the camera - * setCamera(cam); - * * // Place the camera at the top-center. * cam.setPosition(0, -400, 800); * @@ -125,7 +122,7 @@ class Camera { * cam.setPosition(x, -400, 800); * * // Display the value of eyeX, rounded to the nearest integer. - * text(`eyeX: ${round(cam.eyeX)}`, 0, 55); + * text(`eyeX: ${round(cam.eyeX)}`, 0, 45); * } *
*
@@ -183,7 +180,7 @@ class Camera { * fill(0); * * // Display the value of eyeY, rounded to the nearest integer. - * text(`eyeY: ${round(cam.eyeY)}`, 0, 55); + * text(`eyeY: ${round(cam.eyeY)}`, 0, 45); * } *
*
@@ -237,7 +234,7 @@ class Camera { * cam.setPosition(0, y, 800); * * // Display the value of eyeY, rounded to the nearest integer. - * text(`eyeY: ${round(cam.eyeY)}`, 0, 55); + * text(`eyeY: ${round(cam.eyeY)}`, 0, 45); * } *
*
@@ -295,7 +292,7 @@ class Camera { * fill(0); * * // Display the value of eyeZ, rounded to the nearest integer. - * text(`eyeZ: ${round(cam.eyeZ)}`, 0, 55); + * text(`eyeZ: ${round(cam.eyeZ)}`, 0, 45); * } *
*
@@ -349,7 +346,7 @@ class Camera { * cam.setPosition(0, -400, z); * * // Display the value of eyeZ, rounded to the nearest integer. - * text(`eyeZ: ${round(cam.eyeZ)}`, 0, 55); + * text(`eyeZ: ${round(cam.eyeZ)}`, 0, 45); * } *
* @@ -408,7 +405,7 @@ class Camera { * fill(0); * * // Display the value of centerX, rounded to the nearest integer. - * text(`centerX: ${round(cam.centerX)}`, 0, 55); + * text(`centerX: ${round(cam.centerX)}`, 0, 45); * } * * @@ -462,7 +459,7 @@ class Camera { * cam.lookAt(x, 20, -30); * * // Display the value of centerX, rounded to the nearest integer. - * text(`centerX: ${round(cam.centerX)}`, 0, 55); + * text(`centerX: ${round(cam.centerX)}`, 0, 45); * } * * @@ -521,7 +518,7 @@ class Camera { * fill(0); * * // Display the value of centerY, rounded to the nearest integer. - * text(`centerY: ${round(cam.centerY)}`, 0, 55); + * text(`centerY: ${round(cam.centerY)}`, 0, 45); * } * * @@ -575,7 +572,7 @@ class Camera { * cam.lookAt(10, y, -30); * * // Display the value of centerY, rounded to the nearest integer. - * text(`centerY: ${round(cam.centerY)}`, 0, 55); + * text(`centerY: ${round(cam.centerY)}`, 0, 45); * } * * @@ -634,7 +631,7 @@ class Camera { * fill(0); * * // Display the value of centerZ, rounded to the nearest integer. - * text(`centerZ: ${round(cam.centerZ)}`, 0, 55); + * text(`centerZ: ${round(cam.centerZ)}`, 0, 45); * } * * @@ -652,9 +649,6 @@ class Camera { * // Create a p5.Camera object. * cam = createCamera(); * - * // Set the camera - * setCamera(cam); - * * // Place the camera at the top-right. * cam.setPosition(100, -400, 800); * @@ -688,7 +682,7 @@ class Camera { * cam.lookAt(10, 20, z); * * // Display the value of centerZ, rounded to the nearest integer. - * text(`centerZ: ${round(cam.centerZ)}`, 0, 55); + * text(`centerZ: ${round(cam.centerZ)}`, 0, 45); * } * * @@ -746,7 +740,7 @@ class Camera { * fill(0); * * // Display the value of upX, rounded to the nearest tenth. - * text(`upX: ${round(cam.upX, 1)}`, 0, 55); + * text(`upX: ${round(cam.upX, 1)}`, 0, 45); * } * * @@ -799,7 +793,7 @@ class Camera { * cam.camera(100, -400, 800, 0, 0, 0, x, 1, 0); * * // Display the value of upX, rounded to the nearest tenth. - * text(`upX: ${round(cam.upX, 1)}`, 0, 55); + * text(`upX: ${round(cam.upX, 1)}`, 0, 45); * } * * @@ -857,7 +851,7 @@ class Camera { * fill(0); * * // Display the value of upY, rounded to the nearest tenth. - * text(`upY: ${round(cam.upY, 1)}`, 0, 55); + * text(`upY: ${round(cam.upY, 1)}`, 0, 45); * } * * @@ -910,7 +904,7 @@ class Camera { * cam.camera(100, -400, 800, 0, 0, 0, 0, y, 0); * * // Display the value of upY, rounded to the nearest tenth. - * text(`upY: ${round(cam.upY, 1)}`, 0, 55); + * text(`upY: ${round(cam.upY, 1)}`, 0, 45); * } * * @@ -968,7 +962,7 @@ class Camera { * fill(0); * * // Display the value of upZ, rounded to the nearest tenth. - * text(`upZ: ${round(cam.upZ, 1)}`, 0, 55); + * text(`upZ: ${round(cam.upZ, 1)}`, 0, 45); * } * * @@ -1021,7 +1015,7 @@ class Camera { * cam.camera(100, -400, 800, 0, 0, 0, 0, 1, z); * * // Display the value of upZ, rounded to the nearest tenth. - * text(`upZ: ${round(cam.upZ, 1)}`, 0, 55); + * text(`upZ: ${round(cam.upZ, 1)}`, 0, 45); * } * * From d19fefcb84761c719be44fd1bf7cc016252ff99e Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Fri, 18 Apr 2025 20:42:44 +0530 Subject: [PATCH 16/29] fixing setAttributes() --- src/webgl/p5.RendererGL.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/webgl/p5.RendererGL.js b/src/webgl/p5.RendererGL.js index a5ea3b85a9..3a45599bb6 100644 --- a/src/webgl/p5.RendererGL.js +++ b/src/webgl/p5.RendererGL.js @@ -2615,11 +2615,10 @@ function rendererGL(p5, fn) { * } * * - *
- * Now with the antialias attribute set to true. - *
+ * *
* + * // Now with the antialias attribute set to true. * function setup() { * setAttributes('antialias', true); * createCanvas(100, 100, WEBGL); From e4acb5f9534e5236c18eaa27b514cc43abb9b48e Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Sat, 19 Apr 2025 01:11:50 +0530 Subject: [PATCH 17/29] fixing httpDo --- src/io/files.js | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/io/files.js b/src/io/files.js index b98bf009f6..444c5feb37 100644 --- a/src/io/files.js +++ b/src/io/files.js @@ -1089,20 +1089,29 @@ function files(p5, fn){ * let eqFeatureIndex = 0; * * function setup() { + * createCanvas(100,100); + * * let url = 'https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson'; + * + * const req = new Request(url, { + * method: 'GET', + * headers: {authorization: 'Bearer secretKey'} + * }); + * // httpDo(path, method, datatype, success, error) + * * httpDo( - * url, - * { - * method: 'GET', - * // Other Request options, like special headers for apis - * headers: { authorization: 'Bearer secretKey' } + * req, + * 'GET', + * 'json', + * res => { + * earthquakes = res; * }, - * function(res) { - * earthquakes = res; - * } - * ); + * err => { + * console.error('Error loading data:', err); + * } + * ); * } - * + * * function draw() { * // wait until the data is loaded * if (!earthquakes || !earthquakes.features[eqFeatureIndex]) { From 9039796d359aa2c151972dba40974b0017006544 Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Sat, 19 Apr 2025 01:31:03 +0530 Subject: [PATCH 18/29] fixing httpPost --- src/io/files.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/io/files.js b/src/io/files.js index 444c5feb37..2a23bb71db 100644 --- a/src/io/files.js +++ b/src/io/files.js @@ -950,7 +950,7 @@ function files(p5, fn){ * } * * function mousePressed() { - * httpPost(url, 'json', postData, function(result) { + * httpPost(url, postData, 'json', function(result) { * strokeWeight(2); * text(result.body, mouseX, mouseY); * }); @@ -970,8 +970,8 @@ function files(p5, fn){ * function mousePressed() { * httpPost( * url, - * 'json', * postData, + * 'json', * function(result) { * // ... won't be called * }, From 63af24e24dd4bf03a064af487ce1ecce3106bc45 Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Sat, 19 Apr 2025 02:06:07 +0530 Subject: [PATCH 19/29] fixing print() --- src/core/environment.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/environment.js b/src/core/environment.js index 6936d04f52..0d7d6b949c 100644 --- a/src/core/environment.js +++ b/src/core/environment.js @@ -31,8 +31,8 @@ function environment(p5, fn){ * @method print * @param {Any} contents content to print to the console. * @example - *
- * + *
+ * * function setup() { * // Prints "hello, world" to the console. * print('hello, world'); @@ -40,8 +40,8 @@ function environment(p5, fn){ * *
* - *
- * + *
+ * * function setup() { * let name = 'ada'; * // Prints "hello, ada" to the console. From 24763af0a2aca8e1c5b0fb8373280b2086999591 Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Sat, 19 Apr 2025 23:31:37 +0530 Subject: [PATCH 20/29] fixing getNum() --- src/io/p5.TableRow.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/io/p5.TableRow.js b/src/io/p5.TableRow.js index ae5f04652c..c5f1dfd4ea 100644 --- a/src/io/p5.TableRow.js +++ b/src/io/p5.TableRow.js @@ -255,8 +255,8 @@ class TableRow { * let table; * * async function setup() { - * // Create a 200x100 canvas and set a white background - * createCanvas(200, 100); + * // Create a 300x100 canvas and set a white background + * createCanvas(300, 100); * background(255); * * // Load the CSV file with a header row From 301d42f40e55ea2a9ac244ac6cb23afe44dbd78d Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Sat, 19 Apr 2025 23:57:03 +0530 Subject: [PATCH 21/29] Fixing rotationX(), rotationY() and rotationZ() --- src/events/acceleration.js | 48 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/events/acceleration.js b/src/events/acceleration.js index 36ab8a047e..3b0d5d8dc7 100644 --- a/src/events/acceleration.js +++ b/src/events/acceleration.js @@ -142,18 +142,18 @@ function acceleration(p5, fn){ * @example *
* + * let rotationX = 0; // Angle in degrees + * * function setup() { - * createCanvas(100, 100, WEBGL); + * createCanvas(200, 200, WEBGL); // Create 3D canvas * } * * function draw() { - * background(200); - * //rotateZ(radians(rotationZ)); - * rotateX(radians(rotationX)); - * //rotateY(radians(rotationY)); - * box(200, 200, 200); - * describe(`red horizontal line right, green vertical line bottom. - * black background.`); + * background(220); // Set light gray background + * rotateX(radians(rotationX)); // Rotate around X-axis + * normalMaterial(); // Apply simple shaded material + * box(60); // Draw 3D cube (60 units wide) + * rotationX = (rotationX + 2) % 360; // Increment rotation (2° per frame) * } * *
@@ -175,18 +175,18 @@ function acceleration(p5, fn){ * @example *
* + * let rotationY = 0; // Angle in degrees + * * function setup() { - * createCanvas(100, 100, WEBGL); + * createCanvas(200, 200, WEBGL); // Create 3D canvas * } * * function draw() { - * background(200); - * //rotateZ(radians(rotationZ)); - * //rotateX(radians(rotationX)); - * rotateY(radians(rotationY)); - * box(200, 200, 200); - * describe(`red horizontal line right, green vertical line bottom. - * black background.`); + * background(220); // Set light gray background + * rotateY(radians(rotationY)); // Rotate around Y-axis (vertical) + * normalMaterial(); // Apply simple shaded material + * box(60); // Draw 3D cube (60 units wide) + * rotationY = (rotationY + 2) % 360; // Increment rotation (2° per frame) * } * *
@@ -209,18 +209,18 @@ function acceleration(p5, fn){ * @example *
* + * let rotationZ = 0; // Angle in degrees + * * function setup() { - * createCanvas(100, 100, WEBGL); + * createCanvas(200, 200, WEBGL); // Create 3D canvas * } * * function draw() { - * background(200); - * rotateZ(radians(rotationZ)); - * //rotateX(radians(rotationX)); - * //rotateY(radians(rotationY)); - * box(200, 200, 200); - * describe(`red horizontal line right, green vertical line bottom. - * black background.`); + * background(220); + * rotateZ(radians(rotationZ)); // Rotate around Z-axis + * normalMaterial(); // Apply simple shaded material + * box(60); // Draw 3D cube + * rotationZ = (rotationZ + 2) % 360; // Increment rotation angle * } * *
From dd6a98828c606e81775c2467aa98f9932262562a Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Sun, 20 Apr 2025 00:37:54 +0530 Subject: [PATCH 22/29] updating checkBox() --- src/dom/dom.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index 0cf3edee0b..509b95991b 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -945,7 +945,7 @@ function dom(p5, fn){ * * // Create a checkbox and place it beneath the canvas. * checkbox = createCheckbox(); - * checkbox.position(0, 100); + * checkbox.position(0, 70); * * describe('A black square with a checkbox beneath it. The square turns white when the box is checked.'); * } @@ -971,7 +971,7 @@ function dom(p5, fn){ * // Create a checkbox and place it beneath the canvas. * // Label the checkbox "white". * checkbox = createCheckbox(' white'); - * checkbox.position(0, 100); + * checkbox.position(0, 70); * * describe('A black square with a checkbox labeled "white" beneath it. The square turns white when the box is checked.'); * } @@ -997,7 +997,7 @@ function dom(p5, fn){ * // Create a checkbox and place it beneath the canvas. * // Label the checkbox "white" and set its value to true. * checkbox = createCheckbox(' white', true); - * checkbox.position(0, 100); + * checkbox.position(0, 70); * * describe('A white square with a checkbox labeled "white" beneath it. The square turns black when the box is unchecked.'); * } From 58e87462488b61684cf7570de4084e927b9a29d6 Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Sun, 20 Apr 2025 00:45:14 +0530 Subject: [PATCH 23/29] createFileInput() orientation --- src/dom/dom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index 509b95991b..c28a4b99a5 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -1876,7 +1876,7 @@ function dom(p5, fn){ * let img; * * function setup() { - * createCanvas(100, 100); + * createCanvas(200, 200); * * // Create a file input and place it beneath * // the canvas. From 25b164e8ab6352d43c85211cd615b4109f2c9094 Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Sun, 20 Apr 2025 00:51:13 +0530 Subject: [PATCH 24/29] minor fixes --- src/dom/dom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index c28a4b99a5..958ba711c2 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -596,7 +596,7 @@ function dom(p5, fn){ * 'https://p5js.org/assets/img/asterisk-01.png', * 'The p5.js magenta asterisk.' * ); - * img.position(0, -10); + * img.position(0, 10); * * describe('A gray square with a magenta asterisk in its center.'); * } From bf86b7765ac7b0d7a3a7fb00703edfe07b256513 Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Sun, 20 Apr 2025 00:52:27 +0530 Subject: [PATCH 25/29] createElement fixes --- src/dom/dom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index 958ba711c2..6576d4c79e 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -352,7 +352,7 @@ function dom(p5, fn){ * let slider; * * function setup() { - * createCanvas(100, 100); + * createCanvas(200, 200); * * // Create a paragraph element and place * // it at the top of the canvas. From 289c1760d371480e7e89ebd15b19353f3b7e1622 Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Sun, 20 Apr 2025 01:10:16 +0530 Subject: [PATCH 26/29] fixing wording of setup() by removing preload --- src/core/main.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/main.js b/src/core/main.js index 3394715aa2..660775b8b8 100644 --- a/src/core/main.js +++ b/src/core/main.js @@ -462,9 +462,10 @@ for (const k in constants) { * ``` * * Code placed in `setup()` will run once before code placed in - * draw() begins looping. If the - * preload() is declared, then `setup()` will - * run immediately after preload() finishes + * draw() begins looping. When `setup()` is declared async, + * execution pauses at each `await` until the promise resolves, ensuring all assets + * are loaded before the sketch continues. + * * loading assets. * * Note: `setup()` doesn’t have to be declared, but it’s common practice to do so. @@ -535,7 +536,6 @@ for (const k in constants) { *
*
*/ - /** * A function that's called repeatedly while the sketch runs. * From 36b0bb0200c3c61d8b90cd4cb51c3a3baa563eba Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Thu, 24 Apr 2025 02:12:05 +0530 Subject: [PATCH 27/29] fixing broken url --- src/dom/dom.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index 6576d4c79e..7501130cbf 100644 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -593,8 +593,8 @@ function dom(p5, fn){ * background(200); * * let img = createImg( - * 'https://p5js.org/assets/img/asterisk-01.png', - * 'The p5.js magenta asterisk.' + * '/assets/cat.jpg', + * 'image of a cat' * ); * img.position(0, 10); * From 608d2faff27570be34a96a1cd2af45a721382dee Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Thu, 24 Apr 2025 02:13:56 +0530 Subject: [PATCH 28/29] adding more context to docs --- src/core/main.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/core/main.js b/src/core/main.js index 660775b8b8..88b0249436 100644 --- a/src/core/main.js +++ b/src/core/main.js @@ -462,9 +462,14 @@ for (const k in constants) { * ``` * * Code placed in `setup()` will run once before code placed in - * draw() begins looping. When `setup()` is declared async, - * execution pauses at each `await` until the promise resolves, ensuring all assets - * are loaded before the sketch continues. + * draw() begins looping. + * If `setup()` is declared `async` (e.g. `async function setup()`), + * execution pauses at each `await` until its promise resolves. + * For example, `font = await loadFont(...)` waits for the font asset + * to load because `loadFont()` function returns a promise, and the await + * keyword means the program will wait for the promise to resolve. + * This ensures that all assets are fully loaded before the sketch continues. + * * loading assets. * From 68dd3ae080d34a3de5989d70c378e37f59954754 Mon Sep 17 00:00:00 2001 From: Perminder Singh <127239756+perminder-17@users.noreply.github.com> Date: Thu, 24 Apr 2025 02:36:04 +0530 Subject: [PATCH 29/29] reverting back to old p5.Geometry --- src/webgl/p5.Geometry.js | 49 ++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/src/webgl/p5.Geometry.js b/src/webgl/p5.Geometry.js index 5858716129..22e3a481c4 100644 --- a/src/webgl/p5.Geometry.js +++ b/src/webgl/p5.Geometry.js @@ -763,15 +763,17 @@ class Geometry { * * let myGeometry; * - * let v0; - * let v1; - * let v2; - * let v3; * function setup() { * createCanvas(100, 100, WEBGL); * * // Create a p5.Geometry object. - * myGeometry = buildGeometry(createShape); + * myGeometry = new p5.Geometry(); + * + * // Create p5.Vector objects to position the vertices. + * let v0 = createVector(-40, 0, 0); + * let v1 = createVector(0, -40, 0); + * let v2 = createVector(0, 40, 0); + * let v3 = createVector(40, 0, 0); * * // Add the vertices to myGeometry's vertices array. * myGeometry.vertices.push(v0, v1, v2, v3); @@ -798,15 +800,6 @@ class Geometry { * // Draw the p5.Geometry object. * model(myGeometry); * } - * - * function createShape() { - * // Create p5.Vector objects to position the vertices. - * v0 = createVector(-40, 0, 0); - * v1 = createVector(0, -40, 0); - * v2 = createVector(0, 40, 0); - * v3 = createVector(40, 0, 0); - * } - * *
*
* @@ -2196,14 +2189,12 @@ function geometry(p5, fn){ * createCanvas(100, 100, WEBGL); * * // Create a p5.Geometry object. - * myGeometry = buildGeometry(function(){ - * - * // Create p5.Vector objects to position the vertices. - * v0 = createVector(-40, 0, 0); - * v1 = createVector(0, -40, 0); - * v2 = createVector(40, 0, 0); + * myGeometry = new p5.Geometry(); * - * }); + * // Create p5.Vector objects to position the vertices. + * let v0 = createVector(-40, 0, 0); + * let v1 = createVector(0, -40, 0); + * let v2 = createVector(40, 0, 0); * * // Add the vertices to the p5.Geometry object's vertices array. * myGeometry.vertices.push(v0, v1, v2); @@ -2367,16 +2358,13 @@ function geometry(p5, fn){ * createCanvas(100, 100, WEBGL); * * // Create a p5.Geometry object. - * myGeometry = buildGeometry(function(){ - * - * // Create p5.Vector objects to position the vertices. - * v0 = createVector(-40, 0, 0); - * v1 = createVector(0, -40, 0); - * v2 = createVector(0, 40, 0); - * v3 = createVector(40, 0, 0); - * - * }); + * myGeometry = new p5.Geometry(); * + * // Create p5.Vector objects to position the vertices. + * let v0 = createVector(-40, 0, 0); + * let v1 = createVector(0, -40, 0); + * let v2 = createVector(0, 40, 0); + * let v3 = createVector(40, 0, 0); * * // Add the vertices to the p5.Geometry object's vertices array. * myGeometry.vertices.push(v0, v1, v2, v3); @@ -2409,6 +2397,7 @@ function geometry(p5, fn){ *
*
*/ + /** * An array that lists which of the geometry's vertices form each of its * faces.