Skip to content

Don't round values returned by colour query functions.#2062

Merged
lukeapage merged 1 commit intoless:masterfrom
seven-phases-max:not-rounded-color-queries
Jun 22, 2014
Merged

Don't round values returned by colour query functions.#2062
lukeapage merged 1 commit intoless:masterfrom
seven-phases-max:not-rounded-color-queries

Conversation

@seven-phases-max
Copy link
Copy Markdown
Member

Per #2060.
Don't round values returned by:

hue
saturation
lightness
hsvhue
hsvsaturation
hsvvalue
luma
luminance

@bassjobsen
Copy link
Copy Markdown
Contributor

I also found that red(hsv(90, 100%, 50%)) returns 63.75 where i expect an integer.

#408000; = hsv(90, 100%, 50%) and red(#408000); indeed returns 64.

Update: i found that the hsv value should be 50.2%, but also red(hsv(90, 100%, 50.2%)) gives 64.005 and not an integer

@seven-phases-max
Copy link
Copy Markdown
Member Author

@bassjobsen HSV of #408000 is actually [90, 100%, 50.19607843%] (rounded to 8 digits after .).
And not-rounded RGB of hsv(90, 100%, 50%) is [63.75, 127.5, 0]. Less rounds colour values when they output to CSS properties (going deeper than 8 bit and rendering rgb(63.75, 127.5, 0) instead of #408000 would not make much sense). So I don't see any issue in this case.

In other words:

@c: hsv(90, 100%, 50%); // color object = rgb(63.75, 127.5, 0)
r: red(@c);             // "some" floating point number
c: @c;                  // CSS color value = #408000

lukeapage added a commit that referenced this pull request Jun 22, 2014
Don't round values returned by colour query functions.
@lukeapage lukeapage merged commit 9e323a4 into less:master Jun 22, 2014
@seven-phases-max seven-phases-max deleted the not-rounded-color-queries branch June 22, 2014 10:34
@bassjobsen
Copy link
Copy Markdown
Contributor

@seven-phases-max, thanks for your clear explanation. In that case at least the docs don't seem to be correct.

http://lesscss.org/functions/#color-channel-red:, returns an integer 0-255.

In the code for instance hsvhue does a color.toHSV() first. For red() the color object is not "cast" to a rgb object which only can contain integers.

@seven-phases-max
Copy link
Copy Markdown
Member Author

Yes, the documentation may be not always up-to-date.

For red() the color object is not "cast" to a rgb object which only can contain integers.

Color object is an RGB object and it may contain non-integer values actually:

r: red(rgb(1.23, 0, 0)); // = 1.23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants