-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Find nearest color JS #2356
Find nearest color JS #2356
Conversation
.. instead of PredefinedColorPointer. COs and the database now hold the color hex int representation instead of a color id.
... and use QColor instead.
and change cue color CO name
Shade still does not work
Thank you for taking care. |
While this approach is certainly usable. I'd much rather have the API I previously outlined on Zulip in 2.3 included. I'll see how much I can do over the weekends. |
The code looks good, btw. |
@daschuer Thanks, I opened the PR here to have more visibility, so that we can discuss the API. I'll close this and open the PR to @ferranpujolcamins Repository when it's ready.
|
Yes, its primary caching purpose is for caching because I think transforming a js Map/Array into a QColor >8 times every single time we want to transform the color might be a bit wasteful of performance I also don't really see a usecase which benefits in being able to provide a different palette on every single lookup..
I would have done it in C++ because of the previously mentioned performance concerns.
This is considered by the second proposal on Zulip because it doesn't declare a namespace but a class instead. So you could create two different instances of the color object with different maps in the same script.
As I said previously, The optimization concerns might be invalid but with the current state, I am missing the type flexibility I proposed in the previous API. |
Agreed. Is there any use case for deregistering colors though? If not, we could just pass the colors in the object constructor and get rid of register/deregister functions. That would also mean we don't need to bother with the possibility that somebody registers or unregisters a color at runtime. Otherwise we'd need to check that and invalidate the cache.
The question is how costly the JS <-> C++ context switch is. I have no idea, but it could actually make it worse.
Ok. |
This approach requires scripts to have their own way of associating colors with MIDI codes (or other values). With the API @Swiftb0y proposed, the ColorMapper class would take care of that. Regarding performance, I don't think it's a big issue. However, for 2.3 we have no Map in JavaScript, but we do have QMap in C++. |
Ok, I added a I didn't add Let me know what you think. |
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'm not well versed enough in C++ to comment about the details but it looks good from a high-level point of view.
Ok, if there aren't any further comments I'll close this and open a PR for @ferranpujolcamins repo. |
Initial attempt to add lowest-distance color matching for hotcues to Mixxx (as disscussed in #2119).
This is a follow up to #2345.
Demo: https://www.youtube.com/watch?v=fj9HUyNjJAA