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)