In SASS I can do
!pink = #ff43a7 !darker_pink = !pink - #333333
I'd like to the same in ruby.
In SASS I can do
!pink = #ff43a7 !darker_pink = !pink - #333333
I'd like to the same in ruby.
Hex can be represented in ruby by prefixing your value with 0x
pink = 0xff43a7
darker_pink = pink - 0x333333
def color(hex)
"#%06x" % hex
end
.container {
color: <%= color pink %>;
border: 1px solid <%= color darker_pink %>;
}
.container {
color: #ff43a7;
border: 1px solid #cc1074;
}
The basic approach of adding/subtracting colors in Sass is nonsense and only really works when using a gray adjustment. That's why in sass 3 we now have full support of operations in the HSL domain which maps closely to the way people think about colors.
Since Sass is written in ruby so you can at least read our code to see what's going on:
Here's the Color class.
And here's the functions that operate on them.
It really is a non-trivial set of code. Why not just use sass? :P