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

Add a lerp function to Color #8605

Closed
hpinkos opened this issue Feb 11, 2020 · 4 comments · Fixed by #8607
Closed

Add a lerp function to Color #8605

hpinkos opened this issue Feb 11, 2020 · 4 comments · Fixed by #8607
Labels
good first issue An opportunity for first time contributors onramping type - enhancement

Comments

@hpinkos
Copy link
Contributor

hpinkos commented Feb 11, 2020

Add Color.lerp to linearly interpolate between two colors. Similarly to https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Core/Cartesian4.js#L621

@hpinkos hpinkos added type - enhancement good first issue An opportunity for first time contributors onramping labels Feb 11, 2020
@mramato
Copy link
Contributor

mramato commented Feb 11, 2020

Just a note, for interpolating colors you usually want to do it in HSV space, not RGB. I thought we had this code somewhere in Cesium already, but it could just be a really old TODO.

@IanLilleyT
Copy link
Contributor

IanLilleyT commented Feb 11, 2020

There's an argument for either RGB or HSV lerping. Maybe it should be exposed as an option?

I'd prefer RGB lerp by default since it's faster + simpler + often good enough (doesn't need to transform to HSV space and back)

There are also some scenarios where you don't want HSV lerp, such as interpolating between two colors with large hue differences, as you would get a rainbowy result.

I already have an RGB Color.lerp on an old branch. I can PR that. Would it help to have a separate function called Color.lerpHSV which converts the RGB inputs to HSV, lerps, then converts back to RGB.

There's more advanced color lerps out there, not sure if we want to support those.

@hpinkos
Copy link
Contributor Author

hpinkos commented Feb 11, 2020

@IanLilleyT sounds good to me! We use a RGB lerp in some of our other projects, so that's mainly what I was looking for. We can add a separate lerpHSV later when we need it.

@IanLilleyT
Copy link
Contributor

@hpinkos here's the PR: #8607

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue An opportunity for first time contributors onramping type - enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants