root/as3/PotrAs/samples/potras/algorithm/TraceTest.as

リビジョン 86, 1.3 kB (コミッタ: nitoyon, コミット時期: 5 年 前)

initial version

Line 
1 package
2 {
3         import com.nitoyon.potras.*;
4         import flash.display.*;
5         import flash.geom.*;
6         import flash.events.*;
7
8         [SWF(width="320",height="320")]
9         public class TraceTest extends Sprite
10         {
11                 [Embed(source='data1.gif')]
12                 private var Data1:Class;
13
14                 private static const SCALE:int = 8;
15
16                 public function TraceTest():void
17                 {
18                         var bmp:Bitmap = new Data1();
19                         bmp.scaleX = bmp.scaleY = SCALE;
20                         addChild(bmp);
21
22                         var pathList:Array = PathList.create(bmp.bitmapData);
23                         trace(pathList[0].priv.join("\n")  + "\n\n");
24                         trace(pathList[1].priv.join("\n")  + "\n\n");
25                        
26                         var i:int = 0;
27                         var j:int = 0;
28
29                         var bmdOver:BitmapData = new BitmapData(bmp.bitmapData.width, bmp.bitmapData.height);
30                         var bmpOver:Bitmap = new Bitmap(bmdOver);
31                         bmpOver.scaleX = bmpOver.scaleY = SCALE;
32                         bmpOver.alpha = 0.5;
33                         addChild(bmpOver);
34
35                         addEventListener("enterFrame", function(event:Event):void
36                         {
37                                 var pt:Point = pathList[i].priv[j] as Point;
38                                 bmdOver.setPixel32(pt.x, pt.y, 0xffff0000);
39
40                                 if(++j >= pathList[i].priv.length)
41                                 {
42                                         i++;
43                                         j = 0;
44
45                                         if(i >= pathList.length)
46                                         {
47                                                 i = 0;
48                                                 bmdOver.fillRect(new Rectangle(0, 0, bmdOver.width, bmdOver.height), 0xffffffff);
49                                         }
50                                 }
51                         });
52                 }
53         }
54 }
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。