Skip to content

Updating all the broken refrence examples. #7739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 30 commits into
base: dev-2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
81ff09d
updating computeFaces
perminder-17 Apr 15, 2025
77a1492
fixed vertexNormals
perminder-17 Apr 16, 2025
302e25b
vertices fixing
perminder-17 Apr 16, 2025
ade54ac
fixing
perminder-17 Apr 16, 2025
9df7595
fixing setAlpha
perminder-17 Apr 16, 2025
28cf83f
fixing-setGreen
perminder-17 Apr 16, 2025
5d2aad1
updating fontAscent
perminder-17 Apr 16, 2025
9e7445f
fixing @method pixels
perminder-17 Apr 16, 2025
12a6a17
fixing-getCurrentFrame()
perminder-17 Apr 16, 2025
8f017b0
fixing numFrames
perminder-17 Apr 16, 2025
eaedc0a
fixing setFrame()
perminder-17 Apr 16, 2025
2abbd76
fixing describe()
perminder-17 Apr 16, 2025
7b5d67c
fixing gridOutputs
perminder-17 Apr 16, 2025
c3851b3
fixing text-output
perminder-17 Apr 16, 2025
dac7ff2
fixing all p5.Camera text orientation
perminder-17 Apr 16, 2025
d19fefc
fixing setAttributes()
perminder-17 Apr 18, 2025
e4acb5f
fixing httpDo
perminder-17 Apr 18, 2025
9039796
fixing httpPost
perminder-17 Apr 18, 2025
63af24e
fixing print()
perminder-17 Apr 18, 2025
24763af
fixing getNum()
perminder-17 Apr 19, 2025
301d42f
Fixing rotationX(), rotationY() and rotationZ()
perminder-17 Apr 19, 2025
dd6a988
updating checkBox()
perminder-17 Apr 19, 2025
58e8746
createFileInput() orientation
perminder-17 Apr 19, 2025
25b164e
minor fixes
perminder-17 Apr 19, 2025
bf86b77
createElement fixes
perminder-17 Apr 19, 2025
289c176
fixing wording of setup() by removing preload
perminder-17 Apr 19, 2025
36b0bb0
fixing broken url
perminder-17 Apr 23, 2025
608d2fa
adding more context to docs
perminder-17 Apr 23, 2025
68dd3ae
reverting back to old p5.Geometry
perminder-17 Apr 23, 2025
cefb10b
Merge branch 'dev-2.0' into patch-9
perminder-17 Apr 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/accessibility/describe.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ function describe(p5, fn){
*
* <div>
* <code>
*
* function setup(){
* createCanvas(100, 100);
* };
*
* function draw() {
* background(200);
*
Expand All @@ -96,6 +101,11 @@ function describe(p5, fn){
*
* <div>
* <code>
*
* function setup(){
* createCanvas(100, 100);
* }
*
* function draw() {
* background(200);
*
Expand Down
21 changes: 21 additions & 0 deletions src/accessibility/outputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ function outputs(p5, fn){
*
* <div>
* <code>
*
Copy link
Contributor Author

@perminder-17 perminder-17 Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ksen0 , are these functions still broken on my branch as well i.e. After this PR?. I think I tried fixing textOutput() and gridOutput here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect there's bigger problems here because they're broken on 1.x and 2.0. I'll make a separate 1.x/2.0 issue tomorrow about it, please feel free to ignore for this PR. Thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect there's bigger problems here because they're broken on 1.x and 2.0. I'll make a separate 1.x/2.0 issue tomorrow about it, please feel free to ignore for this PR. Thank you!

Hmm, So sorry for the oversight, I think the sketch works correctly but it didn't shows up correctly in the website. I'll have a look today late night or tomorrow morning to figure out what's going on. Thanks for the patience @ksen0 :)

* function setup(){
* createCanvas(100, 100);
* }
*
* function draw() {
* // Add the text description.
* textOutput();
Expand All @@ -101,6 +106,11 @@ function outputs(p5, fn){
*
* <div>
* <code>
*
* function setup(){
* createCanvas(100, 100);
* }
*
* function draw() {
* // Add the text description and
* // display it for debugging.
Expand Down Expand Up @@ -215,6 +225,11 @@ function outputs(p5, fn){
*
* <div>
* <code>
*
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, for gridOutput() here. These are the commit links for both. Can you just confirm if it still breaks for you? " 7b5d67c " and " c3851b3 "

* function setup() {
* createCanvas(100, 100);
* }
*
* function draw() {
* // Add the grid description.
* gridOutput();
Expand All @@ -235,6 +250,11 @@ function outputs(p5, fn){
*
* <div>
* <code>
*
* function setup(){
* createCanvas(100, 100);
* }
*
* function draw() {
* // Add the grid description and
* // display it for debugging.
Expand All @@ -255,6 +275,7 @@ function outputs(p5, fn){
* </div>
*/


fn.gridOutput = function(display) {
// p5._validateParameters('gridOutput', arguments);
//if gridOutput is already true
Expand Down
4 changes: 2 additions & 2 deletions src/color/p5.Color.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ class Color {
* }
* </code>
* </div>
**/
*/
setGreen(new_green, max=[0, 1]) {
if(!Array.isArray(max)){
max = [0, max];
Expand Down Expand Up @@ -492,7 +492,7 @@ class Color {
* }
* </code>
* </div>
**/
*/
setAlpha(new_alpha, max=[0, 1]) {
if(!Array.isArray(max)){
max = [0, max];
Expand Down
8 changes: 4 additions & 4 deletions src/core/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ function environment(p5, fn){
* @method print
* @param {Any} contents content to print to the console.
* @example
* <div>
* <code class="norender">
* <div class="norender">
* <code>
* function setup() {
* // Prints "hello, world" to the console.
* print('hello, world');
* }
* </code>
* </div>
*
* <div>
* <code class="norender">
* <div class="norender">
* <code>
* function setup() {
* let name = 'ada';
* // Prints "hello, ada" to the console.
Expand Down
13 changes: 8 additions & 5 deletions src/core/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,14 @@ for (const k in constants) {
* ```
*
* Code placed in `setup()` will run once before code placed in
* <a href="#/p5/draw">draw()</a> begins looping. If the
* <a href="#/p5/preload">preload()</a> is declared, then `setup()` will
* run immediately after <a href="#/p5/preload">preload()</a> finishes
*
* <a href="#/p5/draw">draw()</a> 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.
*
Expand Down Expand Up @@ -539,7 +543,6 @@ for (const k in constants) {
* </code>
* </div>
*/

/**
* A function that's called repeatedly while the sketch runs.
*
Expand Down
16 changes: 8 additions & 8 deletions src/dom/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -593,10 +593,10 @@ 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);
* img.position(0, 10);
*
* describe('A gray square with a magenta asterisk in its center.');
* }
Expand Down Expand Up @@ -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.');
* }
Expand All @@ -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.');
* }
Expand All @@ -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.');
* }
Expand Down Expand Up @@ -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.
Expand Down
48 changes: 24 additions & 24 deletions src/events/acceleration.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,18 @@ function acceleration(p5, fn){
* @example
* <div>
* <code>
* 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)
* }
* </code>
* </div>
Expand All @@ -175,18 +175,18 @@ function acceleration(p5, fn){
* @example
* <div>
* <code>
* 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)
* }
* </code>
* </div>
Expand All @@ -209,18 +209,18 @@ function acceleration(p5, fn){
* @example
* <div>
* <code>
* 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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you for the expanded example 👍

* rotateZ(radians(rotationZ)); // Rotate around Z-axis
* normalMaterial(); // Apply simple shaded material
* box(60); // Draw 3D cube
* rotationZ = (rotationZ + 2) % 360; // Increment rotation angle
* }
* </code>
* </div>
Expand Down
6 changes: 3 additions & 3 deletions src/image/p5.Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
*
Expand Down Expand Up @@ -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);
*
Expand Down Expand Up @@ -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);
*
Expand Down
1 change: 1 addition & 0 deletions src/image/pixels.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function pixels(p5, fn){
* <code>
* function setup() {
* createCanvas(100, 100);
* background(128);
*
* // Load the pixels array.
* loadPixels();
Expand Down
33 changes: 21 additions & 12 deletions src/io/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
* });
Expand All @@ -970,8 +970,8 @@ function files(p5, fn){
* function mousePressed() {
* httpPost(
* url,
* 'json',
* postData,
* 'json',
* function(result) {
* // ... won't be called
* },
Expand Down Expand Up @@ -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]) {
Expand Down
4 changes: 2 additions & 2 deletions src/io/p5.TableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading