processing / processing/p5.js

[p5.js 2.0 Bug Report]: [p5.strands] Ternary statements not supported?

Open
#8,636 0 comments 0 reactions 1 assignee View on GitHub

@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:
  1. Visit this sketch: https://editor.p5js.org/neill0/sketches/ZbQ9dFk7J
    or run the following snippet (both try filterColor.set(coord.x < 0.5 ? red : green); )
  2. observe all-red canvas (should be half green)
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.