root/as3/Astro/RadialBlur/src/RadialBlurFilter.as

リビジョン 1540, 3.2 kB (コミッタ: muta, コミット時期: 3 年 前)

PixelBender? のサンプル.

Line 
1 /**
2  * Copyright 2008 (c) muta
3  *
4  * http://unbland.net/
5  * http://unbland.net/blog/
6  *
7  * Licensed under the MIT License
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a copy
10  * of this software and associated documentation files (the "Software"), to deal
11  * in the Software without restriction, including without limitation the rights
12  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13  * copies of the Software, and to permit persons to whom the Software is
14  * furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included in
17  * all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25  * THE SOFTWARE.
26  */
27 package
28 {
29     import flash.display.Shader;
30     import flash.filters.ShaderFilter;
31     import flash.utils.ByteArray;
32    
33     public class RadialBlurFilter extends ShaderFilter
34     {
35         [Embed (source="RadialBlur.pbj", mimeType="application/octet-stream")]
36         private var _data:Class;
37        
38         private var _centerX:Number = 1;
39         private var _centerY:Number = 1;
40         private var _amount:Number = 1;
41         private var _rotation:Number = 0;
42        
43         public function RadialBlurFilter(
44             centerX:Number = 1, centerY:Number = 1,
45             amount:Number = 1, rotation:Number = 0):void
46         {
47             super(new Shader(ByteArray(new _data())));
48            
49             this.centerX = centerX;
50             this.centerY = centerY;
51             this.amount = amount;
52             this.rotation = rotation;
53         }
54        
55         public function get centerX():Number
56         {
57             return _centerX;
58         }
59        
60         public function set centerX(value:Number):void
61         {
62             _centerX = value;
63             setData("center", centerX, centerY);
64         }
65        
66         public function get centerY():Number
67         {
68             return _centerY;
69         }
70        
71         public function set centerY(value:Number):void
72         {
73             _centerY = value;
74             setData("center", centerX, centerY);
75         }
76        
77         public function get amount():Number
78         {
79             return _amount;
80         }
81        
82         public function set amount(value:Number):void
83         {
84             _amount = value;
85             setData("amount", amount);
86         }
87        
88         public function get rotation():Number
89         {
90             return _rotation;
91         }
92        
93         public function set rotation(value:Number):void
94         {
95             _rotation = value;
96             setData("rotation", rotation);
97         }
98        
99         /**
100          * @private
101          */
102         private function setData(name:String, ...params):void
103         {
104             shader.data[name].value = params;
105         }
106     }
107 }
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。