チェンジセット 2841: as3/ALFluid
- コミット日時:
- 2009/06/24 12:28:54 (3 年前)
- ファイル:
-
- as3/ALFluid/trunk/samples/LiquidVideo/LiquidVideo.as (更新) (1 diff)
- as3/ALFluid/trunk/samples/LiquidVideo/LiquidVideo.swf (更新) (変更前)
- as3/ALFluid/trunk/samples/MariFace/MariFace.fla (更新) (変更前)
- as3/ALFluid/trunk/samples/MariFace/MariFace.swf (更新) (変更前)
- as3/ALFluid/trunk/samples/YourFace/FunnyFaceGenerator.as (追加)
- as3/ALFluid/trunk/samples/YourFace/FunnyFaceGenerator.fla (追加)
- as3/ALFluid/trunk/samples/YourFace/classes/DownloadImageThread.as (更新) (4 diffs)
- as3/ALFluid/trunk/samples/YourFace/classes/MainThread.as (更新) (8 diffs)
- as3/ALFluid/trunk/samples/YourFace/classes/UploadImageThread.as (更新) (4 diffs)
- as3/ALFluid/trunk/src/net/alumican/as3/alfluid/Melt.as (更新) (1 diff)
- as3/ALFluid/trunk/src/net/alumican/as3/alfluid/core/Fluid.as (更新) (3 diffs)
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/ALFluid/trunk/samples/LiquidVideo/LiquidVideo.as
r2715 r2841 249 249 250 250 //melt target 251 _melt = new Melt(_source, false, 20, FLUID_WIDTH, FLUID_HEIGHT , "refrect");251 _melt = new Melt(_source, false, 20, FLUID_WIDTH, FLUID_HEIGHT); 252 252 _melt.x = _video.x; 253 253 _melt.y = _video.y; as3/ALFluid/trunk/samples/YourFace/classes/DownloadImageThread.as
r2713 r2841 1 package 1 /** 2 * Licensed under the MIT License 3 * 4 * Copyright (c) 2009 alumican.net (www.alumican.net) and 5 * Spark project (www.libspark.org) 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy 8 * of this software and associated documentation files (the "Software"), to deal 9 * in the Software without restriction, including without limitation the rights 10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 * copies of the Software, and to permit persons to whom the Software is 12 * furnished to do so, subject to the following conditions: 13 * 14 * The above copyright notice and this permission notice shall be included in 15 * all copies or substantial portions of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 * THE SOFTWARE. 24 */ 25 package 2 26 { 3 27 import flash.display.BitmapData; … … 10 34 import org.libspark.thread.Thread; 11 35 36 /** 37 * DownloadImageThread 38 * 39 * @author alumican.net<Yukiya Okuda> 40 */ 12 41 public class DownloadImageThread extends Thread 13 42 { 14 43 private var _data:BitmapData; 15 44 45 /** 46 * Constructor 47 * @param data 48 */ 16 49 public function DownloadImageThread(data:BitmapData):void 17 50 { … … 19 52 } 20 53 54 /** 55 * execute function of thread 56 */ 21 57 override protected function run():void 22 58 { … … 33 69 } 34 70 71 /** 72 * set error handlers 73 * @param target 74 */ 35 75 private function _error(target:*):void 36 76 { as3/ALFluid/trunk/samples/YourFace/classes/MainThread.as
r2713 r2841 1 package 1 /** 2 * Licensed under the MIT License 3 * 4 * Copyright (c) 2009 alumican.net (www.alumican.net) and 5 * Spark project (www.libspark.org) 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy 8 * of this software and associated documentation files (the "Software"), to deal 9 * in the Software without restriction, including without limitation the rights 10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 * copies of the Software, and to permit persons to whom the Software is 12 * furnished to do so, subject to the following conditions: 13 * 14 * The above copyright notice and this permission notice shall be included in 15 * all copies or substantial portions of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 * THE SOFTWARE. 24 */ 25 package 2 26 { 3 27 import flash.display.BitmapData; … … 30 54 //------------------------------------- 31 55 32 private var _root: YourFace;56 private var _root:FunnyFaceGenerator; 33 57 private var _melt:Melt; 34 58 private var _source:BitmapData; … … 62 86 /** 63 87 * Constructor 64 */ 65 public function MainThread(root:YourFace):void 88 * @param root 89 */ 90 public function MainThread(root:FunnyFaceGenerator):void 66 91 { 67 92 _root = root; … … 72 97 73 98 //create instance 74 _melt = new Melt(_source, false, 10, 300, 300);99 _melt = new Melt(_source, false, 10, _root.target.width, _root.target.height); 75 100 76 101 //config … … 112 137 } 113 138 139 /** 140 * set events 141 */ 114 142 private function _event():void 115 143 { … … 118 146 } 119 147 148 /** 149 * upload your photo 150 * @param e 151 */ 120 152 private function _upload(e:MouseEvent):void 121 153 { 122 _uploader = new UploadImageThread( "http://127.0.0.1/crossdomain.xml");154 _uploader = new UploadImageThread(); 123 155 _uploader.start(); 124 156 _uploader.join(); … … 129 161 } 130 162 163 /** 164 * upload complete handler 165 * @param e 166 */ 131 167 private function _uploaded():void 132 168 { 133 169 var bmd:BitmapData = _uploader.content.bitmapData; 134 var ratioW:Number = 300/ bmd.width;135 var ratioH:Number = 300/ bmd.height;136 var ratio:Number = (ratioW > ratioH) ? ratioW : ratioH;170 var ratioW:Number = _root.target.width / bmd.width; 171 var ratioH:Number = _root.target.height / bmd.height; 172 var ratio:Number = (ratioW > ratioH) ? ratioW : ratioH; 137 173 _source.draw(bmd, new Matrix(ratio, 0, 0, ratio)); 138 174 … … 140 176 } 141 177 178 /** 179 * download fluid picture 180 * @param e 181 */ 142 182 private function _download(e:MouseEvent):void 143 183 { 144 184 _melt.fluidUseDecay = false; 145 185 146 var data:BitmapData = new BitmapData(360, 360, false); 147 data.draw(_root, new Matrix(1, 0, 0, 1, -70, -70), null, null, new Rectangle(0, 0, 360, 360)); 186 var w:uint = _root.target.width + 60; 187 var h:uint = _root.target.height + 60; 188 189 var data:BitmapData = new BitmapData(w, h, false); 190 data.draw(_root, new Matrix(1, 0, 0, 1, -_root.frame.x, -_root.frame.y), null, null, new Rectangle(0, 0, w, h)); 148 191 149 192 _downloader = new DownloadImageThread(data); as3/ALFluid/trunk/samples/YourFace/classes/UploadImageThread.as
r2713 r2841 1 package 1 /** 2 * Licensed under the MIT License 3 * 4 * Copyright (c) 2009 alumican.net (www.alumican.net) and 5 * Spark project (www.libspark.org) 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy 8 * of this software and associated documentation files (the "Software"), to deal 9 * in the Software without restriction, including without limitation the rights 10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 * copies of the Software, and to permit persons to whom the Software is 12 * furnished to do so, subject to the following conditions: 13 * 14 * The above copyright notice and this permission notice shall be included in 15 * all copies or substantial portions of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 * THE SOFTWARE. 24 */ 25 package 2 26 { 3 27 import flash.display.Bitmap; … … 13 37 import org.libspark.thread.Thread; 14 38 39 /** 40 * UploadImageThread 41 * 42 * @author alumican.net<Yukiya Okuda> 43 */ 15 44 public class UploadImageThread extends Thread 16 45 { 46 /** 47 * uploaded bitmapData 48 */ 17 49 public function get content():Bitmap { return _content; } 18 50 private var _content:Bitmap; 19 51 52 /** 53 * Constructor 54 * @param policyFile 55 */ 20 56 public function UploadImageThread(policyFile:String = ""):void 21 57 { … … 23 59 } 24 60 61 /** 62 * execute function of thread 63 */ 25 64 override protected function run():void 26 65 { … … 58 97 private function _setBitmap(e:Event):void 59 98 { 60 var loader:Loader = LoaderInfo(e.target).loader; 61 62 _content = loader.content as Bitmap; 99 _content = LoaderInfo(e.target).loader.content as Bitmap; 63 100 next(null); 64 101 } 65 102 103 /** 104 * set error handlers 105 * @param target 106 */ 66 107 private function _error(target:*):void 67 108 { as3/ALFluid/trunk/src/net/alumican/as3/alfluid/Melt.as
r2715 r2841 206 206 /** 207 207 * Constructor 208 * @param source 209 * @param transparent 210 * @param gridSize 211 * @param fluidWidth 212 * @param fluidHeight 213 * @param edgeMode "free" or "wrap" 208 214 */ 209 215 public function Melt( as3/ALFluid/trunk/src/net/alumican/as3/alfluid/core/Fluid.as
r2716 r2841 315 315 nr = (i == w - 1) ? 1 : (i + 1); 316 316 } 317 /* 317 318 else if (_edgeMode == "reflect") 318 319 { … … 322 323 nr = (i == w - 1) ? (i - 1) : (i + 1); 323 324 } 325 */ 324 326 else 325 327 { … … 365 367 _mapFilter.componentX = BitmapDataChannel.GREEN; 366 368 _mapFilter.componentY = BitmapDataChannel.BLUE; 367 _mapFilter.mode = DisplacementMapFilterMode.CLAMP;369 _mapFilter.mode = (_edgeMode == "wrap") ? DisplacementMapFilterMode.WRAP : DisplacementMapFilterMode.CLAMP; 368 370 _mapFilter.scaleX = magnitude; 369 371 _mapFilter.scaleY = magnitude;

