/** * com.jR.Drawing.Triangle * March 14th, 2006 * Copyright (c) Jānis Radiņš ( janis@mediaverk.lv ) * * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class com.jR.Drawing.Triangle extends com.jR.Drawing.Polygon { private var _radius:Number = null; private var _x1:Number = null; private var _x2:Number = null; private var _x3:Number = null; private var _y1:Number = null; private var _y2:Number = null; private var _y3:Number = null; private var _r1:Number = 0; private var _r2:Number = 0; private var _r3:Number = 0; public function Triangle(host:MovieClip, level:Number) { super(host, level); addPoint(0, 0, 0); addPoint(0, 0, 0); addPoint(0, 0, 0); _roundCorners = false; } public function set radius(value:Number):Void { r1 = r2=r3=value; } public function set x1(value:Number):Void { _x1 = value; } public function set x2(value:Number):Void { _x2 = value; } public function set x3(value:Number):Void { _x3 = value; } public function set y1(value:Number):Void { _y1 = value; } public function set y2(value:Number):Void { _y2 = value; } public function set y3(value:Number):Void { _y3 = value; } public function set r1(value:Number):Void { _r1 = value; } public function set r2(value:Number):Void { _r2 = value; } public function set r3(value:Number):Void { _r3 = value; } public function get radius():Number { if ((_r1+_r2+_r3)/3 == _r1) { return _r1; } return null; } public function get x1():Number { return _x1; } public function get x2():Number { return _x2; } public function get x3():Number { return _x3; } public function get y1():Number { return _y1; } public function get y2():Number { return _y2; } public function get y3():Number { return _y3; } public function get r1():Number { return _r1; } public function get r2():Number { return _r2; } public function get r3():Number { return _r3; } public function setEquilateral(__width:Number, __height:Number):Void { _x1 = -__width/2; _y1 = __height/2; _x2 = 0; _y2 = -__height/2; _x3 = __width/2; _y3 = __height/2; } public function setIsosceles(__width:Number):Void { _x1 = -__width/2; _y1 = (__width*Math.sin(Math.PI/3))/2; _x2 = 0; _y2 = -_y1; _x3 = __width/2; _y3 = _y1; } private function dealArguments(__inputObject:Object):Void { if (_autoClear == true) { clear(); } for (var i in __inputObject) { if (this["_"+i] !== undefined && this[i] !== undefined) { this[i] = __inputObject[i]; } } if (_x1 == null || _x2 == null || _x3 == null || _y1 == null || _y2 == null || _y3 == null) { throwError("Not enough data to draw triangle", false); return; } modifyPoint(0, {x:_x1, y:_y1, r:_r1}); modifyPoint(1, {x:_x2, y:_y2, r:_r2}); modifyPoint(2, {x:_x3, y:_y3, r:_r3}); } }