flash on 2011-12-17
♥0 |
Line 44 |
Modified 2011-12-18 10:18:57 |
MIT License
archived:2017-03-30 22:00:06
ActionScript3 source code
/**
* Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/i7Ba
*/
package
{
import flash.display.*;
import flash.events.*;
import flash.geom.*;
public class FlashTest extends Sprite
{
public function FlashTest()
{
// write as3 code here..
var centerX:Number=stage.stageWidth/2;
var centerY:Number=stage.stageHeight/2;
// 1 to 2 ratio
// try others 1 / 1.5 etc...
var theta:Number = Math.atan(1 / 2);
var cosX:Number=Math.cos(theta);
var sinX:Number=Math.sin(theta);
var pnt:Point = new Point();
function iso3D(x:Number, y:Number, z:Number):Point {
pnt.x = centerX + (x-z) * cosX;
pnt.y = centerY - (x+z) * sinX - y;
return pnt;
}
var p:Point = iso3D(0,0,0);
graphics.beginFill(0x000000);
graphics.drawCircle(p.x, p.y, 2);
// x axis positive
trace("x = red");
for (var i:int = 1; i<10; i++){
graphics.beginFill(0xFF0000);
p = iso3D(i*10, 0, 0);
graphics.drawCircle(p.x, p.y, 2);
}
// y axis positive
trace("y = green");
for (i= 1; i<10; i++){
graphics.beginFill(0x00FF00);
p = iso3D(0, i * 10, 0);
graphics.drawCircle(p.x, p.y, 2);
}
// z axis positive
trace("z = blue");
for (i= 1; i<10; i++){
graphics.beginFill(0x0000FF);
p = iso3D(0, 0, i * 10);
graphics.drawCircle(p.x, p.y, 2);
}
}
}
}