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

programmatic equivalents of string constructors e.g. rgba #122

Closed
jslz opened this issue Aug 7, 2017 · 6 comments
Closed

programmatic equivalents of string constructors e.g. rgba #122

jslz opened this issue Aug 7, 2017 · 6 comments

Comments

@jslz
Copy link

jslz commented Aug 7, 2017

There's Color.rgb(255,255,255,0.5) which doesn't use strings, but I guess there's no Color.rgba()? Should there be non-string-parsing versions of things?

@Qix-
Copy link
Owner

Qix- commented Aug 7, 2017

I'm not sure what you mean. The main constructor accepts strings:

new Color('rgba(10, 150, 45, 0.2)')

And Color.rgb(r, g, b, a=1.0) is just a static factory method.

What are you trying to achieve?

@jslz
Copy link
Author

jslz commented Aug 7, 2017

hi, thanks, sorry for being unclear -- it confused me that Color.rgba() is not a function at all, but Color.rgb() is. Doing Color.rgb().alpha() is weird to my eyes. Dunno if that explains it any better. Basically if there's a constructor via strings, I'd expect there to be an equivalent pure-code non-string-parsing based version. I'm led to expect this since Color.rgb() exists, I think.

@Qix-
Copy link
Owner

Qix- commented Aug 7, 2017

The following should do what you're intending:

new Color({r: 10, g: 150, b: 45, alpha: 0.2});

// or

new Color([10, 150, 45, 0.2], 'rgb');

I realize now that the makeover didn't include docs. Not sure why I did that.

I do agree somewhat that the last optional value in the constructors should be an alpha value. I'll consider this for an enhancement. Thanks for bringing it up :)

@jslz
Copy link
Author

jslz commented Aug 7, 2017

thanks, cool.

@jslz jslz closed this as completed Aug 7, 2017
@Qix- Qix- reopened this Aug 7, 2017
@Qix-
Copy link
Owner

Qix- commented Aug 7, 2017

Going to keep this open so I can modify the static constructors :) You're right in that they should accept alpha.

@Qix-
Copy link
Owner

Qix- commented Apr 5, 2022

The constructors accept alpha, so perhaps this is just an issue with docs - in which case, I'm going to close in favor of #181. Please correct me if I'm mistaken somehow.

@Qix- Qix- closed this as completed Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants