-
Notifications
You must be signed in to change notification settings - Fork 13
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
Update Alpha Setting for Color #547
Conversation
src/Effects.js
Outdated
@@ -58,6 +58,11 @@ module.exports = class Effects { | |||
return p5.lerpColor(p5.color(prev), p5.color(next), remainder); | |||
}; | |||
|
|||
/* Given a p5.Color object, creates a new color object with the given alpha value*/ | |||
const setAlphaForColor = (color, alpha) => { | |||
return p5.color(color._getRed(), color._getGreen(), color._getBlue(), alpha); |
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.
Can we use p5.red(color)
etc. here?
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.
Looks good! Is there any perf downside of calling p5.color()
every frame? I noticed a small slowdown in the Disco Ball effect, but that could've been because we're parsing a hex color (vs. passing in r/g/b/a args).
Codecov Report
@@ Coverage Diff @@
## master #547 +/- ##
==========================================
+ Coverage 34.45% 34.48% +0.03%
==========================================
Files 23 23
Lines 3381 3378 -3
==========================================
Hits 1165 1165
+ Misses 2216 2213 -3
Continue to review full report at Codecov.
|
@joshlory How bad was the performance degradation? I can definitely understand that this change would cause that and depending on the impact, it might be worth exploring an alternative workaround. |
I think Disco Ball is our slowest effect, but I'm not sure how much of that is |
Issue: #522
To set the alpha of the palette colors in the rainbow, I previously accessed the array of RGBA values in the p5.Color object. This update removes that 'hacky' method and instead creates a new p5.color object with the same RGB values as the old color and a manually set alpha value.