Convert RGB to ColorName String Javascript

前端 未结 6 1490
心在旅途
心在旅途 2020-12-11 05:45

I want to find out if a DOM Element has a style which is for example a color:Red. If this is defined on the inline style just like



        
相关标签:
6条回答
  • 2020-12-11 06:03

    Here is the library that will do it: Name That Color - http://chir.ag/projects/name-that-color/

    0 讨论(0)
  • 2020-12-11 06:10

    Checkout this project https://github.com/evansque/coloraze and here is the node module for it https://www.npmjs.com/package/coloraze

    0 讨论(0)
  • 2020-12-11 06:12

    Check out the https://www.w3schools.com/lib/w3color.js conversion script. It is very comprehensive, converting between named colors, hex, hsl, hwb, cmyk, and ncol

    0 讨论(0)
  • 2020-12-11 06:13

    There's a sample function you could call in this answer:

    Javascript function to convert color names to hex codes

    It does a conversion from the name to the hex value.

    0 讨论(0)
  • 2020-12-11 06:24

    A color name to RGB converter look up table will help, start here: http://web.njit.edu/~walsh/rgb.html.
    On the other hand someone might have build it before, so try to google it: https://encrypted.google.com/search?num=100&q=SlateGray1+SlateGray2+inurl%3A.js

    0 讨论(0)
  • 2020-12-11 06:26

    I think that these are the names supported in most browsers, you could store them in a dictionary and look them up: http://www.febooti.com/products/iezoom/online-help/html-color-names-x11-color-chart.html

    The x11 color names are a superset of the ones defined in css.

    0 讨论(0)
提交回复
热议问题