-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Lerping Color Correctly #615
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
Conversation
30fd5c3
to
25d5416
Compare
Nice code, awesome video. This is super cool! |
That video rocks, and thanks for the improvement! |
thanks!! |
Yay!! Glad I could contribute, i love this project and use p5 all the time! |
So... does processing-java do this? Should it? |
As far as I know, it does not, and yes it should! Source: Ph.D in Computer Graphics ;) -Niels On Mon, May 11, 2015 at 12:21 PM, Erik Blankinship <notifications@github.com
|
Would it be worth adding a comment about this to the source?
|
Yea I'd say it's not a crazy idea to add a comment. That being said, I @lmccart how do I add something to the docs about this? It seems like -Niels On Tue, May 12, 2015 at 5:47 AM, K.Adam White notifications@github.com
|
@njoubert Comments are stripped from the built file: Comments (and code changes) should be made to the individual module files within the source directory, where each method gets a documentation comment block (which are parsed to create the reference material). |
thanks @kadamwhite! yes, I think a comment would be great, and toward the goal of learning, let's include the video link as well. @njoubert do you want to add this? while you're at it, would you mind also making your change to the src/ rather than the lib/ file? https://github.com/processing/p5.js/blob/master/src/color/creating_reading.js#L293 |
Yup I'm adding it now! This also means my previous commit had a problem, since I didn't change the -Niels On Tue, May 12, 2015 at 9:08 AM, Lauren McCarthy notifications@github.com
|
yes this is correct, sorry I missed it last time I merged, I'll take a close look when you submit this new patch. |
RGB color values actually represent the square root of the displayed color, not the color itself. Your monitor squares all the color values before displaying it.
This means that when interpolating between two colors, one must first square the individual values before mixing, and then take the square root, as explained here: https://www.youtube.com/watch?v=LKnqECcg6Gw
I think this looks significantly better! This patch fixes lerpColor to the correct approach. Here is an example:
OLD lerpColor from rgb(0,255,0) to rgb(255,0,0)

NEW lerpColor from rgb(0,255,0) to rgb(255,0,0)
