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

Expose "parseColor" method on style spec package #4018

Closed
lucaswoj opened this issue Jan 19, 2017 · 2 comments
Closed

Expose "parseColor" method on style spec package #4018

lucaswoj opened this issue Jan 19, 2017 · 2 comments

Comments

@lucaswoj
Copy link
Contributor

Users who want to use the function method on the style spec package sometimes need to parse colors too (see https://www.mapbox.com/mapbox-gl-js/example/data-join/). We could make their workflow easier and more consistent by exposing our implementation of parseColor on the style spec package.

cc @kronick @ryanbaumann

@tmcw
Copy link
Contributor

tmcw commented Jan 19, 2017

Just exposing this method will probably lead to some unexpected, since it uses a cache. Modifying the output will modify future output for the same input.

parseColor is a pretty thin wrapper around csscolorparser - could we recommend instead that implementors use that module?

@kronick
Copy link

kronick commented Jan 19, 2017

@tmcw good catch. Would changing it to return a deep copy of the value from the cache be a bad idea? Do we have a benchmark set up to test the performance impact of a copy? If that isn't a good route, looks like csscolorparser would do most of what we need (save for the counterintuitive math where each RGB component needs to be multiplied by alpha).

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

3 participants