Skip to content

Color interpolation - #26

Merged
tmcw merged 1 commit into
masterfrom
color-interpolation
Oct 5, 2016
Merged

tmcw merged 1 commit into
masterfrom
color-interpolation

Conversation

@tmcw

@tmcw tmcw commented Sep 22, 2016

Copy link
Copy Markdown
Contributor

interpolation

Support an interpolation property on functions that allows
users to choose LAB or HCL color interpolation.

@tmcw tmcw mentioned this pull request Sep 22, 2016
4 of 6 tasks

@mourner mourner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! My only concern is that conversion from RGB to LAB/HCL and back is relatively expensive and will happen on every function call, even though the stops will have the same values. Can we refactor the code in a way that caches the converted colors so that the work on an actual call is limited to simple interpolation?

@tmcw

tmcw commented Sep 23, 2016

Copy link
Copy Markdown
Contributor Author

Yep, I think that's very possible. We'd still have to convert back out to RGB, so it wouldn't be zero-cost. I'll work on a second iteration.

@tmcw

tmcw commented Sep 23, 2016

Copy link
Copy Markdown
Contributor Author

55bdcb3 now translates colors on the way in and allows for an "outputFunction" that translates them on the way out. To do this we need to clone the parameters to avoid mutating it, so a JSON.parse/JSON.stringify loop. Do you think that's okay?

@lucaswoj

lucaswoj commented Sep 23, 2016 •

Copy link
Copy Markdown

Thanks for tackling this @tmcw! I like your syntax and implementation 👍

My 2¢: the word interpolation is vague in the context of a generic function library relative to what it does

interpolation is a method of constructing new data points within the range of a discrete set of known data points

vs

interpolation property on functions that allows users to choose LAB or HCL color interpolation.

What do you think about using something like colorInterpolation or colorSpace?

@tmcw

tmcw commented Sep 23, 2016

Copy link
Copy Markdown
Contributor Author

Yep, I agree. Changed interpolation to colorSpace

@lucaswoj

lucaswoj commented Oct 4, 2016

Copy link
Copy Markdown

@mourner are you ready to give this a ✅ ?

@tmcw
tmcw force-pushed the color-interpolation branch from 1476a28 to e341f80 Compare October 5, 2016 15:58
Support a `colorSpace` property on functions that allows
users to choose LAB or HCL color interpolation.
@tmcw
tmcw force-pushed the color-interpolation branch from 5add1c3 to fc98374 Compare October 5, 2016 17:02
@tmcw
tmcw merged commit 111a2b4 into master Oct 5, 2016
@tmcw
tmcw deleted the color-interpolation branch October 5, 2016 17:06
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