/** * Copyright (c) 2006 Peter Goodman * Licensed under the MIT License: * http://www.opensource.org/licenses/mit-license.php */ class FA.draw_fns extends FA.query { private var i:Object; private var line_width:Number; private var line_color:Number; private var line_transparency:Number; private var fill_transparency:Number; //-------------------------------------------- // Draw a shape. //-------------------------------------------- public function draw (_i:Object) : FA.query { var s:String = i.shape.toLowerCase(); var _s:FA.query = this; i = _i; return this.each(function(i){ if (this[shape].constructor == Function && this instanceof MovieClip) { line_width = i.lineWidth || 1; line_color = i.lineColor || 0x000000; line_transparency = i.lineAlpha || 100; fill_transparency = i.fillAlpha || 100; if (i.fillColor != undefined) { this.beginFill(i.fillColor, fill_transparency); } this.lineStyle(line_width, line_color, line_transparency); _s[s].apply(_s, [this]); if (i.fillColor != undefined) { this.endFill(); } } }); } //-------------------------------------------- // Draw a circle. Format: // { // radius: 10, // _x: 100, // _y: 100 // } //-------------------------------------------- private function circle(e) : Void { var x:Number = 0, y:Number = 0, a:Number = 0; for (a = 0; a <= 360; a++) { x = i._x + i.radius * Math.cos(a * Math.PI / 180); y = i._y + i.radius * Math.sin(a * Math.PI / 180); if (a == 0) { e.moveTo(x, y); } e.lineTo(x, y); } } //-------------------------------------------- // Draw a rectangle. Format: // { // width: 100, // height: 100, // } //-------------------------------------------- private function rectangle(e) : Void { e.moveTo(i._x, i._y); e.lineTo(i.width, i._y); e.lineTo(i.width, i.height); e.lineTo(i._x, i.height); } //-------------------------------------------- // Draw a triangle. // { // a: [x, y], // left // b: [x, y], // right // _x: 100, // _y: 100 // } //-------------------------------------------- private function triangle(e) : Void { e.moveTo(i._x, i._y); e.lineTo(i.b[1], i.b[1]); // c e.lineTo(i.a[0], i.a[1]); // a e.lineTo(i._x, i._y); // b } }