v2.3.1-rc.2
Pre-releaseWhat's Changed
Testers Wanted 💚
p5.js version 2.3.1 is almost ready, 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.3.1-rc.2/lib/p5.js"></script>
<script src="https://cdn.jsdelivr.net/npm/p5@2.3.1-rc.2/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);
}Some things to test in your sketches:
- Code updates touched these functions, so please test that they behave as usual / as expected: loading SVG files and bad URLs with
loadImage(), applyingtint()to images in 2D mode, framebuffers with custom pixel densities,orbitControl()after swiping outside the canvas,mouseIsPressedbehavior after clicking DOM elements, andline(),point(),triangle(),quad(),rect()(including with rounded corners, like in the example below) - In shaders and p5.strands code there have been feature additions and bugfixes:
randomGaussian()andcolor()inside p5.strands shader code,instanceIndexfor instanced rendering,TRIANGLE_FANdrawing in both WebGL and WebGPU, custom shaders that setuSamplerviasetUniform(), hooks that return objects should work, custom shaders should be able to use version directives,mouseXandwidthin instance mode with p5.strands shaders
If anything breaks or looks off, please report it on GitHub!
Warning
This release renames the color space previously called HDR to P3 for accuracy. If you use HDR color space constants in your code, please update them to P3. The maintainers felt this correction was important to make now. If you have concerns about backward compatibility, you can share them on the linked pull request discussion.
What's new
randomGaussian() is available in p5.strands code - see the static example in the starter sketch or below, which also shows more p5.js-style, beginner-friendly colors are also available.
- Add p5.strands support for randomGaussian() by @harshiltewari2004 in #8800
- Replace randomness-related noise usage in strands example by @VikasKSingh05 in #8824
- feat(strands): add color() support for beginner-friendly color inputs by @LalitNarayanYadav in #8822
- Add instanceIndex alias for instanceID by @aashu2006 in #8912
- fix builtin global accessors for instance mode in strands shaders by @aashu2006 in #8878
// This sketch uses an unreleased version of p5.js
// github.com/processing/p5.js/releases/tag/v2.3.1-rc.2
// Thanks for testing 💚
async function setup() {
//for normal 2D or WEBGL stuff
createCanvas(400, 400, WEBGL);
//for WEBGPU stuff
// await createCanvas(400, 400, WEBGPGU);
myShader = buildMaterialShader(myShaderBuilder);
}
function myShaderBuilder(){
finalColor.begin();
let coord = finalColor.texCoord;
// color() and randomGaussian() available in p5.strands
let c = color('#eeff22');
finalColor.set([c.r, c.g, c.b, randomGaussian()*0.1 + 0.3]);
finalColor.end();
}
function draw() {
stroke(255);
background("#f1678e");
shader(myShader);
orbitControl();
// rect with rounded corners
rect(-50, -50, 100, 100, 50, 10);
translate(0,0,50);
rect(-50, -50, 100, 100, 3);
translate(0,0,50);
rect(-50, -50, 100, 100, 0, 20, 30, 20);
translate(0,0,50);
rect(-50, -50, 100, 100);
}Custom shader bugfixes
- Fix WebGL shader version regex by @eupthere in #8857
- fix: preserve user-set uSampler uniform for custom shaders by @BHARATH0153 in #8869
Ongoing work on shapes & SVG
- fix : other shape use the shape class also add new roundrect Primitive by @VANSH3104 in #8899
- Fix
loadImageSVG file loading regression by @gfrancine in #8937
Other bugfixes
- Fix memory leak on loadImage failure by @gfrancine in #8958
- Fix framebuffer texture size clamping using wrong pixel density by @NalinDalal in #8964
- Fix TRIANGLE_FAN immediate mode support by @davepagurek in #8974
- fix: convert tint to RGBA array in _getTintedImageCanvas by @SarthakRawat-1 in #8934
- Fix orbitControl() breaking after touch swipe outside canvas. by @perminder-17 in #8863
- Fix object returns in p5.strands hooks by @davepagurek in #8950
- fixing-mouseClick by @perminder-17 in #8917
What's Changed 🎊
- Rename HDR to P3 by @limzykenneth in #8975
- Add shader examples to trigonometric functions by @SOUMITRO-SAHA in #8801
- Mark private methods as private by @ksen0 in #8854
- note strokeweight isn't scaled in webgl/webgpu by @Nixxx19 in #8850
- feat: add friendly error for cross-hook property access (#8813) by @BHARATH0153 in #8862
- Expose dimensions property on Vector by @ksen0 in #8874
- fix: correct textToContours and textToModel reference documentation (#8623) by @gourijain029-del in #8626
- Update 2.x top level docs to match main by @ksen0 in #8892
- Stewards workflow in main by @ksen0 in #8906
- Add shader examples for math functions by @SOUMITRO-SAHA in #8802
- Add friendly FES error for dimension mismatch on shared variable assi… by @harshiltewari2004 in #8823
- Update release workflow to check for prerelease by @ksen0 in #8956
- docs: add gfrancine as a contributor for code by @allcontributors[bot] in #8959
- docs: add slash-init as a contributor for bug by @allcontributors[bot] in #8967
New Contributors
- @VikasKSingh05 made their first contribution in #8824
- @BHARATH0153 made their first contribution in #8862
- @gourijain029-del made their first contribution in #8626
- @SarthakRawat-1 made their first contribution in #8934
- @gfrancine made their first contribution in #8937
Full Changelog: v2.3.0...v2.3.1-rc.1