chrisbra / Colorizer

color hex codes and color names
550 stars 31 forks source link

colorizing hsl() and rgb() #9

Closed teschmitz closed 12 years ago

teschmitz commented 12 years ago

So far I have only been using hex colour codes and it is a real joy working with CSS now!

To-day, I used hsl() for the first time and the colourization doesn't seem correct or am I doing something dumb?

024d75 = hsl(201,97%,23%) = rgb(2,77,117)

The hex code and rgb() give me the right shade of blue. But hsl() gives me a shade of purple.

teschmitz commented 12 years ago

easily fixed: divide h by 360, not 255!

function! s:hue2rgb(m1, m2, h) " let h = (a:h + 0.0)/255 let h = (a:h + 0.0)/360

teschmitz commented 12 years ago

Also: should ColorHSLValues not return str rather than a:val? Maybe I am not understanding the purpose of this function?

chrisbra commented 12 years ago

On Fri, May 4, 2012 22:09, teschmitz wrote:

So far I have only been using hex colour codes and it is a real joy working with CSS now!

To-day, I used hsl() for the first time and the colourization doesn't seem correct or am I doing something dumb?

024d75 = hsl(201,97%,23%) = rgb(2,77,117)

The hex code and rgb() give me the right shade of blue. But hsl() gives me a shade of purple.

Thanks for the feedback. I look into it.

regards, Christian

teschmitz commented 12 years ago

I just noticed another minor issue with hsl/rgb functions:

When used in a comment, for example:

The colourization goes to the last closing bracket on that line. (greedy matching); I think it's in StripParantheses(val)

teschmitz commented 12 years ago

I have just spent absolutely ages trying to figure out what the problem with the following HSL colour definition is:

hsl( 81, 89, 36)

This is should have been green but was displayed as red #AE0A0A, which is the same as hsl(0,89,36).

The problem was caused by the space between the open parenthesis and 81. Whenever the hue is preceded by a space it is scanned in as zero.

Remove the space and the colour display is correct (with my fix from post #2 applied). The spaces in front of the other two parameters don't cause problems.

chrisbra commented 12 years ago

Hi teschmitz!

On Mo, 07 Mai 2012, teschmitz wrote:

I have just spent absolutely ages trying to figure out what the problem with the following HSL colour definition is:

hsl( 81, 89, 36)

This is should have been green but was displayed as red #AE0A0A, which is the same as hsl(0,89,36).

The problem was caused by the space between the open parenthesis and 81. Whenever the hue is preceded by a space it is scanned in as zero.

Remove the space and the colour display is correct (with my fix from post #2 applied). The spaces in front of the other two parameters don't cause problems.

Thanks for that many feedback. I think I fixed all 3 issues, you raised in this ticket. Please try latest head.

regards,

Christian

Wer nicht auf seine Weise denkt, denkt überhaupt nicht. -- Oscar Wilde

teschmitz commented 12 years ago

All above issues fixed.

But while you're at it, her's another: it doesn't like a space between the function name and the open bracket, for example:

hsl (89,81,37) will not be colourized.

chrisbra commented 12 years ago

On Mon, May 7, 2012 22:28, teschmitz wrote:

All above issues fixed.

But while you're at it, her's another: it doesn't like a space between the function name and the open bracket, for example:

hsl (89,81,37) will not be colourized.

Thanks, this should also be fixed now.

regards, Christian

teschmitz commented 12 years ago

All working.