changing picture, and/or sprites color with javascript?

Hey guys,

Im wondering if its possible to manipulate the colors of pictures and sprites through javascript, and in rpg maker mv. And im not talking about switching pictures of spritesheets with premade identical assets that have a different color - but actual manipulating images.
yes and no...

What you're describing is usually called hue changes, and that involves mathematical functions to change the data.
Decades ago, when RAM and HDD storage was expensive, it was usually done in every engine because that way you could reduce the number of pictures needed for a game and still have visible changes.

However, it also needs a lot of processing power, especially when the pictures got larger.
In the last years storage got so cheap that most developers abandoned the idea of mathematical hue changes - especially the RMs remove that option in the last several engine versions, because they already have problems with lag.
It's basically an outdated technique that most programmers stay far away from for good reasons.

So if you search deep enough you should find documentation on the formulae required, and then you'll have to implement that formula to recalculate the picture data on the fly.
However, it will cost you much in CPU cycles and your game will be worse for it.
@Andar alright then i guess ill just stick to making different colored images. Thanks for the headsup!
I have to correct it a bit.
@Andar is completely right that with canvas2D rendering hue change is computationally expensive. You take a bitmap and have to recalculate data. But that's just one part of it. There is not just Canvas2D, but there's also WebGL.
Now WebGL doesn't need to recalculate anything, because it doesn't use bitmap based graphics, but vertex based graphics. Not to mention, WebGL is GPU accelerated.
You can use hue changes with WebGL without worrying about performance, because the performance cost is none. The only downside is, the support for WebGL is only around 70% as far as I know. As for mobile devices, they have so weak gpu that I cannot even play games I was able to 5 years ago when they were still rendered by flash.
@Poryg Oh interesting, ill have to check that out then. thanks for putting that out there!

Original thread: https://forums.rpgmakerweb.com/threads/changing-picture-and-or-sprites-color-with-javascript.95504/