Previous Page
Next Page

Recipe 10.10. Making a Digital Negative

Problem

You want to make a digital negative from a display object.

Solution

Use a digital negative matrix and apply it with a ColorMatrixFilter object.

Discussion

You can use a digital negative matrix in conjunction with a flash.filters.ColorMatrixFilter object to apply the matrix. The digital negative matrix is as follows:

-1  0  0  0  255
 0 -1  0  0  255
 0  0 -1  0  255
 0  0  0  1  0

The following example applies a digital negative effect to a display object:

sampleSprite.filters = [new ColorMatrixFilter([-1, 0, 0, 0, 255, 0, -1, 0, 0, 255, 0, 0, -1, 0, 255, 0, 0, 0, 1, 0])];

You can also use the ascb.filters.ColorMatrixArrays.DIGITAL_NEGATIVE constant, as shown here:

sampleSprite.filters = [new ColorMatrixFilter(ColorMatrixArrays.DIGITAL_NEGATIVE)];


Previous Page
Next Page
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)