Something I've been meaning to do for a while now is port our ColorMatrix class to AS3. It's a fairly simple conversion, but is still a handy utility to have on hand.
If you haven't used the ColorMatrix class before, here is the description from when we first released it in 2005:
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 to apply color adjustments. The added bonus of ColorMatrix is that it uses the same calculations to generate matrix values as the Flash 8 IDE (with the exception of contrast adjustment which uses linear interpolation to provide a bit more granularity).
Download the updated source here
Here is a quick sample of it in use. This demo is included in the download package.
Comments (10)
This class is absolutely brilliant - I've been needing a class like this for a long time. Good work!
Posted by: Dark Vyper at December 12, 2007 03:33 PMURL: http://www.fatal-exception.co.uk
Sliders would be better for demo purposes ;)
Posted by: Valters Boze at December 13, 2007 01:13 AMThanks for sharing!
URL: http://blog.valtersboze.com
Good work! This class is perfect. I've been needing a class like this.
Posted by: Maksus at December 13, 2007 02:07 AMURL: http://max.kr.ua
Great work!
Has anyone ever attempted to translate Flash color matrices to other languages?
Specifically I've got a project where we're allowing a User to modify an image within Flash but would like to accurately translate the final effect to ImageMagick for export.
Posted by: Ferris at December 13, 2007 07:19 AMURL:
This is Brad from the CN talk you gave in Atlanta. Matrix manipulation confounds me so this is really helpful. Thanks for posting it.
Posted by: brad at December 14, 2007 08:46 AMURL: http://www.bulletpattern.com
Ferris,
It should be fairly easy to translate Flash Color matrices to other languages. The only issue is that Flash uses 4x5 matrices whereas most languages use 5x5 matrices. You'll note that the ColorMatrix class actually has to "pad" the matrix to 5x5 in order to carry out matrix multiplication.
Posted by: Grant Skinner at December 17, 2007 10:14 AMURL: http://gskinner.com/blog/
Great - this class is perfect. Thanks - I'll be back soon, bye !
Posted by: Mielno at December 28, 2007 03:54 PMURL: http://www.jacek.ta.pl
Using the adjustColor class is removing any filters I had set with AS (but not the ones set on the stage) and vice versa if I re-apply the filter it strips off the color effects...any suggestions for getting around this?
Posted by: Josh at January 18, 2008 10:12 PMURL:
Oops, disregard the part about it not affecting some filters...those were unaffected becuase they were on a nested object...but any time they are applied to the same object the new effect removes the previous one.
Posted by: Josh at January 18, 2008 10:19 PMURL:
Super travail, merci !!!!
Posted by: Cyril at February 25, 2008 01:30 PMURL: