0

I've been using the Genome2D library and wanted to create a filter that inverts all color. After reading Adobe documentation, I can't seem to figure out what's going on with the alpha channel since .rgba doesn't even seem to work.

This Genome2D code desaturates all color:

fragmentCode = "dp3 ft0.xyz, ft0.xyz, fc1.xyz";
fragmentConstants = Vector.<Number>([0.299,0.587,0.114,0]);

Following that example, I wrote this code for inverting color:

fragmentCode = "sub ft0.xyz, fc1.xyz, ft0.xyz"
fragmentConstants = Vector.<Number>([1,1,1,0]);

All of the color inverts, but the alpha channel is fully opaque in places it should be completely transparent. I'm having trouble figuring out how to copy the old alpha values from the original texture.

dinorider
  • 191
  • 10
  • I know that's not an answer neither a push into the right direction, but are you sure you want to bother with AGAL and low-level operations? In **Starling** you can invert colors of any object with a filter: http://doc.starling-framework.org/v2.3/starling/filters/ColorMatrixFilter.html#invert() BTW, you might probably look up how they did it, it's an open-source project. – Organis May 31 '18 at 19:34
  • They used a matrix transformation which varies a bit, but I appreciate the direction. I'm only bothering with this because I'm so close to the solution but can't seem to figure out one silly thing. – dinorider May 31 '18 at 20:31

0 Answers0