Image programming in actionscript3 games)

Source: Internet
Author: User

Total Directory: http://blog.csdn.net/iloveas2014/article/details/38304477

4.5.3 distance-based weighted average matrix

Now, let's test the round fuzzy matrix. For the 3*3 matrix, the top, bottom, and center five points are 1.4, the element on the four corners of the matrix is 1, which is calculated based on the distance from the convolution point to the center point. This rule is still applicable to the matrix of its cube size, so we implement this algorithm in the array loop of getconfilter:

 

Private function getconfilter (matrixsize: int, bias: Number = 0, preservealpha: Boolean = true, clamp: Boolean = true, color: uint = 0, Alpha: Number = 0 ): convolutionfilter {var amount: Int = matrixsize * matrixsize; var divisor: Number = 0; // because the element value of the matrix is no longer equal to 1, you cannot directly use matrixsize * matrixsize to obtain divisorvar arr: array = []; for (var I: Int = 0; I <amount; I ++) {var MATRIXx: Int = I % matrixsize; // the x-axis of the matrix (number of rows) vaR matrixy: Int = I/matrixsize; // The X coordinate of the matrix (number of rows) var disx: Int = MATRIXx-matrixsize; var DISY: Int = matrixy-matrixsize; VaR value: number = math. max (0, matrixsize-math. SQRT (disx * disx + DISY * DISY); // if the distance is greater, the less colors you want to obtain. If the distance is greater than 10, the ARR [I] = value is not used; divisor + = value; // accumulate to divisor} return New convolutionfilter (matrixsize, matrixsize, arr, divisor * 0.5, bias, preservealpha, clamp, color, alpha );}

 

Because the corner points larger than the matrixsize are no longer involved in the calculation, you can no longer see the square at the corner. Of course, the phenomenon of scum still exists (Figure 4.57 ), in fact, this kind of scum can also be described in professional terms. It is called the zhenling phenomenon (like the feeling of the sound body vibration, such as Bell and audio nose ).

 

Figure 4.57 Effect of switching to a circle Matrix

Image programming in actionscript3 games)

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.