Making things move as3 Reading Notes-drawing API resume

Source: Internet
Author: User
Tags image filter in degrees

1. filter: Import flash. Filters. * package,

If a filter is applied to a display objectcacheAsBitmapThe property value is settrue. If all filters are cleared, they are restored.cacheAsBitmapThe original value. If the width or height of the result image exceeds 2880 pixels, no filter is applied. This filter supports stage scaling. However, it does not support regular scaling, rotation, and skew. If the object itself is scaled (ifscaleXAndscaleYIf it is set to a value other than 1.0), the filter will not be scaled. It scales only when you zoom in on the stage.

■ Drop shadow (projection filter)

Class Name dropshadowfilter

DropShadowFilter(distance:Number = 4.0, angle:Number = 45, color:uint = 0, alpha:Number = 1.0, blurX:Number = 4.0, blurY:Number = 4.0, strength:Number = 1.0, quality:int = 1, inner:Boolean = false, knockout:Boolean = false, hideObject:Boolean = false)

    distance:Number(Default =4.0)-The offset distance of the shadow, in pixels.

    angle:Number(Default =45)-Shadow angle: 0 to 360 degrees (floating point ).

    color:uint(Default =0)-Shadow color, in hexadecimal format0 xrrggbb. The default value is 0x000000.

    alpha:Number(Default =1.0)-Alpha transparency of the shadow color. Valid values: 0.0 to 1.0. For example,. 25 sets the transparency value to 25%.

    blurX:Number(Default =4.0)-Horizontal blur. Valid values: 0 to 255.0 (floating point ).

    blurY:Number(Default =4.0)-Vertical blur. Valid values: 0 to 255.0 (floating point ).

    strength:Number(Default =1.0)-Impression or cross-page strength. The higher the value, the deeper the color of the impression, and the stronger the contrast between the shadow and the background. Valid values: 0 to 255.0.

    quality:int(Default =1)-Number of times the filter is applied. Use bitmapfilterquality constant:

  •       BitmapFilterQuality.LOW
  •       BitmapFilterQuality.MEDIUM
  •       BitmapFilterQuality.HIGH

       inner:Boolean(Default =false)-Indicates whether the shadow is an inner shadow. ValuetrueSpecifies the inner shadow. ValuefalseSpecifies the outer shadow (shadow around the outer edge of the object ).

    knockout:Boolean(Default =false)-Application hollowing effect (true), Which will effectively make the object fill transparent and display the background color of the document. (Make the original object transparent)

    hideObject:Boolean(Default =false)-Indicates whether to hide objects. If the value istrue, Indicates that no object is drawn, and only the shadow is visible.

 

■ Blur (Fuzzy filter), blur effect can soften the details of the image.

Class Name blurfilter

Blurfilter (blurx: Number = 4.0, blury: Number = 4.0, quality: Int = 1)

   blurX:Number(Default =4.0)-Horizontal blur. Valid values: 0 to 255.0 (floating point value ).

   blurY:Number(Default =4.0)-Vertical blur. Valid values: 0 to 255.0 (floating point value ).

   quality:int(Default =1)-Number of times the filter is applied. You can use bitmapfilterquality constant to specify the quality:

  •       flash.filters.BitmapFilterQuality.LOW
  •       flash.filters.BitmapFilterQuality.MEDIUM
  •       flash.filters.BitmapFilterQuality.HIGH
  • High quality approaching Gaussian blur. For most applications, these three values are sufficient. Although you can use other values up to 15 to achieve different effects, note that the higher the value, the slower the rendering speed.

■ Glow (luminous filter) can apply luminous effects to display objects.

Class Name glowfilter

Glowfilter (color: uint = 0xff0000, Alpha: Number = 1.0, blurx: Number = 6.0, blury: Number = 6.0, strength: Number = 2, quality: Int = 1, inner: boolean = false, Knockout: Boolean = false)

color:uint(Default =0xFF0000)-Halo color, in hexadecimal format 0xRrggbb. The default value is 0xff0000.

alpha:Number(Default =1.0)-The Alpha transparency of the color. Valid values: 0 to 1. For example,. 25 sets the transparency value to 25%.

blurX:Number(Default =6.0)-Horizontal blur. Valid values: 0 to 255 (floating point ). The multiplier values (such as 2, 4, 8, 16, and 32) of 2 are optimized to display faster than other values.

blurY:Number(Default =6.0)-Vertical blur. Valid values: 0 to 255 (floating point ). The multiplier values (such as 2, 4, 8, 16, and 32) of 2 are optimized to display faster than other values.

strength:Number(Default =2)-Impression or cross-page strength. The higher the value, the deeper the color of the impression, and the stronger the contrast between the light and the background. Valid values: 0 to 255.

quality:int(Default =1)-Number of times the filter is applied. Use bitmapfilterquality constant:

  • BitmapFilterQuality.LOW
  • BitmapFilterQuality.MEDIUM
  • BitmapFilterQuality.HIGH

For more information, seequalityAttribute description.

inner:Boolean(Default =false)-Specify whether the light emitting is inner light. ValuetrueSpecify that the light is inside the light. ValuefalseSpecify that the light emitting is the outside light (the light emitting around the outer edge of the object ).

knockout:Boolean(Default =false)-Whether the object has the effect of hollowing out data. The value istrueThe filling of the object is transparent and the background color of the document is displayed.

■ Bevel (oblique filter). The oblique effect gives an object (such as a button) a three-dimensional appearance.

Class Name bevelfilter

BevelFilter(distance:Number = 4.0, angle:Number = 45, highlightColor:uint = 0xFFFFFF, highlightAlpha:Number = 1.0, shadowColor:uint = 0x000000, shadowAlpha:Number = 1.0, blurX:Number = 4.0, blurY:Number = 4.0, strength:Number = 1, quality:int = 1, type:String = "inner", knockout:Boolean = false)

distance:Number(Default =4.0)-The offset distance of the oblique angle, in pixels (floating point ).

angle:Number(Default =45)-Angle of the oblique angle, ranging from 0 to 360 degrees. // It can be imagined that the light is projected, and the light angle

highlightColor:uint(Default =0xFFFFFF)-Highlight the oblique angle,0 xrrggbb.

highlightAlpha:Number(Default =1.0)-Highlight the Alpha transparency of the color. Valid values: 0.0 to 1.0. For example,. 25 sets the transparency value to 25%.

shadowColor:uint(Default =0x000000)-Shadow color of oblique angle,0 xrrggbb.

shadowAlpha:Number(Default =1.0)-Alpha transparency of the shadow color. Valid values: 0.0 to 1.0. For example,. 25 sets the transparency value to 25%.

blurX:Number(Default =4.0)-Horizontal blur, in pixels. Valid values: 0 to 255.0 (floating point ).

blurY:Number(Default =4.0)-Vertical blur, in pixels. Valid values: 0 to 255.0 (floating point ).

strength:Number(Default =1)-Impression or cross-page strength. The higher the value, the deeper the color of the impression, and the stronger the contrast between the angle and the background. Valid values: 0 to 255.0.

quality:int(Default =1)-Quality of oblique angle. Valid values: 0 to 15, but for most applications, you can useBitmapFilterQualityConstant:

  • BitmapFilterQuality.LOW
  • BitmapFilterQuality.MEDIUM
  • BitmapFilterQuality.HIGH

The lower the values, the faster the filter is displayed. You can use other available values to achieve different effects.

type:String(Default ="inner")-Angle type. Valid value:BitmapFilterTypeConstant:BitmapFilterType.INNER,BitmapFilterType.OUTEROrBitmapFilterType.FULL.

knockout:Boolean(Default =false)-Application hollowing effect (true), Which will effectively make the object fill transparent and display the background color of the document.

■ Gradient bevel (gradient angle filter), which can apply gradient angle effects to display objects. A gradient angle is an edge with an inclined surface that is located outside the object, inside or at the top of the object. An edge with a slope gives the object a three-dimensional appearance.

Class Name gradientbevelfilter

Gradientbevelfilter (distance: Number = 4.0, angle: Number = 45, colors: array = NULL, Alphas: array = NULL, ratios: array = NULL, blurx: Number = 4.0, blury: number = 4.0, strength: Number = 1, quality: Int = 1, type: String = "inner", Knockout: Boolean = false)

distance:Number(Default =4.0)-Offset distance. Valid values: 0 to 8.

angle:Number(Default =45)-Angle, in degrees. Valid values: 0 to 360.

colors:Array(Default =null)-The RGB hexadecimal color value Array Used in the gradient. For example, the red is 0xff0000, and the blue is 0x0000ff.

alphas:Array(Default =null)-colorsThe array that corresponds to the Alpha transparency value of the color. The valid values of each element in the array are 0 to 1. For example,. 25 sets the transparency value to 25%.

ratios:Array(Default =null)-Array of the color distribution ratio; valid values: 0 to 255.

blurX:Number(Default =4.0)-Horizontal blur. Valid values: 0 to 255. If the Blur volume is less than or equal to 1, the original image is copied as is. The default value is 4. The multiplier values (such as 2, 4, 8, 16, and 32) of 2 are optimized to display faster than other values.

blurY:Number(Default =4.0)-Vertical blur. Valid values: 0 to 255. If the Blur volume is less than or equal to 1, the original image is copied as is. The multiplier values (such as 2, 4, 8, 16, and 32) of 2 are optimized to display faster than other values.

strength:Number(Default =1)-Impression or cross-page strength. The higher the value, the deeper the color of the impression, and the stronger the contrast between the angle and the background. Valid values: 0 to 255. If the value is 0, the filter is not applied.

quality:int(Default =1)-Filter quality. Use bitmapfilterquality constant:

  • BitmapFilterQuality.LOW
  • BitmapFilterQuality.MEDIUM
  • BitmapFilterQuality.HIGH

For more information, seequalityAttribute description.

type:String(Default ="inner")-Place corner effects. Possible values are bitmapfiltertype constants:

  • BitmapFilterType.OUTER-- Oblique angle on the outer edge of the object
  • BitmapFilterType.INNER-- Oblique angle on the inner edge of the object
  • BitmapFilterType.FULL-- Oblique angle at the top of the object

knockout:Boolean(Default =false)-Specify whether to apply the hollowing effect. The value istrueThe filling of the object is transparent and the background color of the document is displayed.

■ Gradient glow (gradient light filter), gradient light is a very realistic luminous effect, you can control the color gradient.

Class Name gradientglowfilter

Gradientglowfilter (distance: Number = 4.0, angle: Number = 45, colors: array = NULL, Alphas: array = NULL, ratios: array = NULL, blurx: Number = 4.0, blury: number = 4.0, strength: Number = 1, quality: Int = 1, type: String = "inner", Knockout: Boolean = false)

distance:Number(Default =4.0)-The offset distance of the Halo.

angle:Number(Default =45)-Angle, in degrees. Valid values: 0 to 360.

colors:Array(Default =null)-Defines the gradient color array. For example, the red is 0xff0000, and the blue is 0x0000ff.

alphas:Array(Default =null)-colorsThe array that corresponds to the Alpha transparency value of the color. The valid values of each element in the array are 0 to 1. For example, value. 25 sets the Alpha transparency value to 25%.

ratios:Array(Default =null)-Array of the color distribution ratio. Valid values: 0 to 255. This value defines the width percentage of the color sampling rate to 100%.

blurX:Number(Default =4.0)-Horizontal blur. Valid values: 0 to 255. If the Blur volume is less than or equal to 1, the original image is copied as is. The multiplier values (such as 2, 4, 8, 16, and 32) of 2 are optimized to display faster than other values.

blurY:Number(Default =4.0)-Vertical blur. Valid values: 0 to 255. If the Blur volume is less than or equal to 1, the original image is copied as is. The multiplier values (such as 2, 4, 8, 16, and 32) of 2 are optimized to display faster than other values.

strength:Number(Default =1)-Impression or cross-page strength. The higher the value, the deeper the color of the impression, and the stronger the contrast between the light and the background. Valid values: 0 to 255. The larger the value, the stronger the impression. If the value is 0, the filter is not applied.

quality:int(Default =1)-Number of times the filter is applied. Use bitmapfilterquality constant:

  • BitmapFilterQuality.LOW
  • BitmapFilterQuality.MEDIUM
  • BitmapFilterQuality.HIGH

type:String(Default ="inner")-Placement of filter effects. The possible value is the constant of flash. Filters. bitmapfiltertype:

  • BitmapFilterType.OUTER-- Glow on the outer edge of the object
  • BitmapFilterType.INNER-- Glow on the inner edge of the object; default value.
  • BitmapFilterType.FULL-- Glow on the top of an object

knockout:Boolean(Default =false)-Whether the object has the effect of hollowing out data. The application hollowing effect will make the object transparent and display the background color of the document. The value istrueEmpty the specified application. The default value isfalse.

■ Color matrix filter, which allows saturation change, color phase rotation, Alpha brightness, and various other effects.

Class Name colormatrixfilter

Colormatrixfilter (Matrix: array = NULL)

Matrix: 4*5 matrices,

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.

If you want to add 100 (offset) to the red channel, set a [4] to 100, for example:


Figure.The red value increases by 100

If you want to double the green channel, set a [6] to 2, for example:


Figure.Double green

If you want to make the blue color in the result image equal to the red number of the source image, set a [10] to 1, and a [12] to 0, for example:


Figure.Red indicates the blue value.

Change the imageBrightness, You need to change the same number in each color channel value. The simplest way is to set the same offset for each channel. When the offset is positive, the brightness can be reduced when the brightness is increased to negative. (Figure 8) is an example of adding brightness.


Figure.Increase brightness

You can also change the brightness proportionally by multiplying each color channel with a value, and increase the brightness by less than 1 to reduce the brightness.
To convert an image to a grayscale image based on the principle, you need to set the parts of each channel to the same value. Because there are three channels, you can multiply each channel by 0.33 and add them to get the result value. For example (figure 9)


FigureGrayscale Matrix

 

■ Convolution (Convolution filter). convolution combines the pixels of the input image with adjacent pixels to generate the image. Through convolution, you can achieve a large number of image effects, including blur, edge detection, sharpening, relief, and corner.

Class Name convolutionfilter

Convolutionfilter (MATRIXx: Number = 0, matrixy: Number = 0, matrix: array = NULL, divisor: Number = 1.0, bias: Number = 0.0, preservealpha: Boolean = true, clamp: boolean = true, color: uint = 0, Alpha: Number = 0.0) // some green parameters are most commonly used.

matrixX:Number(Default =0)-MatrixXDimension (number of columns in the matrix ). The default value is 0.

matrixY:Number(Default =0)-MatrixYDimension (number of rows in the matrix ). The default value is 0.

matrix:Array(Default =null)-Array of values used for matrix conversion. The number of items in the array must be equalmatrixX * matrixY.

divisor:Number(Default =1.0)-Divisor used in matrix conversion. The default value is 1. If the divisor is the sum of all Matrix Values, the overall color intensity of the result is flattened. If the value 0 is ignored, the default value is used.

bias:Number(Default =0.0)-Deviation of the matrix conversion result to be added. The default value is 0.

preserveAlpha:Boolean(Default =true)-falseThe value indicates that the alpha value is not retained, and convolution applies to all channels (including alpha channels ). The value istrueIndicates that only convolution is applied to the color channel. The default value istrue.

clamp:Boolean(Default =true)-For pixels outside the source image, if the value istrueIndicates that the color value at the given edge of the input image is copied, and the input image is extended along each border of the input image as needed. If the value isfalse, Indicates thatcolorAndalphaUse the colors specified in the property. The default value istrue.

color:uint(Default =0)-To replace the hexadecimal color of pixels other than the source image.

alpha:Number(Default =0.0)-Replace the Alpha color.

Here, matrix is the matrix for Convolution with the image, which is generally called a template. MATRIXx and matrixy specify the template size. For simplicity, we use the 3*3 template as an example.
The formula can be expressed as follows (for each color channel ):

dst (x, y) = ((src (x-1, y-1) * a0 + src(x, y-1) * a1....src(x, y+1) * a7 + src (x+1,y+1) * a8) / divisor) + bias

The a0-a8 is matrix [0]-matrix [8]

It can be simply understood:

A 3*3-size template overwrites the image and moves it on the image. Template center location (Matrix [4]) the pixel value of the image is the weighted sum of the nine pixel values under the template and the values of each element in the template (the sum here is the sum of each channel A, R, G, and B respectively), divide the divisor by a factor to prevent image saturation. The offset bias is added. (The boundary position is not considered .)

■ Displacement map (replacement image filter) achieves the replacement and restructuring of image pixels. The most intuitive understanding is to see the following through the water surface.

Class Name displacementmapfilter

Displacementmapfilter (mapbitmap: bitmapdata = NULL, mappoint: Point = NULL, componentx: uint = 0, componenty: uint = 0, scalex: Number = 0.0, scaley: Number = 0.0, mode: string = "Wrap", color: uint = 0, Alpha: Number = 0.0)

mapBitmap:BitmapData(Default =null)-Bitmapdata object that contains the replacement ing data.

mapPoint:Point(Default =null)-A value that contains the offset between the upper left corner of the Target Display object and the upper left corner of the mapped image.

componentX:uint(Default =0)-Specifies the color channel used in the ing image for replacement.XResult. The possible value is the bitmapdatachannel constant.

componentY:uint(Default =0)-Specifies the color channel used in the ing image for replacement.YResult. The possible value is the bitmapdatachannel constant.

scaleX:Number(Default =0.0)-Used for scaling ing CalculationXThe multiplier of the replacement result.

scaleY:Number(Default =0.0)-Used for scaling ing CalculationYThe multiplier of the replacement result.

mode:String(Default ="wrap")-Filter mode. The possible value is the displacementmapfiltermode constant.

color:uint(Default =0)-Specify the color of the replacement that exceeds the specified range. The valid range of replacement is 0.0 to 1.0. IfmodeSetDisplacementMapFilterMode.COLOR.

alpha:Number(Default =0.0)-Specify the Alpha value of the replaced application beyond the range. It is specified as the standard value between 0.0 and 1.0. For example,. 25 sets the transparency value to 25%. IfmodeSetDisplacementMapFilterMode.COLOR.

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.