Skip to content

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

@nbogie

Description

@nbogie

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);
} 

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions