HSV color modifier

I’m trying to change a sprites hue value using a js code
Here is what I want:

I looked up in the documentation but couldn’t find something that works perfectly as I wanted.
A link or an answer would be really nice :slight_smile:

Just use a shader. Pass the hue value to it, and apply that shader to your sprite.

If you do an online search, then you’ll end up with many results, like this one:

That is not js…

Your initial post is tagged as “cocos2d-x” and “JavaScript”, implying that you’re using the cocos2d-x engine with JS, so what is stopping you from using a shader?

If you want to do the hue change in JavaScript, then just be aware that it may be slow to process if you don’t use a shader, especially if you’re planning on applying it to many textures. The RGB to HSV (or HSL) color space algorithms shown in the link I provided are exactly what you need, but you would just have to implement them yourself in JavaScript.


Hi, maybe you can refer to this document, but it’s in Chinese.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.