Repository navigation
Support ** in p5.strands and error on unsupported operators - #9375
Open
harshiltewari2004 wants to merge 3 commits into
Open
harshiltewari2004 wants to merge 3 commits into
harshiltewari2004 wants to merge 3 commits into
Conversation
Continuous ReleaseCDN linkPublished PackagesCommit hash: 5971e8c Previous deploymentsThis is an automated message. |
davepagurek
reviewed
Nov 14, 2026
| }).not.toThrow(); | ||
| }); | ||
|
|
||
| suite('exponentiation operator (#9252)', () => { |
Contributor
There was a problem hiding this comment.
It's probably not super important to put the PR number here; the idea is to have the code be understandable to other contributors without extra context from github.
Contributor
Author
There was a problem hiding this comment.
Makes sense, I'll drop it.
| myp5.background(0); | ||
| myp5.filter(testShader); | ||
| const c = myp5.get(25, 25); | ||
| assert.approximately(c[0], 64, 5); // 0.5 ** 2 = 0.25 -> ~64 |
Contributor
There was a problem hiding this comment.
For completeness, can we add similar tests to the webgpu module too?
Contributor
Author
There was a problem hiding this comment.
Sure, adding them now.
Contributor
Author
There was a problem hiding this comment.
Added in a29df88, same three cases using the material shader pattern, since filter shader tests are still todo on WebGPU.
davepagurek
reviewed
Nov 15, 2026
| }); | ||
|
|
||
|
|
||
| suite('exponentiation operator', () => { |
Contributor
There was a problem hiding this comment.
minor, but it looks like indentation is off here
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #9252
Changes:
replaceBinaryOperator(src/strands/strands_transpiler.js) now maps**topow, soa ** bbecomesa.pow(b). This also covers**=, since compound assignments go through the same function.StrandsNode.prototype.pow(src/strands/strands_api.js), which builds apow()function call node rather than a binary operator, since GLSL and WGSL have no**operator. This resolves the TODO.defaultcase that throws a strands error naming the operator (e.g.&,<<), instead of crashing with.undefined is not a function/reading 'startsWith'inside the transpiler. This was the second option in the issue; happy to drop it into a separate PR if you'd rather keep this one to**only.Tests (new
exponentiation operator (#9252)suite intest/unit/webgl/p5.Shader.js):v ** 2renders the same aspow(v, 2)v **= 2worksunsupported operatorAll three failed before the source change and pass after. The change is in the backend-independent transpiler, so I only added WebGL tests; happy to add WebGPU ones too.
npx vitest run: everything passes excepttest/unit/webgpu/p5.Shader.js→ "handle passing a value from a vertex hook to a fragment hook with swizzle assignment", which also fails on a cleanmain.PR Checklist
npm run lintpasses