PageRenderTime 414ms CodeModel.GetById 222ms app.highlight 3ms RepoModel.GetById 188ms app.codeStats 0ms

/src/away3d/loaders/parsers/data/DefaultBitmapData.as

http://github.com/away3d/away3d-core-fp11
ActionScript | 41 lines | 35 code | 6 blank | 0 comment | 4 complexity | f1e992e8dac3f8e7546a02ab7e558012 MD5 | raw file
 1package away3d.loaders.parsers.data
 2{
 3	import flash.display.BitmapData;
 4	import flash.geom.Point;
 5	import flash.geom.Rectangle;
 6
 7	public class DefaultBitmapData {
 8		
 9		private static var _bitmapData:BitmapData;
10
11		public static function get bitmapData() : BitmapData
12		{
13			if(!_bitmapData)
14				build();
15				
16			return _bitmapData;
17		}
18		
19		private static function build() : void
20		{
21			var size:uint = 256;
22			_bitmapData = new BitmapData(size,size, false, 0xFFFFFF);
23			var i:uint;
24			var step:int = size/8;
25			var rect:Rectangle = new Rectangle(0,0,step,step);
26			for(i=0;i<4;++i){
27				_bitmapData.fillRect(rect, 0x000000);
28				rect.x += step*2;
29			}
30			rect.x = 0;
31			rect.width = _bitmapData.width;
32			var destpt:Point = new Point(0,0);
33			
34			for(i=1;i<8;++i){
35				destpt.x = (i%2 == 0)? 0 : step;
36				destpt.y = step*i;
37				_bitmapData.copyPixels(_bitmapData,rect,destpt);
38			}
39		}
40	}
41}