-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Refactor Color Code #6680
Comments
Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, please make sure to fill out the inputs in the issue forms. Thank you! |
Can I also work on this issue. |
Some of the JSDoc issues are due inconsistent variable names which is easy to fix. Others are 🤬🤯 because we often have multiple override signatures with conflicting variable names and types. JSDoc seems to only use the last signature. I haven’t figured out a way to fix this without messing up the documentation. |
There's always a tradeoff between performance and code-cleanliness when it comes to extracting things into functions, but I have some ideas where it maybe makes sense. This part of the code appears 7 times:
It could be extracted into a private function, like Even better would be to store the actual array as
There are so many places where we multiply a normalized channel value by it's corresponding value is Likewise, we could have a I could go on but I don't know if any of these justify the performance hit of additional function calls. Like there's a note in the code about something that was done specifically for performance:
Where it could be written much cleaner as:
But it seems like it was not done that way on purpose. |
As part of 2.0 RFC at #6678, I would like to rewrite the color module entirely with potentially different backwards incompatible API. The old implementation may be kept around as a bridging addon library between 1.x and 2.0 only. If the desire is to still work on refactoring this codebase I don't mind but just want to note it may not be included in the next major version. |
Increasing Access
Making the code easier to read
Most appropriate sub-area of p5.js?
Feature enhancement details
I noticed a bunch of tiny problems in src/color/p5.Color.js:
pInst and vals for example could be replaced with p5Instance and values respectively
For example,
this._array[1]
could becomethis._array[GreenLevel]
_calculateLevels()
might be broken down using a simpler method_updateLevel(level)
. In many cases only that smaller method would be called (on setRed(), setBlue(),... for example)_getMode()
,_getMaxes()
and the export default are never used, they can be removed._parseInputs()
is too long (207 lines of code) and therfore hard to readI would like to work on this issue
The text was updated successfully, but these errors were encountered: