What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 131 Stack Exchange communities.

I just answered a question in which the OP basically wants a mathematical model for doing interpolation between color points in a way which would look natural to the human eye (and which presumably is not what linear interpolation would produce).

My answer was to pre-pick N colors and simply project from the initial input range to these color bands.

Which led me to wonder... how is it done here on SO?

share|improve this question
    
Can you point to a post that has comments with upvote counts in different colors? –  Gabe Apr 4 '11 at 0:15
    
@Gabe: The highest voted question (stackoverflow.com/questions/194812/…) has some variety. –  Jon Apr 4 '11 at 0:16
    
I see. The styles are "cool", "warm", "hot", and "supernova". –  Gabe Apr 4 '11 at 0:23
1  
Translate RGB to the HSL color space. Different S. It's a bit off, they probably picked them from a table. –  Uphill Luge Apr 4 '11 at 0:33

1 Answer 1

up vote 11 down vote accepted

css

.supernova {
color: #FE7A15 !important;
}

.hot {
color: #CF7721 !important;
}

.warm {
color: #9B764F !important;
}

.cool {
color: #999 !important;
}

js

// e.g. options = { min: 15, max: 300, setIsValid: function }

var max = options.max;

var css = cur > max * 0.8 ? "supernova" : cur > max * 0.6 ? "hot" : cur > max * 0.4 ? "warm" : "cool";
share|improve this answer
3  
Thanks for taking the time to dig. –  Jon Apr 4 '11 at 16:49
    
I love the shorthand if statements in the last line. –  Tom Sep 26 '12 at 16:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .