flash on 2016-9-17
/**
* Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/Gbqm
*/
package {
import flash.events.MouseEvent;
import flash.display.StageQuality;
import flash.events.Event;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
stage.addEventListener(Event.ENTER_FRAME, onEnter);
}//ctor
public var mbutton:int = 0;
public var ang:Number = 0;
public function onEnter(e:Event):void
{
graphics.clear();
graphics.lineStyle(2, 0);
drawWave(0,0,0, 16,16);
drawWave(16*8,0,0, 16,16);
drawWave(0,0,16*8, 16,16);
drawWave(16*8,-32,16*8, 16,16);
drawWave(16*8,-128,16*8, 16,16);
ang += 0.1;
}//onEnter
public function drawWave(wx:Number, wy:Number, wz:Number, cw:Number=16, ch:Number=16):void
{
var mw:int; var mh:int;
var k:int; var i:int;
var ax:Number; var ay:Number; var az:Number;
var px:Number; var py:Number; var pz:Number;
var ta:Number; var ti:Number; var u:Number;
mw = 8; mh = 8;
// drawBox2(wx,wy,wz, mw*cw, 16, mh*ch);
u = 6.28/mw;
ti = ang;
for (i=0;i<mh;i+=1)
{
ta = ang;
for (k=0;k<mw+1;k+=1)
{
ax = k * cw + wx;
az = i * ch + wz;
ay = (Math.sin(ta)*Math.cos(ti))*8 + wy;
ta+=u;
//drawBox3(ax,ay,az, 2,2,2);
//drawLine(ax,0,az, ax,ay,az);
if (k > 0)
{ drawLine(ax,ay,az, px,py,pz); }
px=ax;py=ay;pz=az;
}//nextk
ti +=u;
}//nexti
}//drawwave
public var camx:Number = 0; public var camy:Number = 0; public var camz:Number = 0;
public var rendw:Number = 465 * 0.5; public var rendh:Number = 465 * 0.5;
public function drawLine(ax:Number, ay:Number, az:Number,
bx:Number, by:Number, bz:Number):void
{
var sx:Number; var sy:Number;
ax -= camx; ay -= camy; az -= camz;
bx -= camx; by -= camy; bz -= camz;
sx = ax - az + rendw; sy = (ax * 0.5) + (az * 0.5) - ay;
graphics.moveTo(sx,sy);
sx = bx - bz + rendw; sy = (bx * 0.5) + (bz * 0.5) - by;
graphics.lineTo(sx, sy);
}//drawline
public function drawBox3(ax:Number,ay:Number,az:Number,
rx:Number,ry:Number,rz:Number):void
{ drawBox(ax-rx,ay-ry,az-rz,ax+rx,ay+ry,az+rz); }
public function drawBox2(ax:Number,ay:Number,az:Number,
aw:Number,ah:Number,ad:Number):void
{ drawBox(ax,ay,az, ax+aw,ay+ah,az+ad); }
public function drawBox(ax:Number, ay:Number, az:Number,
bx:Number, by:Number, bz:Number):void
{
drawLine(ax, ay, az, bx, ay, az);
drawLine(ax, by, az, bx, by, az);
drawLine(ax, ay, bz, bx, ay, bz);
drawLine(ax, by, bz, bx, by, bz);
drawLine(ax, ay, az, ax, by, az);
drawLine(bx, ay, az, bx, by, az);
drawLine(ax, ay, bz, ax, by, bz);
drawLine(bx, ay, bz, bx, by, bz);
drawLine(ax, ay, az, ax, ay, bz);
drawLine(bx, ay, az, bx, ay, bz);
drawLine(ax, by, az, ax, by, bz);
drawLine(bx, by, az, bx, by, bz);
}//drawbox
}//classend
}