Skip to content

[css-color-4] Hue "longer" handling when hues resolve to the same #7147

@facelessuser

Description

@facelessuser

A discrepancy with "longer" hue handling was noticed in Color.js regarding its hue handling and the CSS spec. The conversation seemed to converge on the CSS specification maybe not handling this case correctly.

The current spec specifies longer as this:

if (0 < θ₂ - θ₁ < 180) {
  θ₁ += 360;
}
else if (-180 < θ₂ - θ₁ < 0) {
  θ₂ += 360;
}

This seems to work fine in all cases except when θ₁ and θ₂ end up being identical. Cases like with 0deg and 360deg or 180deg and 540deg.

During discussions, it seems that maybe these cases were not being handled correctly. It also seems that a more descriptive approach as to the intent is needed as well to clear up confusion:

svgeesus commented [21 hours ago]color-js/color.js#136 (comment))
I think an issue should be raised on CSS Color 4:

  • each hue fixup method should have a textual description, not just a bunch of mathematics, and
  • the longer one has no reason for a discontinuity. The result is either 0, or it is 180 to 359.9999 which makes no sense as being the "longer" way round. Instead it should be 180 to 360.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions