Skip to content

Improve FES messages for strands color functions (#8914)#8971

Open
manju2810 wants to merge 1 commit into
processing:mainfrom
manju2810:fix/strands-color-fes-messages
Open

Improve FES messages for strands color functions (#8914)#8971
manju2810 wants to merge 1 commit into
processing:mainfrom
manju2810:fix/strands-color-fes-messages

Conversation

@manju2810

Copy link
Copy Markdown

Resolves #8914

Changes:

Three FES message improvements for strands color functions, as described in the issue:

  1. lerpColor() missing/wrong arguments — previously reported the internal mix function name instead of lerpColor. Added an explicit arg-count check in lerpColor() (src/strands/strands_api.js) so lerpColor(c, 0.5) now reports:
    lerpColor() expects 3 arguments (color1, color2, amount), but 2 were provided.

  2. lerpColor() / red() given a non-numeric value — previously threw a generic "non-numeric value" message with no indication of which function or argument caused it. lerpColor() now catches and rewrites this error to name itself and the offending argument index (e.g. lerpColor(c1, "blue", 0.5)lerpColor() received a non-numeric value for argument 2: blue). A small strandsNodeForArg helper does the same for red(), green(), blue(), and alpha() (e.g. red("blue")red() received a non-numeric value for argument 1: blue). The argument-detection logic recurses into arrays so array-based colors (e.g. [1, 0, 0, 1]) are never misreported as the bad argument.

  3. Invalid color stringcolor('#fv0a') previously threw a bare "Invalid color string" with no indication of what was invalid. src/color/p5.Color.js now includes the actual string: Invalid color string: '#fv0a'.

hue(), saturation(), brightness(), and lightness() were left as-is since the issue only called out red/lerpColor/color explicitly, but they follow the identical pattern if a maintainer wants them included too.

Screenshots of the change:

Verified manually in a browser (inside a .modify() block) — console output before/after:

  • lerpColor(c, 0.5)[p5.strands parameter validation error]: lerpColor() expects 3 arguments (color1, color2, amount), but 2 were provided.
  • red("blue")[p5.strands type error]: red() received a non-numeric value for argument 1: blue
  • lerpColor(c1, "blue", 0.5)[p5.strands type error]: lerpColor() received a non-numeric value for argument 2: blue
  • color('#fv0a')Invalid color string: '#fv0a'

PR Checklist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve FES error messages for color functions in p5.strands

1 participant