| 1 |
package org.libspark.mapchipx { |
|---|
| 2 |
import flash.display.BitmapData; |
|---|
| 3 |
import flash.display.DisplayObjectContainer; |
|---|
| 4 |
import flash.geom.Point; |
|---|
| 5 |
import flash.geom.Rectangle; |
|---|
| 6 |
|
|---|
| 7 |
/** |
|---|
| 8 |
* ... |
|---|
| 9 |
* @author KAZUMiX |
|---|
| 10 |
*/ |
|---|
| 11 |
public class ChipInfo { |
|---|
| 12 |
|
|---|
| 13 |
private var src:DisplayObjectContainer; |
|---|
| 14 |
private var srcBmd:BitmapData; |
|---|
| 15 |
private var rect:Rectangle; |
|---|
| 16 |
private var isTransparent:Boolean; |
|---|
| 17 |
|
|---|
| 18 |
public function ChipInfo(src:DisplayObjectContainer, chipWidth:uint, chipHeight:uint, isTransparent:Boolean = false) { |
|---|
| 19 |
this.src = src; |
|---|
| 20 |
this.isTransparent = isTransparent; |
|---|
| 21 |
srcBmd = new BitmapData(chipWidth, chipHeight, isTransparent); |
|---|
| 22 |
rect = new Rectangle(0, 0, srcBmd.width, srcBmd.height); |
|---|
| 23 |
update(); |
|---|
| 24 |
} |
|---|
| 25 |
|
|---|
| 26 |
public function update():void { |
|---|
| 27 |
srcBmd.fillRect(rect, 0x00000000); |
|---|
| 28 |
srcBmd.draw(src, null, null, null, rect, false); |
|---|
| 29 |
} |
|---|
| 30 |
|
|---|
| 31 |
public function pasteTo(targetBmd:BitmapData, targetPoint:Point):void { |
|---|
| 32 |
targetBmd.copyPixels(srcBmd, rect, targetPoint); |
|---|
| 33 |
} |
|---|
| 34 |
} |
|---|
| 35 |
|
|---|
| 36 |
} |
|---|