-
-
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
[p5.js 2.0]: Color module rewrite - Culori.js/ Color.js/Texel #7374
Conversation
Color Module rewrite - findings
Project branches:
FeaturesThe following table outlines the difference between the supported color spaces. The core color spaces currently supported by p5.js (RGB, HSB/HSV, HSL) were taken as a starting point to test the integration of the libraries within the existing p5.js API.
Maintainability
Stats from: https://npmtrends.com/@texel/color-vs-colorjs.io-vs-culori Packages sizesThe p5.js Color module currently handles all the operations to convert between color spaces, as well as validating the different input formats offered to the users. The introduction of a colour library will increase the overall size of the library. The following table shows the size of every library when rendered within p5.js, as well as the Gzip size; these have been visualised using the Rollup Plugin Visualizer.
The following image shows a visual of the p5.js packages. In this visual we have an overview of texel, culori and colorjs when they have been installed within p5.js. This diagram can be replicated by running PerformanceThe performance of each library can be benchmarked against each other. One of the key attractive points of Texel is its optimisation for speed against Colorjs.io and therefore Culori, at the cost of lacking functionalities. However, a veridic performance overview of each library can only be achieved once fully integrated within the p5.js API. The current integration of each color library is partial, and some of them require extra development work to achieve conversions and readings, mainly concerning the HSB/HSV colour space. Therefore, it is necessary to further investigate the potential performance impacts of integrating new color libraries. ConclusionThe tested libraries have different ranges of complexity and performance. However, their implementation within p5.js can be summarised as:
In summary, a most immediate implementation can come from Culori as a good balance between functionality and performance. |
@dianamgalindo Thanks for the detailed research it's very helpful. I think there is a good case to implement culori with possible second options as color.js. Texel color will require quite a bit more development at the moment but we can always revisit when it is more mature. I'll probably won't merge this PR directly as it seems to contain mostly test code. I may adapt some of the proof of concept code for culori though. |
Resolves #7018
Changes:
These are ongoing changes made to the p5.js Color module in an attempt to implement the Culori.js color library.
The changes are based on the current implementation that has been given to the Color.js library on the
dev-2.0
branch.The main key differences against the existing p5.Color implementation is the removal of
colorPatterns
and_parseInputs
. These are usually replaced by pre-existing functions such asconverter
,parse
, orto
provided by the external API's (Color.js/ Culori.js)PR Checklist
npm run lint
passes