Tumetsu
Tumetsu

Reputation: 1721

How to change hue with ColorMatrixFilter in AS3

At the moment my game looks something like this: https://i.sstatic.net/nDerE.jpg

I want to change the hue of background squares so that each level would have different color. I did some research and figured out that I could use ColorMatrixFilter for this. I managed to get code like this to work, which changes the hue:

var matrix:Array = new Array();
        matrix = matrix.concat([1, 1, 1, 0, 0]); // red
            matrix = matrix.concat([0, 1, 0, 0, 0]); // green
            matrix = matrix.concat([0, 0, 1, 1, 0]); // blue
            matrix = matrix.concat([0, 0, 0, 1, 0]); // alpha

           back.applyFilter(koe, new Rectangle(0, 0, 640, 480), new Point(0, 0), new ColorMatrixFilter(matrix));

However, what I didn't figure out was how exactly the matrix works and how I could get hue value from Photoshop for example and insert it to the matrix, or tween hue from -180 to 180. Like for example, in Photoshop, I can use slider to set "Hue" to to +87 to get desired color.

So how exactly I can insert the Hue value which Photoshop or other image software gives me to this matrix?

Upvotes: 0

Views: 1871

Answers (1)

fsbmain
fsbmain

Reputation: 5267

You can use ColorMatrix utility class by Grant Skinner the adjustHue method

Upvotes: 2

Related Questions