Coder Social home page Coder Social logo

Comments (4)

overclokk avatar overclokk commented on May 20, 2024 1

I just created a pull-request with a fix for this issue, it simply normalizes the negative value for the hue.

from color.

freekmurze avatar freekmurze commented on May 20, 2024 1

Thanks for the PR! 🙌

from color.

overclokk avatar overclokk commented on May 20, 2024

I just found another conversion issue from hsl to hex or rgb but I think it's better to open another issue for that.

from color.

horuskol avatar horuskol commented on May 20, 2024

The maths used for HEX/RGB to HSL conversion does sometimes output a negative value for hue, but hsl(354, 70%, 54%) and hsl(-6, 70%, 54%) will produce the same shade of red on display. Because of the cyclic nature of hue, values like 714 and -366 would also be equivalent.

However, the hue could be normalised before being so that it is always between 0 and 360.

while ($hue < 0) {
    // can sometimes be negative
    $hue += 360;
}

while ($hue > 360) {
  // I don't think this is likely, but for balance
  $hue -= 360;
}

edit: I just saw that the markdown preview for hsl(-6, 70%, 54%) didn't work. Interesting. So far I've never had a problem with negative hue whenever I've used it.

from color.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.