Testers Wanted š
p5.js version 2.4 will be ready soon. Help testing it by trying your existing sketches with the new version, or by trying out the upcoming features! This is a release candidate (RC), which means it is not yet live on the p5.js Editor. Your help with testing now will help make the release more stable!
To help with testing, you can use this starter sketch.
Or load both p5.js and WebGPU mode by adding these two script tags to your sketch:
<script src="https://cdn.jsdelivr.net/npm/p5@2.4.0-rc.1/lib/p5.js"></script>
<script src="https://cdn.jsdelivr.net/npm/p5@2.4.0-rc.1/lib/p5.webgpu.js"></script>Then load WebGPU mode in createCanvas - note the async/await, this is needed for WebGPU but not WebGL:
async function setup() {
await createCanvas(400, 400, WEBGPU);
}Testing this Release
A few features that are planned for 2.4 are still in progress. Check the changes below, test with existing sketches or by writing new sketches that use new functionality (like SVG, p5.strands instancing, or multi-material 3D models), and report any issues you find to help prepare this version for release.
What's New in 2.4
To help with testing, you don't need to test every single thing. It is very helpful to pick something you're familiar with in p5, and dig into it, especially looking for strange behavior in edge cases. You can pick any section or pull request below, and focus your testing on that.
Patches between 2.3 and 2.4
Starting with 2.3.2, we changed the release process. While work on the 2.4 release continued in the main branch, atomic patches made security updates and bugfixes available sooner. Want to help test? Check the release notes below and ensure everything from prior patches still works as expected.
- 2.3.1 This patch introduces new p5.strands features, improvements to shapes & SVG handling, and bugfixes across WebGL and WebGPU. It also renames the color space previously called HDR to P3 for accuracy.
- 2.3.2 This patch improves 2D paths and adds a loading animation to display when setup() takes a long time.
- 2.3.3 This patch release includes a security hardening measure, a couple of bugfixes, and documentation updates.
- 2.3.4 Bugfixes/CI, fixed TypeScript declarations generation
New in 2.4: SVG Support
-
@VANSH3104 added SVG import/export in #9123. Usage and examples shown in this playlist. p5.js 2.4 will support this out of the box with no additional imports needed. With thanks to @davepagurek for reviews, and @mingness for project mentorship.
-
@Danyccsf also worked on SVG-related bugfixes in #9261 and #9292
p5.strands API additions in 2.4
p5.strands is a feature in p5.js 2.x for authoring shaders using JavaScript. See: "Hello Color World" tutorial and p5.strands contribution guide. This feature in active development. New additive features added in this release:
- @aashu2006 added a simplified instancing API for p5.strands. Read more here (Starting with #8878 and #8912 which was part of 2.3.1, but with most of the work shipping in 2.4 with #8952). Thanks to @davepagurek and @eupthere for your reviews on this feature!
- @perminder-17 added transformation matrix support in #8984.
The below sketch shows these features in the t variable (a 3D transform that includes rotation and translation), and in the instances(count).box(18) line:
let myShader;
let count = 10;
function setup() {
createCanvas(200, 200, WEBGL);
myShader = buildMaterialShader(placeOnRing);
}
function placeOnRing() {
worldInputs.begin();
let angle = instanceIndex * TWO_PI / count + millis()/1000;
let t = transform3D();
t = rotateY(t, angle);
t = translate(t, 65, 0, 0);
worldInputs.position = transformPoint(t, worldInputs.position);
worldInputs.normal = transformNormal(t, worldInputs.normal);
worldInputs.end();
}
function draw() {
orbitControl();
background('purple');
lights();
directionalLight(255, 255, 255, 0, 1, 0);
directionalLight(255, 255, 255, 0, -1, 0);
ambientLight(255, 100, 0);
noStroke();
fill('pink');
shader(myShader);
instances(count).box(18);
}loadModel() in 2.4: Multi-Material Support
@Nixxx19 [added support for multi-material model support](https://nixxx19.hashnode.dev/it-started-with-a-grey-lump). This is not an API change, but a big update in `loadModel()` for `.obj` files with multiple materials. With thanks to @davepagurek for reviews, and @diyaayay for project mentorship.
- GSOC 26: multi-material model parts (obj/mtl) by @Nixxx19 in #8879
- GSOC 26: render multi-material models per part by @Nixxx19 in #8955
- GSOC 26: multi-material buildGeometry by @Nixxx19 in #9063
- GSOC 26: multi-material .mtl loading test coverage by @Nixxx19 in #9065
- GSOC 26: specular, ambient, and shininess texture maps by @Nixxx19 in #9066
- GSOC 26: custom vertex attributes in multi-material buildGeometry by @Nixxx19 in #9077
- GSOC 26: normal (bump) map support by @Nixxx19 in #9067
- GSOC 26: document multi-material and texture map support by @Nixxx19 in #9068
- GSOC 26: bumpTexture() for height maps by @Nixxx19 in #9089
- GSOC 26: keep bump map slopes correct at image edges by @Nixxx19 in #9095
- GSOC 26: multi-material audit, edge cases, and a windows path fix by @Nixxx19 in #9096
- GSOC 26: apply mtl material state to single-material models by @Nixxx19 in #9110
- Fix loadModel normalize overload validation by @xsupremeyx in #9286
Significant updates to Friendly Error System (FES) in 2.4
In #9212, @limzykenneth continued the FES rework started in #8887. The FES has been modularized and now supports translation. Finally, in #9307, @limzykenneth improved performance of FES, so it can be used for longer even as sketches get more complex.
Translations can be loaded in two ways, from a local file or from CDN. Within the same folder, the p5.js script will look for ${languageCode}.json for a file matching that name and load it as a translation string JSON, if that file cannot be found, it will then load from the JSDelivr CDN for a version we publish. If that also does not exist, no translation will be loaded and messages will be printed in the language it is written, ie. English.
In #9109, @davepagurek added experimental feature logging, which users will notice when they use SVG and p5.strands API in this release. Thanks to @Vaivaswat2244 for reviewing!
Additional FES bugfixes and documentation improvements were added by @harshiltewari2004, @bhabishnu, @aashu2006, and @sneakyfelix
Vectors and Math
In continued stabilization, vector and math operations now behave consistently across dimensions. These contributions by @mawerb @BHARATH0153 @Pranava-Pai-N @Pcmhacker-piro @dontwanttothink were reviewed by @davepagurek and @perminder-17 thank you!
- Vector lerp() function now takes in generalized dimensions by @mawerb in #8994
- fix: Vector.equals() asymmetric result when dimensions differ by @BHARATH0153 in #8999
- Fix: Handled 3X3 Matrix transpose with the custom input matrix by @Pranava-Pai-N in #9198
- Fix/issue 8924 by @solowiz398 #9009 Updated the setter method for 'x' to check to see if the length of the array is greater than 0. This condition passes for both a 1d vector and n amount of vector
- fix: allow negative divisors in p5.Vector.rem() by @Pcmhacker-piro in #9170
Security and Testing
This minor release includes substantial work on updating dependencies and build system, as well as automated tests including performance test. Additionally, based on feedback from Processing Foundation team, current p5.js maintainers, and active p5.js editor contributors, we have now created and published an updated Security Policy that includes a public incident response plan. Thanks to @perminder-17 for stewarding this update in #9298
Build, dependency, and CI updates by @limzykenneth @ulgens @Vaivaswat2244 @AmanUllah687
Automated testing improvements by @harshiltewari2004 @BhumitSahani @shakeelmohamed @michtesar, @yashgoyal0110 @Danyccsf @Pranava-Pai-N and @Shruti2110-coder
Graphics Improvements and Bugfixes
p5.strands API & Transpiler by @eupthere @davepagurek @tsumon @harshiltewari2004 @LalitNarayanYadav @bhabishnu @aashu2006
- Support strands shader variable names including double underscores by @eupthere in #8923
- Fix p5.strands assignment to property swizzles by @davepagurek in #9082
- Handle backtick strings as p5.strands uniform names by @davepagurek in #9112
- Read p5.strands callback params and body from the AST by @tsumon in #9188
- Strands matrix uniforms by @harshiltewari2004 in #9204
- Add paletteLerp for p5.strands (closes #8751) by @LalitNarayanYadav in #8817
- fix(strands): avoid aliasing phi node inputs by @bhabishnu in #9281
- fix(strands): read loop state by flat key by @bhabishnu in #9284
- Keep p5.strands transpiler output valid for comma-joined expressions by @harshiltewari2004 in #9193
- Add webgpu build back to rolldown config by @davepagurek in #9087
- Webgpu variable length buffer by @davepagurek in #9086
- Infer storage buffer element type from the typed array passed in by @aashu2006 in #9083
Rendering & Shading by @Vaivaswat2244 @Srinidhi444 @bhabishnu @skyyash
- fallback to webgl on webgpu failures by @skyyash in #9191
- fix: run canvas teardown in Renderer3D.remove() by @Vaivaswat2244 in #9162
- feat(webgl): add SEGMENTED mode for true flat shading by @Srinidhi444 in #9288
- feat: introduce KEEP_CONNECTIONS and deprecate FLAT by @Srinidhi444 in #9271
- fix: preserve vertex attributes with smooth normals by @Srinidhi444 in #9233
- fix: restore drawing context after set() by @bhabishnu in #9220
Core & Performance by @frank890417 @NalinDalal @dontwanttothink, with thanks to @davepagurek @limzykenneth @perminder-17 for reviews
- Fix 2D point() not drawn when |x| >= 256 by @frank890417 in #9210
- Fixes Large slowdown in p5.Graphics.set() compared to v1.11.x by @NalinDalal in #9014
- Interpolate colors in the current colorMode or in another specified space by @dontwanttothink in #9024
Documentation and Bugfixes
Stability improvements and bugfixes by @harshiltewari2004 @slash-init @Pcmhacker-piro @skyyash
- Terminate saveFrames() capture by frame count instead of wall-clock d⦠by @harshiltewari2004 in #9012
- fix: stop pending createCapture media streams on remove by @slash-init in #9254
- fix: revoke Blob URLs created by p5.File by @slash-init in #9155
- fix: clean up media streams in p5.remove by @slash-init in #9234
- fix(utilities): do not mutate typed arrays in shuffle() when modify is false by @Pcmhacker-piro in #9186
- fix(image): fix pixelDensity idempotence and high-DPI canvas resize by @Pcmhacker-piro in #9167
- fix: clean up instance remove lifecycle hooks by @slash-init in #9085
- fix: allow createRadio to remove element by @slash-init in #9154
- Wait for the download click instead of a fixed timeout in saveCanvas ⦠by @harshiltewari2004 in #9031
- fix early type checks for comparison/logical ops in binaryOpNode by @skyyash in #9163
Documentation improvements by @skyyash @MarsGray @Goutte @TheNetherWatcher @ksen0
* Fix typo in library submission instructions by @ksen0 in https://github.com//pull/9117 * fix dependency variable typo in explanation by @skyyash in https://github.com//pull/9102 * Revise contributor guidelines for new contributors by @ksen0 in https://github.com//pull/9090 * Update reference preview branch instructions by @MarsGray in https://github.com//pull/9021 * fix broken emoji-key links in readme by @TheNetherWatcher in https://github.com//pull/9140 * docs: show a correct approximated value for TAU by @Goutte in https://github.com//pull/9275p5.js Library is a Community Effort
Stewards & Mentors
Every PR is reviewed by at least one maintainer or steward, most of whom are volunteers. The work in this release was supported by thoughtful comments, reviews, discussions, and mentorship by @davepagurek @diyaayay @eupthere @ksen0 @limzykenneth @mingness @perminder-17 @skyyash @Vaivaswat2244. Additional special thanks to @aashu2006 @Ayush4958 @bhabishnu and @lirenjie95 for your support with reviews!
Welcome to first-time contributors! š
- @ulgens made their first contribution in #9032
- @Danyccsf made their first contribution in #9071
- @slash-init made their first contribution in #9085
- @TheNetherWatcher made their first contribution in #9140
- @yashgoyal0110 made their first contribution in #9115
- @mawerb made their first contribution in #8994
- @AmanUllah687 made their first contribution in #9073
- @sneakyfelix made their first contribution in #9165
- @Pcmhacker-piro made their first contribution in #9170
- @Shruti2110-coder made their first contribution in #9166
- @tsumon made their first contribution in #9188
- @Pranava-Pai-N made their first contribution in #9142
- @frank890417 made their first contribution in #9210
- @bhabishnu made their first contribution in #9220
- @shakeelmohamed made their first contribution in #8918
- @michtesar made their first contribution in #8993
- @Srinidhi444 made their first contribution in #9233
- @BhumitSahani made their first contribution in #9264
- @xsupremeyx made their first contribution in #9286
- @Goutte made their first contribution in #9275
- @solowiz398 made their first contribution in #9009
Full Changelog: v2.3.0...v2.4.0-rc.1