Skip to content

Inconsistent colorMode behavior #1459

Closed

Description

@hobzcalvin

Haven't tried other colorModes but I'm pretty sure this is a bug. Seems that if I pass 1000 the max for all HSB values, passing 1000 for the hue breaks things while passing 1000 for saturation/brightness gets me the max as I expect.

// Assume 1000 is the maximum allowed value (that is, inclusive) passed in to color() as docs suggest
colorMode(HSB, 1000, 1000, 1000, 1000);
color(0, 0, 0); // RGB is 0, 0, 0 as expected
color(0, 1000, 1000); // RGB is 255, 0, 0 as expected
color(999, 1000, 1000); // RGB is 255, 0, 1.53; ok
color(1000, 1000, 1000); // RGB is 255, 0, 255. Huh???
// So is 999 the true max allowed value?
color(0, 999, 999); // RGB is 254.745, 0.2547, 0.2547 so that's not right

Activity

  1. ecridge commented on Jun 11, 2016

    @ecridge
    Contributor

    You’re right, this is a bug. HSB colours with hue at max value are being rendered as magenta, regardless of the user-defined maximum. HSL seems to be fine.

    I’ll take a look into it.

  2. ecridge commented on Jun 11, 2016

    @ecridge
    Contributor

    The if statement in p5.ColorConversion._hsbaToRGBA didn’t take into account the fact that sector could be 6. Should be fixed now. 😅

  3. hobzcalvin commented on Jun 11, 2016

    @hobzcalvin
    ContributorAuthor

    Great; thanks for the quick response!

  4. added a commit that references this issue on Jun 15, 2016
    0492e9e
  5. lmccart commented on Jun 15, 2016

    @lmccart
    Member

    thanks both for identifying and fixing!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions