1////////////////////////////////////////////////////////////////////////////////
2//
3//  ADOBE SYSTEMS INCORPORATED
4//  Copyright 2008 Adobe Systems Incorporated
5//  All Rights Reserved.
6//
7//  NOTICE: Adobe permits you to use, modify, and distribute this file
8//  in accordance with the terms of the license agreement accompanying it.
9//
10////////////////////////////////////////////////////////////////////////////////
11
12package spark.filters
13{
14
15import flash.filters.BitmapFilter;
16import flash.filters.GradientBevelFilter;
17
18import mx.core.mx_internal;
19import mx.filters.BaseFilter;
20import mx.filters.IBitmapFilter;
21
22use namespace mx_internal;
23
24[DefaultProperty("entries")]
25
26
27/**
28 * The GradientBevelFilter class lets you apply a gradient bevel effect to
29 * display objects. A gradient bevel is a beveled edge, enhanced with gradient color,
30 * on the outside, inside, or top of an object. Beveled edges make objects look
31 * three-dimensional.
32 * You can apply the filter to any display object (that is, objects that inherit from the DisplayObject class),
33 * such as MovieClip, SimpleButton, TextField, and Video objects, as well as to BitmapData objects.
34 *
35 * <p>The use of filters depends on the object to which you apply the filter:</p>
36 * <ul><li>To apply filters to display objects, use the
37 * <code>filters</code> property. Setting the <code>filters</code>
38 * property of an object does not modify the object, and you can remove the filter by clearing the
39 * <code>filters</code> property. </li>
40 *
41 * <li>To apply filters to BitmapData objects, use the <code>BitmapData.applyFilter()</code> method.
42 * Calling <code>applyFilter()</code> on a BitmapData object takes the source BitmapData object
43 * and the filter object and generates a filtered image as a result.</li>
44 * </ul>
45 *
46 * <p>If you apply a filter to a display object, the <code>cacheAsBitmap</code> property of the
47 * display object is set to <code>true</code>. If you clear all filters, the original value of
48 * <code>cacheAsBitmap</code> is restored.</p>
49 *
50 * <p>This filter supports Stage scaling. However, it does not support general scaling, rotation,
51 * and skewing; if the object itself is scaled (if <code>scaleX</code> and <code>scaleY</code> are set
52 * to a value other than 1.0), the
53 * filter effect is not scaled. It is scaled only when the user zooms in on the Stage.</p>
54 *
55 * <p>A filter is not applied if the resulting image exceeds the maximum dimensions.
56 * In  AIR 1.5 and Flash Player 10, the maximum is 8,191 pixels in width or height,
57 * and the total number of pixels cannot exceed 16,777,215 pixels. (So, if an image is 8,191 pixels
58 * wide, it can only be 2,048 pixels high.)
59 * For example, if you zoom in on a large movie clip with a filter applied, the filter is
60 * turned off if the resulting image exceeds the maximum dimensions.</p>
61 *
62 *  @mxml
63 *  <p>The <code>&lt;s:GradientBevelFilter&gt;</code> tag inherits all of the tag
64 *  attributes of its superclass and adds no tag attributes:</p>
65 *
66 *  <pre>
67 *  &lt;s:GradientBevelFilter/&gt;
68 *  </pre>
69 *
70 * @langversion 3.0
71 * @playerversion Flash 10
72 * @playerversion AIR 1.5
73 * @productversion Flex 4
74 *
75 * @includeExample examples/GradientBevelFilterExample.mxml
76 *
77 * @see spark.filters.BevelFilter
78 * @see flash.filters.GradientBevelFilter
79 * @see #ratios GradientBevelFilter.ratios
80 * @see flash.display.BitmapData#applyFilter()
81 * @see flash.display.DisplayObject#filters
82 * @see flash.display.DisplayObject#cacheAsBitmap
83 */
84public class GradientBevelFilter extends GradientFilter implements IBitmapFilter
85{
86    /**
87     * Constructor.
88     *
89     * @param distance The offset distance. Valid values are 0 to 8.
90     * @param angle The angle, in degrees. Valid values are 0 to 360.
91     * @param colors An array of RGB hexadecimal color values to use in the gradient.
92     * For example, red is 0xFF0000, blue is 0x0000FF, and so on.
93     * @param alphas An array of alpha transparency values for the corresponding colors in
94     * the <code>colors</code> array. Valid values for each element in the array are 0 to 1.
95     * For example, .25 sets a transparency value of 25%.
96     * @param ratios An array of color distribution ratios; valid values are
97     * 0 to 255.
98     * @param blurX The amount of horizontal blur. Valid values are 0 to 255. A blur of 1 or
99     * less means that the original image is copied as is. The default value
100     * is 4. Values that are a power of 2 (such as 2, 4, 8, 16 and 32) are optimized
101     * to render more quickly than other values.
102     * @param blurY The amount of vertical blur. Valid values are 0 to 255. A blur of 1 or less
103     * means that the original image is copied as is. Values that are a power of 2
104     * (such as 2, 4, 8, 16 and 32) are optimized
105     * to render more quickly than other values.
106     * @param strength The strength of the imprint or spread. The higher the value, the more color
107     * is imprinted and the stronger the contrast between the bevel and the background.
108     * Valid values are 0 to 255. A value of 0 means that the filter is not applied.
109     *
110     * @param quality The quality of the filter. Use BitmapFilterQuality constants:
111     * <ul>
112     * <li><code>BitmapFilterQuality.LOW</code></li>
113     * <li><code>BitmapFilterQuality.MEDIUM</code></li>
114     * <li><code>BitmapFilterQuality.HIGH</code></li>
115     * </ul>
116     * <p>For more information, see the description of the <code>quality</code> property.</p>
117     *
118     * @param type The placement of the bevel effect. Possible values are BitmapFilterType constants:
119     * <ul><li><code>BitmapFilterType.OUTER</code> &#x2014; Bevel on the outer edge of the object</li>
120     * <li><code>BitmapFilterType.INNER</code> &#x2014; Bevel on the inner edge of the object</li>
121     * <li><code>BitmapFilterType.FULL</code> &#x2014; Bevel on top of the object</li>
122     * </ul>
123     * @param knockout Specifies whether a knockout effect is applied. The value <code>true</code>
124     * makes the object's fill transparent and reveals the background color of the document.
125     *
126     * @langversion 3.0
127         * @playerversion Flash 10
128     * @playerversion AIR 1.5
129     * @productversion Flex 4
130     *
131     */
132    public function GradientBevelFilter(distance:Number = 4.0, angle:Number = 45,
133                                        colors:Array = null, alphas:Array = null,
134                                        ratios:Array = null, blurX:Number = 4.0,
135                                        blurY:Number = 4.0, strength:Number = 1,
136                                        quality:int = 1, type:String = "inner",
137                                        knockout:Boolean = false)
138    {
139        super(colors, alphas, ratios);
140
141        this.distance = distance;
142        this.angle = angle;
143        this.blurX =blurX ;
144        this.blurY = blurY;
145        this.strength = strength;
146        this.quality = quality;
147        this.type = type;
148        this.knockout = knockout;
149    }
150
151    /**
152     * Returns a copy of this filter object.
153     * @return A new GradientBevelFilter instance with all the
154     * same properties as the original GradientBevelFilter instance.
155     *
156     * @langversion 3.0
157         * @playerversion Flash 10
158     * @playerversion AIR 1.5
159     * @productversion Flex 4
160     */
161    public function clone():BitmapFilter
162    {
163        return new flash.filters.GradientBevelFilter(distance, angle, colors, alphas, ratios,
164                                        blurX, blurY, strength, quality, type,
165                                        knockout);
166    }
167
168}
169}
170