package com.rubenswieringa.geom { import flash.geom.*; import mx.graphics.RoundedRectangle; /** * Provides functionality for working with Rectangles. This class extends the RoundedRectangle class and thus has all of its functionality (and also the functionality of the Rectangle class, which RoundedRectangle extends). * * @author Ruben Swieringa * ruben.swieringa@gmail.com * www.rubenswieringa.com * www.rubenswieringa.com/blog * @version 1.0.0 * * * edit 5b* * * * This class is a slightly stripped-down version of the original lib_flex_book_com_rubenswieringa_geom_SuperRectangle class (the unfinished method getCornersInbetween() has been removed) * * Before modifying and/or redistributing this class, please contact Ruben Swieringa (ruben.swieringa@gmail.com). * * * View code documentation at: * http://www.rubenswieringa.com/code/as3/flex/Geom/docs/ * */ public class lib_flex_book_com_rubenswieringa_geom_SuperRectangle extends RoundedRectangle { public static const NONE:int = -1; public static const TOP:int = 0; public static const RIGHT:int = 1; public static const BOTTOM:int = 2; public static const LEFT:int = 3; /** * Constructor. */ public function lib_flex_book_com_rubenswieringa_geom_SuperRectangle (x:Number=0, y:Number=0, width:Number=0, height:Number=0, cornerRadius:Number=0):void { super(x, y, width, height, cornerRadius); } /** * Takes a Rectangle instance and returns it as a lib_flex_book_com_rubenswieringa_geom_SuperRectangle with the same position, width, height, and (if applicable) corner-radius. * * @param rect Rectangle * * @return rect as a lib_flex_book_com_rubenswieringa_geom_SuperRectangle. */ public static function createlib_flex_book_com_rubenswieringa_geom_SuperRectangle (rect:Rectangle):lib_flex_book_com_rubenswieringa_geom_SuperRectangle { if (rect is lib_flex_book_com_rubenswieringa_geom_SuperRectangle){ return lib_flex_book_com_rubenswieringa_geom_SuperRectangle(rect); } var newRect:lib_flex_book_com_rubenswieringa_geom_SuperRectangle = new lib_flex_book_com_rubenswieringa_geom_SuperRectangle(rect.x, rect.y, rect.width, rect.height); if (rect is RoundedRectangle){ newRect.cornerRadius = RoundedRectangle(rect).cornerRadius; } return newRect; } /** * Indicates on which side of this lib_flex_book_com_rubenswieringa_geom_SuperRectangle a Point is. Note that if the Point is not on the lib_flex_book_com_rubenswieringa_geom_SuperRectangle its border, -1 will be the return-value. * * @param point A coordinate. * * @see lib_flex_book_com_rubenswieringa_geom_SuperRectangle#NONE * @see lib_flex_book_com_rubenswieringa_geom_SuperRectangle#TOP * @see lib_flex_book_com_rubenswieringa_geom_SuperRectangle#RIGHT * @see lib_flex_book_com_rubenswieringa_geom_SuperRectangle#BOTTOM * @see lib_flex_book_com_rubenswieringa_geom_SuperRectangle#LEFT * * @return An integer indicating on which side a given coordinate is. 0 stands for he top-side, 1 for right-side, etc. Use the constants of the lib_flex_book_com_rubenswieringa_geom_SuperRectangle class for improved code-readability. */ public function isOnSide (point:Point):int { var lines:Array = this.getLines(); for (var i:int=0; i