flash on 2010-11-9
♥0 |
Line 69 |
Modified 2010-11-09 12:57:00 |
MIT License
archived:2017-03-20 02:06:26
ActionScript3 source code
/**
* Copyright h_sakurai ( http://wonderfl.net/user/h_sakurai )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/syIa
*/
package
{
import flash.display.GraphicsPathCommand;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.display.Stage;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
[SWF(width = "460", height = "300", backgroundColor = "0xFFFFFF")]
public class Index6 extends Sprite{
// 描画データ
private var vertices:Vector.<Number> = new Vector.<Number>();
private var indices:Vector.<int> = new Vector.<int>();
private var uvtData:Vector.<Number> = new Vector.<Number>();
private var bitmapData:BitmapData = new BitmapData(255,255, false, 0xff33ddff);
public function Index6():void
{
// ステージ設定
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
for(var i:int = 0; i < 16;i++) {
bitmapData.fillRect(new Rectangle(0, i*16, 255, 8),0x111111*i);
}
// 描画データセット
setDrawingData();
// 描画
render();
}
private function enterFrameHandler(e:Event):void
{
setDrawingData();
render();
}
/*----------------------------------
描画データセット
----------------------------------*/
private function setDrawingData():void
{
// 1.頂点の座標
// 左上 1
vertices[0] = 0;
vertices[1] = 0;
// 左下 2
vertices[2] = 10;
vertices[3] = 210;
// 右上 3
vertices[4] = 120;
vertices[5] = 10;
// 右下 4
vertices[6] = 220;
vertices[7] = 130;
// 右下2 5
vertices[8] = 220;
vertices[9] = 300;
// 2.描画の順番
// 左上0,右上1,右下3,左下2
indices.push(0, 1, 2, 2, 3, 1, 4, 3, 1);
// 3.テクスチャのどの部分を使うか?(0から1の間の小数点)
// 左上 u0,v0
// 左下 u0,v1
// 右上 u1,v0
// 右下 u1,v1
// 左上とひもづけ
uvtData[0] = 0;
uvtData[1] = 0;
// 左下とひもづけ
uvtData[2] = 0;
uvtData[3] = .5;
// 右上とひもづけ
uvtData[4] = 1;
uvtData[5] = 0;
// 右下とひもづけ
uvtData[6] = 1;
uvtData[7] = .5;
// 右下とひもづけ
uvtData[8] = 1;
uvtData[9] = 1;
}
/*----------------------------------
描画
----------------------------------*/
private function render():void
{
graphics.clear();
graphics.beginBitmapFill(bitmapData);
graphics.drawTriangles(
vertices, // 頂点
indices, // 描画順
uvtData // テクスチャのどの部分を使うか。
);
}
}
}