Closed snird closed 10 years ago
OK, thanks for the info. I'm looking at the Sass implementation here and their examples seem to match the current behavior: https://github.com/nex3/sass/blob/fda58a6c342afc3f6ba87fbfc0158cb1a00a768f/lib/sass/script/functions.rb#L897-L914. There are also more test cases here - I haven't ran them all to make sure it conforms: https://github.com/nex3/sass/blob/fda58a6c342afc3f6ba87fbfc0158cb1a00a768f/test/sass/functions_test.rb#L441-L449.
Here is the code I've run to compare with their comment:
tinycolor.lighten("hsl(0, 0%, 0%)", 30).toHslString()
"hsl(0, 0%, 30%)"
tinycolor.lighten("#800", 20).toHexString()
"#ee0000"
yes, you are right. the sass
implementation is the same as yours, my mistake.
but there is some reason to implement the brighten
function I suggested IMO, this technique yields somewhat different results and when working with another library somewhere else, which uses this technique, it might be useful to have this as well in tinycolor.
@bgrins to add to this, lighten
tweaks the color in two dimensions (saturation and lightness), while brighten
only works on the lightness attribute.
Agree that the new brighten
function could be useful on its own.
@bgrins to add to this, lighten tweaks the color in two dimensions (saturation and lightness), while brighten only works on the lightness attribute.
@Radagaisus Sounds like you have the terms backwards here, right? lighten
just changes the lightness in HSL space whereas brighten
as implemented in #40 is working in RGB space and just increases all 3 components equally.
ok, this is quite tricky, at first I thought you had a bug in your
lighten
function but it appears to be just right to the "standard": http://en.wikipedia.org/wiki/HSL_and_HSV#Lightness but what I was really looking for wasbrighten
function (according to the wikipedia page). given the hex code of black#000000
brighten by 50% should be#7f7f7f
(whilelighten
gives back#808080
) here, this tool: hexcolortool.com uses lighten like this. thebrighten
function is the "standard"lighten
function in many places, for example insass
(which is why I was confused) and many, many standard libraries (e.g, even the Java library: http://www.java2s.com/Code/Java/2D-Graphics-GUI/Lightensacolorbyagivenamount.htm )brighten
function is really necessary, and should be explained to differentiate from the currentlighten
IMO. thanks.