BitmapDataへの描画
♥0 |
Line 28 |
Modified 2010-09-09 14:46:48 |
MIT License
archived:2017-03-20 15:20:08
ActionScript3 source code
/**
* Copyright yun ( http://wonderfl.net/user/yun )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/geHt
*/
package {
import flash.display.Sprite;
import flash.display.BitmapData;
import flash.display.Bitmap;
[SWF(width = 465, height = 465, backgroundColor = 0)]
public class BitmapDataSample extends Sprite {
private var bmpdata:BitmapData;
private var sprite:Sprite;
public function BitmapDataSample() {
// BitmapDataを作成して表示リストに追加
bmpdata = new BitmapData(465, 465, false, 0);
addChild(new Bitmap(bmpdata));
// グラフィックの作成
sprite = newFig(232, 232, 300, 0xFFFFFF);
// BitmapDataへ描画
bmpdata.draw(sprite);
}
private function newFig(cx:Number, cy:Number, size:Number, col:uint):Sprite {
// 中心(cx,cy), 幅高さsize, 色col のグラフィックを生成
var shape:Sprite = new Sprite();
shape.graphics.lineStyle(0, 0x000000, 0.3);
shape.graphics.beginFill(col);
shape.graphics.drawCircle(cx, cy, size * 0.5);
shape.graphics.drawCircle(cx, cy, size * 0.4);
var w:Number = size * 0.6;
var h:Number = size * 0.15;
shape.graphics.drawRect(cx - w/2, cy - h/2, w, h);
shape.graphics.endFill();
return shape;
}
}
}