Skip to content

Should p5.strands support HSB-based color construction via an optional mode parameter in color()? #8916

@LalitNarayanYadav

Description

@LalitNarayanYadav

Topic

Topic

During review of #8822, a follow-up idea came up around supporting HSB-based color construction in p5.strands without relying on colorMode().

One possible approach would be to allow an optional mode parameter in color():

color(v1, v2, v3, [alpha], [mode])

Example use case:

let h = (hue(mixed) + millis() * 0.001) % 360;
let s = saturation(mixed);
let br = brightness(mixed);

let hueShift = color(h, s, br, alpha(mixed), HSB);

Currently, p5.strands stores colors internally as normalized RGBA vec4 values and does not support colorMode(). This keeps behavior simple and predictable, but it also makes it harder to construct new colors from HSB values after extracting hue, saturation, and brightness information.

Questions worth discussing:

  • Should p5.strands support HSB-based color construction?
  • If so, should it be done through an optional mode parameter in color()?
  • Should this functionality exist only inside strands, or should it also be available in regular p5.js for consistency?
  • Are there alternative APIs that would be clearer or easier to maintain?

This is intended as a design discussion rather than a concrete implementation proposal.

Related PR: #8822

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions