-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Color gradient curve #14976
Color gradient curve #14976
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At a high level, I feel like the interplay between Curve
and ColorRange
needs a bit of thought (in terms of how exactly we want to work with gradients long-term).
Separately, it seems to me like all of the concrete curvy stuff here is essentially reinventing the logic in curve::cores::EvenCore
/SampleCurve
.
Maybe the right thing to do would be to use the EvenCore
technology in helping define the ColorRange
s for these kinds of transitions and separately to have a curve constructor for any ColorRange
that spits out a Curve
over the unit interval.
Having both ColorRange
and Curve
feels a bit weird, but I'm not color-y enough to make any pronouncements about whether ColorRange
ought to be deprecated or something, so I'll leave that to other people.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this feature, but there are some changes I'd like made around trait implementations. I can't comment on interoperability with the Curve
side of Bevy as I'm not familiar with that yet.
0ac5eff
to
66d2859
Compare
I took another try to implement it. Now it's backed by a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a much better attempt, thank you for taking our feedback on board and not giving up! I have made some suggestions which should resolve your type parameter issue and make the API much cleaner to work with. I've tested this on my own machine so it should work straight away.
I also experimented with adding a FromIterator
implementation, but this cannot be done due to the fallibility of ColorCurve::new
, we'll have to wait for TryFromIterator
to be stabilised.
Excellent work!
Co-Authored-By: Zachary Harrold <zac@harrold.com.au>
@bushrat011899 Thanks for guiding me! I almost already had this at some point in time. The deal breaker for me was the let mix: fn(&T, &T, f32) -> T = <T as Mix>::mix; I guess I gave up too early 😅 Anyways: Looks sooooo much cleaner now! Thanks again! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work, glad I could help!
Another approach, if you prefer to avoid function pointers, would be to just use |
That's even better and also solves the serde flaw! |
Co-authored-by: Matty <weatherleymatthew@gmail.com>
10eefcb
to
aeca4d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useful, and a straightforward implementation. Nice work!
Objective
ColorRange
trait to interpolate linearly between two colorsn >= 1
Solution
ColorGradient
which takesn >= 1
colors and linearly interpolates between consecutive pairs of themCurve
intergration for thisColorGradient
which yields a curve struct. After that we can apply all of the cool curve adaptors like.reparametrize()
and.map()
to the gradientTesting
Showcase
Kind of related to #14971 (comment)