Giter VIP home page Giter VIP logo

Comments (3)

bgrins avatar bgrins commented on May 25, 2024

I see the point. This is tricky because the color is stored in RGB internally. So since hsl(11, 100%, 100%) converts to rgb(255,255,255) once the call to toString() happens later the data has been lost.

I can't think of an easy way to work around this off the top of my head. I'd like to avoid storing _h, _s, _l for every color, since we would potentially want to do the same thing for every color format.

from tinycolor.

hackhat avatar hackhat commented on May 25, 2024

I see the problem...and is not that easy to solve..

I think the only way is to keep hsl internally instead of RGB.

since we would potentially want to do the same thing for every color format.

I don't understand why this is bad

from tinycolor.

ephemere000 avatar ephemere000 commented on May 25, 2024

I agree with hackhat. The internal format should keep the original values passed. RGB internal representation is the worst as it does not contain any info: hue, luminescence, lightness, saturation... Everything must be converted to these systems through mapping functions.

I was animating colors and as soon as I would reach a saturation or lightness of 0 (in HSL), everything would go red (hue 0). In these cases, the RGB values are all equal, eg. rgb(64,64,64). No formula can extract back any of the original hue. Arbitrarily, tinycolor resets them to default values: 0 for hue (red).

RGB is a thing from the 90s to represent colors. It can be useful in some cases for some type of applications, but we now use other color systems to represent human perception (not LCD/CRT physical intensities). Modern applications require: luminescence, brightness, contrast, triad, complementary, themes...

RGB can't keep any original info, they don't exist in its system. I agree with hackhat, the internal representation should keep all the parameters of all the original formats that were passed. These are minuscule structures compared to other JS objects. It would still be tiny.

I realized that tinycolor is basically just a structure storing RGB values with conversion formulas. I will be looking for other tools that are more sophisticated and that represent the actual color theories.

from tinycolor.

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.