flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject git commit: [flex-asjs] [refs/heads/develop] - Completed Point and Rectangle Added casting for overrides
Date Sun, 10 Jul 2016 20:24:54 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop 37ed8408b -> c9d14d38a


Completed Point and Rectangle
Added casting for overrides


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/c9d14d38
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/c9d14d38
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/c9d14d38

Branch: refs/heads/develop
Commit: c9d14d38a20bd7af3ba8bfb453564194fe461207
Parents: 37ed840
Author: Harbs <harbs@in-tools.com>
Authored: Sun Jul 10 23:24:45 2016 +0300
Committer: Harbs <harbs@in-tools.com>
Committed: Sun Jul 10 23:24:45 2016 +0300

----------------------------------------------------------------------
 .../main/flex/org/apache/flex/geom/Matrix.as    |  11 +
 .../src/main/flex/org/apache/flex/geom/Point.as |  95 +++++++++
 .../main/flex/org/apache/flex/geom/Rectangle.as | 213 ++++++++++++++++++-
 3 files changed, 309 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c9d14d38/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Matrix.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Matrix.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Matrix.as
index c0b829c..6d8118d 100644
--- a/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Matrix.as
+++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Matrix.as
@@ -22,6 +22,7 @@ package org.apache.flex.geom
 	COMPILE::SWF
 	{
 		import flash.geom.Matrix;
+		import flash.geom.Point;
 	}
 
 	COMPILE::SWF
@@ -35,6 +36,16 @@ package org.apache.flex.geom
 		{
 			return new org.apache.flex.geom.Matrix(this.a, this.b, this.c, this.d, this.tx, this.ty);
 		}
+		override public function deltaTransformPoint(point:flash.geom.Point):org.apache.flex.geom.Point
+		{
+			return super.deltaTransformPoint(point) as org.apache.flex.geom.Point;
+		}
+		
+		override public function transformPoint(point:flash.geom.Point):org.apache.flex.geom.Point
+		{
+			return super.transformPoint(point) as org.apache.flex.geom.Point;
+		}
+
 
 	}
 	COMPILE::JS

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c9d14d38/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Point.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Point.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Point.as
index 24dd8d6..f44e0bb 100644
--- a/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Point.as
+++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Point.as
@@ -18,6 +18,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.geom
 {
+
 COMPILE::SWF
 {
     import flash.geom.Point;
@@ -46,6 +47,31 @@ public class Point extends flash.geom.Point
 	{
 		return new org.apache.flex.geom.Point(x,y);
 	}
+	override public function subtract(v:flash.geom.Point):org.apache.flex.geom.Point
+	{
+		return super.subtract(v) as org.apache.flex.geom.Point;
+	}
+	
+	override public function add(v:flash.geom.Point):org.apache.flex.geom.Point
+	{
+		return super.add(v) as org.apache.flex.geom.Point;
+	}
+
+	public static function interpolate(pt1:org.apache.flex.geom.Point, pt2:org.apache.flex.geom.Point,
f:Number):org.apache.flex.geom.Point
+	{
+		return flash.geom.Point.interpolate(pt1,pt2,f) as org.apache.flex.geom.Point;
+	}
+	
+	public static function distance(pt1:org.apache.flex.geom.Point, pt2:org.apache.flex.geom.Point):Number
+	{
+		return flash.geom.Point.distance(pt1,pt2);
+	}
+	
+	public static function polar(len:Number, angle:Number):org.apache.flex.geom.Point
+	{
+		return flash.geom.Point.polar(len,angle) as org.apache.flex.geom.Point;
+	}
+
 }
 
 /**
@@ -71,10 +97,79 @@ public class Point
     
     public var x:Number;
     public var y:Number;
+	public static function interpolate(pt1:Point, pt2:Point, f:Number):Point
+	{
+		return new Point(pt2.x + f * (pt1.x - pt2.x),pt2.y + f * (pt1.y - pt2.y));
+	}
+	
+	public static function distance(pt1:Point, pt2:Point):Number
+	{
+		return pt1.subtract(pt2).length;
+	}
+	
+	public static function polar(len:Number, angle:Number):Point
+	{
+		return new Point(len * Math.cos(angle),len * Math.sin(angle));
+	}
+	
+	public function get length():Number
+	{
+		return Math.sqrt(x * x + y * y);
+	}
+	
 	public function clone():Point
 	{
 		return new Point(x,y);
 	}
+	
+	public function offset(dx:Number, dy:Number):void
+	{
+		x = x + dx;
+		y = y + dy;
+	}
+	
+	public function equals(toCompare:Point):Boolean
+	{
+		return toCompare.x == x && toCompare.y == y;
+	}
+	
+	public function subtract(v:Point):Point
+	{
+		return new Point(x - v.x, y - v.y);
+	}
+	
+	public function add(v:Point):Point
+	{
+		return new Point(x + v.x, y + v.y);
+	}
+	
+	public function normalize(thickness:Number):void
+	{
+		var invD:Number = length;
+		if(invD > 0)
+		{
+			invD = thickness / invD;
+			x = x * invD;
+			y = y * invD;
+		}
+	}
+	
+	public function toString():String
+	{
+		return "(x=" + x + ", y=" + y + ")";
+	}
+	
+	public function copyFrom(sourcePoint:Point):void
+	{
+		x = sourcePoint.x;
+		y = sourcePoint.y;
+	}
+	
+	public function setTo(xa:Number, ya:Number):void
+	{
+		x = xa;
+		y = ya;
+	}
 }
 
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/c9d14d38/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Rectangle.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Rectangle.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Rectangle.as
index 6a79a45..d19dbad 100644
--- a/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Rectangle.as
+++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Rectangle.as
@@ -18,6 +18,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.geom
 {
+
 COMPILE::SWF
 {
     import flash.geom.Rectangle;
@@ -44,8 +45,9 @@ public class Rectangle extends flash.geom.Rectangle
     }
 	override public function clone():org.apache.flex.geom.Rectangle
 	{
-		return new org.apache.flex.geom.Rectangle(left,top,width,height);
+		return new org.apache.flex.geom.Rectangle(x,y,width,height);
 	}
+
 }
 
 /**
@@ -65,37 +67,228 @@ public class Rectangle
 {
     public function Rectangle(x:Number = 0, y:Number = 0, width:Number = 0, height:Number
= 0)
     {
-        left = x;
-        top = y;
+        this.x = x;
+        this.y = y;
         this.width = width;
         this.height = height;
     }
     
-    public var left:Number;
-    public var top:Number;
+	public var x:Number;
+	public var y:Number;
     public var width:Number;
     public var height:Number;
 
+	public function get left():Number
+	{
+		return x;
+	}
+	public function set left(value:Number):void
+	{
+		x = value;
+	}
+	public function get top():Number
+	{
+		return y;
+	}
+	public function set top(value:Number):void
+	{
+		y = value;
+	}
     public function get right():Number
     {
-        return left + width;
+        return x + width;
     }
     public function set right(value:Number):void
     {
-        width = value - left;
+        width = value - x;
     }
     
     public function get bottom():Number
     {
-        return top + height;
+        return y + height;
     }
     public function set bottom(value:Number):void
     {
-        height = value - top;
+        height = value - y;
     }
 	public function clone():Rectangle
 	{
-		return new Rectangle(left,top,width,height);
+		return new Rectangle(x,y,width,height);
+	}
+	public function get topLeft():Point
+	{
+		return new Point(x, y);
+	}
+	
+	public function set topLeft(value:Point):void
+	{
+		width = width + (x - value.x);
+		height = height + (y - value.y);
+		x = value.x;
+		y = value.y;
+	}
+	
+	public function get bottomRight():Point
+	{
+		return new Point(right, bottom);
+	}
+	
+	public function set bottomRight(value:Point):void
+	{
+		width = value.x - x;
+		height = value.y - y;
+	}
+	
+	public function get size():Point
+	{
+		return new Point(width, height);
+	}
+	
+	public function set size(value:Point):void
+	{
+		width = value.x;
+		height = value.y;
+	}
+	
+	public function isEmpty():Boolean
+	{
+		return width <= 0 || height <= 0;
+	}
+	
+	public function setEmpty():void
+	{
+		x = 0;
+		y = 0;
+		width = 0;
+		height = 0;
+	}
+	
+	public function inflate(dx:Number, dy:Number):void
+	{
+		x = x - dx;
+		width = width + 2 * dx;
+		y = y - dy;
+		height = height + 2 * dy;
+	}
+	
+	public function inflatePoint(point:Point):void
+	{
+		x = x - point.x;
+		width = width + 2 * point.x;
+		y = y - point.y;
+		height = height + 2 * point.y;
+	}
+	
+	public function offset(dx:Number, dy:Number):void
+	{
+		x = x + dx;
+		y = y + dy;
+	}
+	
+	public function offsetPoint(point:Point):void
+	{
+		x = x + point.x;
+		y = y + point.y;
+	}
+	
+	public function contains(x:Number, y:Number):Boolean
+	{
+		return x >= x && x < x + width && y >= y && y < y +
height;
+	}
+	
+	public function containsPoint(point:Point):Boolean
+	{
+		return point.x >= x && point.x < x + width && point.y >= y &&
point.y < y + height;
+	}
+	
+	public function containsRect(rect:Rectangle):Boolean
+	{
+		var r1:Number = rect.x + rect.width;
+		var b1:Number = rect.y + rect.height;
+		var r2:Number = x + width;
+		var b2:Number = y + height;
+		return rect.x >= x && rect.x < r2 && rect.y >= y && rect.y
< b2 && r1 > x && r1 <= r2 && b1 > y && b1 <=
b2;
+	}
+	
+	public function intersection(toIntersect:Rectangle):Rectangle
+	{
+		var result:Rectangle = new Rectangle();
+		if (isEmpty() || toIntersect.isEmpty())
+		{
+			result.setEmpty();
+			return result;
+		}
+		result.x = Math.max(x, toIntersect.x);
+		result.y = Math.max(y, toIntersect.y);
+		result.width = Math.min(x + width, toIntersect.x + toIntersect.width) - result.x;
+		result.height = Math.min(y + height, toIntersect.y + toIntersect.height) - result.y;
+		if (result.width <= 0 || result.height <= 0)
+		{
+			result.setEmpty();
+		}
+		return result;
+	}
+	
+	public function intersects(toIntersect:Rectangle):Boolean
+	{
+		if (isEmpty() || toIntersect.isEmpty())
+		{
+			return false;
+		}
+		var resultx:Number = Math.max(x, toIntersect.x);
+		var resulty:Number = Math.max(y, toIntersect.y);
+		var resultwidth:Number = Math.min(x + width, toIntersect.x + toIntersect.width) - resultx;
+		var resultheight:Number = Math.min(y + height, toIntersect.y + toIntersect.height) - resulty;
+		if (resultwidth <= 0 || resultheight <= 0)
+		{
+			return false;
+		}
+		return true;
+	}
+	
+	public function union(toUnion:Rectangle):Rectangle
+	{
+		var r:Rectangle = null;
+		if (isEmpty())
+		{
+			return toUnion.clone();
+		}
+		if (toUnion.isEmpty())
+		{
+			return clone();
+		}
+		r = new Rectangle();
+		r.x = Math.min(x, toUnion.x);
+		r.y = Math.min(y, toUnion.y);
+		r.width = Math.max(x + width, toUnion.x + toUnion.width) - r.x;
+		r.height = Math.max(y + height, toUnion.y + toUnion.height) - r.y;
+		return r;
+	}
+	
+	public function equals(toCompare:Rectangle):Boolean
+	{
+		return toCompare.x == x && toCompare.y == y && toCompare.width == width
&& toCompare.height == height;
+	}
+	
+	public function toString():String
+	{
+		return "(x=" + x + ", y=" + y + ", w=" + width + ", h=" + height + ")";
+	}
+	
+	public function copyFrom(sourceRect:Rectangle):void
+	{
+		x = sourceRect.x;
+		y = sourceRect.y;
+		width = sourceRect.width;
+		height = sourceRect.height;
+	}
+	
+	public function setTo(xa:Number, ya:Number, widtha:Number, heighta:Number):void
+	{
+		x = xa;
+		y = ya;
+		width = widtha;
+		height = heighta;
 	}
 }
 


Mime
View raw message