if statement - Comparing a color range using either hex or decimal in javascript -


i extracting main color picture, , want call different function depending on whether red, blue, green, yellow, purple etc. (the more options can have, better). able is:

if(color < maxcolorvaluered && color > mincolorvaluered) { function1(); } else { if { ..... 

where maxcolorvalue , mincolorvalue either hexadecimal or decimal color values, , values between count same rough color - specify (roughly) minimum , maximum red colors, example.

so have 2 questions: 1) can compare hexadecimals? , how? make life easier if rather decimal. 2) got handy chart giving color ranges? ordinary charts (i.e. can find on google) doing head in . . . looking @ them, i'm not 100% sure can specify range that?

basically, i'm not entirely sure doable way - have suggestions getting same end result way?

thanks in advance help.

i can answer #1. can compare hexadecimal number converting base of 10. this

var h1 = "ffff00", h2 = "ffff01";  if (parseint("0x" + h1, 16) < parseint("0x" + h2, 16) ){     console.log("h1 smaller h2"); } 

Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -