Flash filter highlighted elements (as2 colormatrixfilter)

Source: Internet
Author: User

ThisCodeYes as2

 

You can use a matrix to conveniently operate colors in flash.

Colormatrixfilter is very powerful. Its package is: Import flash. Filters. colormatrixfilter;

The values of red, green, and blue channels are determined by the calculation method shown below:

Code:

Redresult = A [0] * srcr + A [1] * srcg + A [2] * SRCB + A [3] * srca + A [4]
Greenresult = A [5] * srcr + A [6] * srcg + A [7] * SRCB + A [8] * srca
+ A [9]
Blueresult = A [10] * srcr + A [11] * srcg + A [12] * SRCB + A [13] *
Srca + A [14]
Alpharesult = A [15] * srcr + A [16] * srcg + A [17] * SRCB + A [18] *
Srca + A [19]

We can see that the value of the first line determines the red value, the second line determines the green, the third line blue, and the fourth line is the transparent (alpha) channel value. We can also see that the first four columns are consistent with red, green, blue, and Alpha.
The product of the channel value, and the value in the fifth column is the sum (offset ). Note that the source and result values of each row are in the range from 0 to 255. Therefore, even if the value of each channel is less than 0 or greater than 255, it will be forced
Within the interval.

1. Black and white. Spr. Filters = [New colormatrixfilter (

[1, 0, 0, 0, 0,


1, 0, 0, 0,

1, 0, 0, 0,

0, 0, 0, 0

])]; 2. It is highlighted. Spr. Filters = [New colormatrixfilter (

[1, 0, 0, 50,


0, 1, 0, 0, 50,


0, 0, 1, 0, 50,

0, 0, 0, 0

])];

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.