/**
* Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/sKk8
*/
package {
import flash.display.StageQuality;
import flash.events.Event;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
stage.quality = StageQuality.LOW;
var i:int; var num:int;
vecFace = new Vector.<int>(maxTri*3, false);
vecVert = new Vector.<Number>(maxTri*9, false);
num = vecFace.length;
for(i=0;i<num;i+=1) { vecFace[i] = i; }
stage.addEventListener(Event.ENTER_FRAME, onEnter);
}//ctor
public var itRend:int =0;
public var maxTri:int = 4096; //1024;
public var vecFace:Vector.<int>;
public var vecVert:Vector.<Number>;
public function addTri(x0:Number,y0:Number,z0:Number,
x1:Number,y1:Number,z1:Number, x2:Number,y2:Number,z2:Number):void
{
var k:int;
k = itRend * 9;
vecVert[k] = x0; vecVert[k+1] = y0; vecVert[k+2] = z0;
vecVert[k+3] = x1; vecVert[k+4] = y1; vecVert[k+5] = z1;
vecVert[k+6] = x2; vecVert[k+7] = y2; vecVert[k+8] = z2;
itRend +=1; if (itRend >= maxTri) { itRend -= 1; }
}//addtri
public function render():void
{
var i:int; var num:int; var k:int; var v:int;
num = itRend * 3;
for (i=0; i<num;i+=3)
{
graphics.beginFill(0, 0.5);
v = vecFace[i] * 3; graphics.moveTo(vecVert[v], vecVert[v+1]);
v = vecFace[i+1] * 3; graphics.lineTo(vecVert[v], vecVert[v+1]);
v = vecFace[i+2] * 3; graphics.lineTo(vecVert[v], vecVert[v+1]);
v = vecFace[i] * 3; graphics.lineTo(vecVert[v], vecVert[v+1]);
graphics.endFill();
}//nexti
}//render
public var gt:int= 0;
public function onEnter(e:Event):void
{
var i:int; var k:int;
var ax:Number; var ay:Number;
var aw:Number; var ah:Number;
var ta:Number;
graphics.clear();
itRend = 0;
addTri(0,0,0, 128,0,0, 0,128,0);
addTri(0,128,0, 128,0,0, 128,128,0 );
aw = 8; ah=8;
for (i=0;i<32;i+=1)
{
for (k=0;k<64;k+=1)
{
ta = Math.sin((gt+k)*0.3);
ax = k * aw;
ay = i * ah + ta *8;
addTri(ax,ay,0, ax+aw,ay,0, ax,ay+ah,0);
addTri(ax,ay+ah,0, ax+aw,ay,0, ax+aw,ay+ah,0 );
}//nextk
}//nexti
graphics.lineStyle(1, 0);
render();
gt += 1;
}//onenter
}//classend
}