ColorMatrixHx


https://github.com/ConfidantCommunications/ColorMatrixHx

To install, run:

haxelib install ColorMatrixHx 1.0.0 

See using Haxelib in Haxelib documentation for more information.

README.md

ColorMatrix

This is ported from the class by GSkinner.com. Thanks!

This can be used in OpenFL or any other code which can use a similar 5x5 color transform matrix.

ColorMatrix provides a way to adjust Brightness, Contrast, Saturation and Hue based on a range of numeric values as well as multiply matrices. The ColorMatrix can then be passed into ColorMatrixFilter (OpenFL or Flash) to apply color adjustments. The added bonus of ColorMatrix is that it uses the same calculations to generate matrix values as the Flash IDE (with the exception of contrast adjustment which uses linear interpolation to provide a bit more granularity).

Example Use

var bmd = Assets.getBitmapData("photo.png").clone(); //clone is necessary to avoid destructive operations on the original data
var cm = new ColorMatrix();
cm.adjustHue(-170);
cm.adjustSaturation(-15);
var cmf = new ColorMatrixFilter( cm.value() );
bmd.applyFilter(
	bmd,
	new Rectangle(0,0,bmd.width,bmd.height),
	new Point(),
	cmf
);

var b = new Bitmap(bmd);
addChild(b);

Note: The original library directly extended the Array class, while retrieving the data now makes use of the value() function. It may be possible to make it a static extension of Array in future.

Contributors
ConfidantCommunications
Version
1.0.0
Published
3 years ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub