[p5.js 2.0 Bug Report]: [p5.strands] Ternary statements not supported?
Open
@davepagurek is already working on this.
Since Mar 11, 2026.
Area:WebGL
p5.js 2.0+
- Dominant language
- JavaScript
- Stars
- 24k
- Forks
- 3.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 25
Description
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
p5.js version
2.2.3-rc.0
Web browser and version
n/a
Operating system
n/a
Steps to reproduce this
Steps:
- Visit this sketch: https://editor.p5js.org/neill0/sketches/ZbQ9dFk7J
or run the following snippet (both tryfilterColor.set(coord.x < 0.5 ? red : green);) - observe all-red canvas (should be half green)
- observe the transpiled GLSL in console has over-simplified the code
Snippet:
const red = [1, 0, 0, 1];
const green = [0, 1, 0, 1];
const coord = filterColor.texCoord;
filterColor.set(coord.x < 0.5 ? red : green);
gets compiled to...
vec4 getColor(FilterInputs inputs, sampler2D canvasContent) {
return vec4(1.0000, 0.0000, 0.0000, 1.0000);
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.