F5 KScope0
// write as3 code here..
package{
import flash.display.*;
import flash.events.*;
import flash.geom.Matrix;
import frocessing.FC;
import frocessing.core.F5Graphics2D;
import net.hires.debug.Stats;
[SWF(frameRate="30", backgroundColor="#000000")]
public class F5KScope0 extends Sprite
{
private var _hw:Number;
private var _hh:Number;
private var _r:Number;
private var fg:F5Graphics2D;
private var bd:BitmapData;
private var _display:DisplayObject;
private var mtx:Matrix;
public function F5KScope0()
{
stage.align = StageAlign.TOP_LEFT;
addEventListener( Event.ADDED_TO_STAGE, setup );
}
private function setup(e:Event):void
{
removeEventListener( Event.ADDED_TO_STAGE, setup );
_hw = stage.stageWidth*0.5;
_hh = stage.stageHeight*0.5;
_r = _hw/Math.cos(Math.PI/6);
fg = new F5Graphics2D(graphics);
fg.noStroke();
bd = new BitmapData( _hw*2, _hh*2, false, 0xff000000 );
mtx = new Matrix();
mtx.scale( _hw/40, _hw/40 );
var s:Shape = new Shape();
s.graphics.beginGradientFill( FC.GRADIENT_TYPE_RADIAL, [0xff0000, 0x00ff00, 0x0000ff], [1.0, 1.0, 1.0], [0, 127, 255]);
s.graphics.drawRect( 0, 0, 80, 80 );
s.graphics.endFill();
_display = s;
var m:Shape = new Shape();
m.graphics.beginFill(0xffffff);
m.graphics.drawEllipse( 0, 0, _hw * 2, _hw * 2 );
m.graphics.endFill();
mask = m;
//addChild(new Stats());
addEventListener( Event.ENTER_FRAME, draw );
}
private function draw(e:Event):void
{
mtx.translate( -_hw, -_hh );
mtx.rotate( 0.05 );
mtx.translate( _hw, _hh );
bd.draw( _display, mtx );
fg.beginDraw();
fg.translate( _hw, _hh );
drawKScope( bd );
fg.endDraw();
}
private function drawKScope( bd:BitmapData ):void
{
var a:Number = Math.PI / 3;
var u:Number = 0.5;
var v:Number = 1;
fg.beginShape( FC.TRIANGLE_FAN );
fg.texture( bd );
fg.vertex( 0, 0, u, v );
u = v = 0;
for ( var i:int = 0; i <= 6; i++ )
{
fg.vertex( _r * Math.cos( a * i ), _r * Math.sin( a * i ), u, v );
u = ( u == 1 ) ? 0 : 1;
}
fg.endShape();
}
}
}