Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-color] multiplying by a percentage #24

Open
ianstormtaylor opened this issue Dec 16, 2013 · 2 comments
Open

[css-color] multiplying by a percentage #24

ianstormtaylor opened this issue Dec 16, 2013 · 2 comments

Comments

@ianstormtaylor
Copy link

hey tab, i'm mocking up a parser/converter for the color() function, and was running into an issue of not knowing how to treat the multiplication by a percentage. the most natural way to multiply i'd assume would be by a integer/float:

color(rgb(10, 10, 10) red(* 2))

but the spec says that multiplication happens with a percentage only, so would that be the percentage of the current value? aka the above would translate to:

color(rgb(10, 10, 10) red(* 20%))

aka the 20% is 2 of the red channel 10. or would it be a percentage of the possible full channel, aka a percentage of 255?

i could be way overthinking this. thanks for any help!

@ianstormtaylor
Copy link
Author

for reference, here's where i'm at: https://github.com/ianstormtaylor/css-color-function

@tabatkins
Copy link
Owner

Multiplying by a percentage follows the standard rules: just treat it like a number. red(* 20%) would be the same as red(* .2).

I should clarify this, given that adding/subtracting a percentage does indeed resolve it against the current value. Thanks for the report!

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

No branches or pull requests

2 participants