<NME> RectangleFloat.cs
<BEF> ADDFILE
<MSG> Made a RectangleFloat class

<DFF> @@ -0,0 +1,307 @@
+﻿/*
+Copyright (c) 2014, Lars Brubaker
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+The views and conclusions contained in the software and documentation are those
+of the authors and should not be interpreted as representing official policies,
+either expressed or implied, of the FreeBSD Project.
+*/
+
+using MatterHackers.VectorMath;
+using Newtonsoft.Json;
+using System;
+
+namespace MatterHackers.Agg
+{
+	public struct RectangleFloat
+	{
+		public float Left, Bottom, Right, Top;
+
+		public static readonly RectangleFloat ZeroIntersection = new RectangleFloat(float.MaxValue, float.MaxValue, float.MinValue, float.MinValue);
+
+		public RectangleFloat(float left, float bottom, float right, float top)
+		{
+			this.Left = left;
+			this.Bottom = bottom;
+			this.Right = right;
+			this.Top = top;
+		}
+
+		public RectangleFloat(RectangleInt intRect)
+		{
+			Left = intRect.Left;
+			Bottom = intRect.Bottom;
+			Right = intRect.Right;
+			Top = intRect.Top;
+		}
+
+		public void SetRect(float left, float bottom, float right, float top)
+		{
+			init(left, bottom, right, top);
+		}
+
+		public static bool operator ==(RectangleFloat a, RectangleFloat b)
+		{
+			if (a.Left == b.Left && a.Bottom == b.Bottom && a.Right == b.Right && a.Top == b.Top)
+			{
+				return true;
+			}
+
+			return false;
+		}
+
+		public static bool operator !=(RectangleFloat a, RectangleFloat b)
+		{
+			if (a.Left != b.Left || a.Bottom != b.Bottom || a.Right != b.Right || a.Top != b.Top)
+			{
+				return true;
+			}
+
+			return false;
+		}
+
+		public override int GetHashCode()
+		{
+			return new { x1 = Left, x2 = Right, y1 = Bottom, y2 = Top }.GetHashCode();
+		}
+
+		public override bool Equals(object obj)
+		{
+			if (obj.GetType() == typeof(RectangleFloat))
+			{
+				return this == (RectangleFloat)obj;
+			}
+			return false;
+		}
+
+		public bool Equals(RectangleFloat other, float epsilon)
+		{
+			return Math.Abs(Left - other.Left) <= epsilon
+				&& Math.Abs(Bottom - other.Bottom) <= epsilon
+				&& Math.Abs(Right - other.Right) <= epsilon
+				&& Math.Abs(Top - other.Top) <= epsilon;
+		}
+
+		public void init(float left, float bottom, float right, float top)
+		{
+			Left = left;
+			Bottom = bottom;
+			Right = right;
+			Top = top;
+		}
+
+		// This function assumes the rect is normalized
+		[JsonIgnoreAttribute]
+		public float Width
+		{
+			get
+			{
+				return Right - Left;
+			}
+		}
+
+		// This function assumes the rect is normalized
+		[JsonIgnoreAttribute]
+		public float Height
+		{
+			get
+			{
+				return Top - Bottom;
+			}
+		}
+
+		public RectangleFloat normalize()
+		{
+			float t;
+			if (Left > Right) { t = Left; Left = Right; Right = t; }
+			if (Bottom > Top) { t = Bottom; Bottom = Top; Top = t; }
+			return this;
+		}
+
+		public bool clip(RectangleFloat r)
+		{
+			if (Right > r.Right) Right = r.Right;
+			if (Top > r.Top) Top = r.Top;
+			if (Left < r.Left) Left = r.Left;
+			if (Bottom < r.Bottom) Bottom = r.Bottom;
+			return Left <= Right && Bottom <= Top;
+		}
+
+		public bool is_valid()
+		{
+			return Left <= Right && Bottom <= Top;
+		}
+
+		public bool Contains(float x, float y)
+		{
+			return (x >= Left && x <= Right && y >= Bottom && y <= Top);
+		}
+
+		public bool Contains(RectangleFloat innerRect)
+		{
+			if (Contains(innerRect.Left, innerRect.Bottom) && Contains(innerRect.Right, innerRect.Top))
+			{
+				return true;
+			}
+
+			return false;
+		}
+
+		public bool Contains(Vector2 position)
+		{
+			return Contains((float)position.x, (float)position.y);
+		}
+
+		public bool IntersectRectangles(RectangleFloat rectToCopy, RectangleFloat rectToIntersectWith)
+		{
+			Left = rectToCopy.Left;
+			Bottom = rectToCopy.Bottom;
+			Right = rectToCopy.Right;
+			Top = rectToCopy.Top;
+
+			if (Left < rectToIntersectWith.Left) Left = rectToIntersectWith.Left;
+			if (Bottom < rectToIntersectWith.Bottom) Bottom = rectToIntersectWith.Bottom;
+			if (Right > rectToIntersectWith.Right) Right = rectToIntersectWith.Right;
+			if (Top > rectToIntersectWith.Top) Top = rectToIntersectWith.Top;
+
+			if (Left < Right && Bottom < Top)
+			{
+				return true;
+			}
+
+			return false;
+		}
+
+		public bool IntersectWithRectangle(RectangleFloat rectToIntersectWith)
+		{
+			if (Left < rectToIntersectWith.Left) Left = rectToIntersectWith.Left;
+			if (Bottom < rectToIntersectWith.Bottom) Bottom = rectToIntersectWith.Bottom;
+			if (Right > rectToIntersectWith.Right) Right = rectToIntersectWith.Right;
+			if (Top > rectToIntersectWith.Top) Top = rectToIntersectWith.Top;
+
+			if (Left < Right && Bottom < Top)
+			{
+				return true;
+			}
+
+			return false;
+		}
+
+		public void unite_rectangles(RectangleFloat r1, RectangleFloat r2)
+		{
+			Left = r1.Left;
+			Bottom = r1.Bottom;
+			Right = r1.Right;
+			Right = r1.Top;
+			if (Right < r2.Right) Right = r2.Right;
+			if (Top < r2.Top) Top = r2.Top;
+			if (Left > r2.Left) Left = r2.Left;
+			if (Bottom > r2.Bottom) Bottom = r2.Bottom;
+		}
+
+		public void ExpandToInclude(RectangleFloat rectToInclude)
+		{
+			if (Right < rectToInclude.Right) Right = rectToInclude.Right;
+			if (Top < rectToInclude.Top) Top = rectToInclude.Top;
+			if (Left > rectToInclude.Left) Left = rectToInclude.Left;
+			if (Bottom > rectToInclude.Bottom) Bottom = rectToInclude.Bottom;
+		}
+
+		public void ExpandToInclude(Vector2 position)
+		{
+			ExpandToInclude((float)position.x, (float)position.y);
+		}
+
+		public void ExpandToInclude(float x, float y)
+		{
+			if (Right < x) Right = x;
+			if (Top < y) Top = y;
+			if (Left > x) Left = x;
+			if (Bottom > y) Bottom = y;
+		}
+
+		public void Inflate(float inflateSize)
+		{
+			Left = Left - inflateSize;
+			Bottom = Bottom - inflateSize;
+			Right = Right + inflateSize;
+			Top = Top + inflateSize;
+		}
+
+		public void Offset(Vector2 offset)
+		{
+			Offset((float)offset.x, (float)offset.y);
+		}
+
+		public void Offset(float x, float y)
+		{
+			Left = Left + x;
+			Bottom = Bottom + y;
+			Right = Right + x;
+			Top = Top + y;
+		}
+
+		static public RectangleFloat operator *(RectangleFloat a, float b)
+		{
+			return new RectangleFloat(a.Left * b, a.Bottom * b, a.Right * b, a.Top * b);
+		}
+
+		static public RectangleFloat operator *(float b, RectangleFloat a)
+		{
+			return new RectangleFloat(a.Left * b, a.Bottom * b, a.Right * b, a.Top * b);
+		}
+
+		public float XCenter
+		{
+			get { return (Right - Left) / 2; }
+		}
+
+		public float YCenter
+		{
+			get { return (Top - Bottom) / 2; }
+		}
+
+#if false
+		public void Inflate(BorderFloat borderFloat)
+		{
+			Left -= borderFloat.Left;
+			Right += borderFloat.Right;
+			Bottom -= borderFloat.Bottom;
+			Top += borderFloat.Top;
+		}
+
+		public void Deflate(BorderFloat borderFloat)
+		{
+			Left += borderFloat.Left;
+			Right -= borderFloat.Right;
+			Bottom += borderFloat.Bottom;
+			Top -= borderFloat.Top;
+		}
+#endif
+
+		public override string ToString()
+		{
+			return string.Format("L:{0}, B:{1}, R:{2}, T:{3}", Left, Bottom, Right, Top);
+		}
+	}
+}
\ No newline at end of file

{'commit': 'diff --git a/agg/Agg.csproj b/agg/Agg.csproj\nindex 987a0d49..6811b2e7 100644\n--- a/agg/Agg.csproj\n+++ b/agg/Agg.csproj\n@@ -195,6 +195,7 @@\n     <Compile Include="Font\\UnitTests.cs" />\n     <Compile Include="Image\\ImageSequence.cs" />\n     <Compile Include="PluginFinder.cs" />\n+    <Compile Include="RectangleFloat.cs" />\n     <Compile Include="RectangleDouble.cs" />\n     <Compile Include="RectangleInt.cs" />\n     <Compile Include="RootedObjectEventHandler.cs" />\ndiff --git a/agg/RectangleFloat.cs b/agg/RectangleFloat.cs\nnew file mode 100644\nindex 00000000..d5d51974\n--- /dev/null\n+++ b/agg/RectangleFloat.cs\n@@ -0,0 +1,307 @@\n+\ufeff/*\n+Copyright (c) 2014, Lars Brubaker\n+All rights reserved.\n+\n+Redistribution and use in source and binary forms, with or without\n+modification, are permitted provided that the following conditions are met:\n+\n+1. Redistributions of source code must retain the above copyright notice, this\n+   list of conditions and the following disclaimer.\n+2. Redistributions in binary form must reproduce the above copyright notice,\n+   this list of conditions and the following disclaimer in the documentation\n+   and/or other materials provided with the distribution.\n+\n+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\n+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+\n+The views and conclusions contained in the software and documentation are those\n+of the authors and should not be interpreted as representing official policies,\n+either expressed or implied, of the FreeBSD Project.\n+*/\n+\n+using MatterHackers.VectorMath;\n+using Newtonsoft.Json;\n+using System;\n+\n+namespace MatterHackers.Agg\n+{\n+\tpublic struct RectangleFloat\n+\t{\n+\t\tpublic float Left, Bottom, Right, Top;\n+\n+\t\tpublic static readonly RectangleFloat ZeroIntersection = new RectangleFloat(float.MaxValue, float.MaxValue, float.MinValue, float.MinValue);\n+\n+\t\tpublic RectangleFloat(float left, float bottom, float right, float top)\n+\t\t{\n+\t\t\tthis.Left = left;\n+\t\t\tthis.Bottom = bottom;\n+\t\t\tthis.Right = right;\n+\t\t\tthis.Top = top;\n+\t\t}\n+\n+\t\tpublic RectangleFloat(RectangleInt intRect)\n+\t\t{\n+\t\t\tLeft = intRect.Left;\n+\t\t\tBottom = intRect.Bottom;\n+\t\t\tRight = intRect.Right;\n+\t\t\tTop = intRect.Top;\n+\t\t}\n+\n+\t\tpublic void SetRect(float left, float bottom, float right, float top)\n+\t\t{\n+\t\t\tinit(left, bottom, right, top);\n+\t\t}\n+\n+\t\tpublic static bool operator ==(RectangleFloat a, RectangleFloat b)\n+\t\t{\n+\t\t\tif (a.Left == b.Left && a.Bottom == b.Bottom && a.Right == b.Right && a.Top == b.Top)\n+\t\t\t{\n+\t\t\t\treturn true;\n+\t\t\t}\n+\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tpublic static bool operator !=(RectangleFloat a, RectangleFloat b)\n+\t\t{\n+\t\t\tif (a.Left != b.Left || a.Bottom != b.Bottom || a.Right != b.Right || a.Top != b.Top)\n+\t\t\t{\n+\t\t\t\treturn true;\n+\t\t\t}\n+\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tpublic override int GetHashCode()\n+\t\t{\n+\t\t\treturn new { x1 = Left, x2 = Right, y1 = Bottom, y2 = Top }.GetHashCode();\n+\t\t}\n+\n+\t\tpublic override bool Equals(object obj)\n+\t\t{\n+\t\t\tif (obj.GetType() == typeof(RectangleFloat))\n+\t\t\t{\n+\t\t\t\treturn this == (RectangleFloat)obj;\n+\t\t\t}\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tpublic bool Equals(RectangleFloat other, float epsilon)\n+\t\t{\n+\t\t\treturn Math.Abs(Left - other.Left) <= epsilon\n+\t\t\t\t&& Math.Abs(Bottom - other.Bottom) <= epsilon\n+\t\t\t\t&& Math.Abs(Right - other.Right) <= epsilon\n+\t\t\t\t&& Math.Abs(Top - other.Top) <= epsilon;\n+\t\t}\n+\n+\t\tpublic void init(float left, float bottom, float right, float top)\n+\t\t{\n+\t\t\tLeft = left;\n+\t\t\tBottom = bottom;\n+\t\t\tRight = right;\n+\t\t\tTop = top;\n+\t\t}\n+\n+\t\t// This function assumes the rect is normalized\n+\t\t[JsonIgnoreAttribute]\n+\t\tpublic float Width\n+\t\t{\n+\t\t\tget\n+\t\t\t{\n+\t\t\t\treturn Right - Left;\n+\t\t\t}\n+\t\t}\n+\n+\t\t// This function assumes the rect is normalized\n+\t\t[JsonIgnoreAttribute]\n+\t\tpublic float Height\n+\t\t{\n+\t\t\tget\n+\t\t\t{\n+\t\t\t\treturn Top - Bottom;\n+\t\t\t}\n+\t\t}\n+\n+\t\tpublic RectangleFloat normalize()\n+\t\t{\n+\t\t\tfloat t;\n+\t\t\tif (Left > Right) { t = Left; Left = Right; Right = t; }\n+\t\t\tif (Bottom > Top) { t = Bottom; Bottom = Top; Top = t; }\n+\t\t\treturn this;\n+\t\t}\n+\n+\t\tpublic bool clip(RectangleFloat r)\n+\t\t{\n+\t\t\tif (Right > r.Right) Right = r.Right;\n+\t\t\tif (Top > r.Top) Top = r.Top;\n+\t\t\tif (Left < r.Left) Left = r.Left;\n+\t\t\tif (Bottom < r.Bottom) Bottom = r.Bottom;\n+\t\t\treturn Left <= Right && Bottom <= Top;\n+\t\t}\n+\n+\t\tpublic bool is_valid()\n+\t\t{\n+\t\t\treturn Left <= Right && Bottom <= Top;\n+\t\t}\n+\n+\t\tpublic bool Contains(float x, float y)\n+\t\t{\n+\t\t\treturn (x >= Left && x <= Right && y >= Bottom && y <= Top);\n+\t\t}\n+\n+\t\tpublic bool Contains(RectangleFloat innerRect)\n+\t\t{\n+\t\t\tif (Contains(innerRect.Left, innerRect.Bottom) && Contains(innerRect.Right, innerRect.Top))\n+\t\t\t{\n+\t\t\t\treturn true;\n+\t\t\t}\n+\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tpublic bool Contains(Vector2 position)\n+\t\t{\n+\t\t\treturn Contains((float)position.x, (float)position.y);\n+\t\t}\n+\n+\t\tpublic bool IntersectRectangles(RectangleFloat rectToCopy, RectangleFloat rectToIntersectWith)\n+\t\t{\n+\t\t\tLeft = rectToCopy.Left;\n+\t\t\tBottom = rectToCopy.Bottom;\n+\t\t\tRight = rectToCopy.Right;\n+\t\t\tTop = rectToCopy.Top;\n+\n+\t\t\tif (Left < rectToIntersectWith.Left) Left = rectToIntersectWith.Left;\n+\t\t\tif (Bottom < rectToIntersectWith.Bottom) Bottom = rectToIntersectWith.Bottom;\n+\t\t\tif (Right > rectToIntersectWith.Right) Right = rectToIntersectWith.Right;\n+\t\t\tif (Top > rectToIntersectWith.Top) Top = rectToIntersectWith.Top;\n+\n+\t\t\tif (Left < Right && Bottom < Top)\n+\t\t\t{\n+\t\t\t\treturn true;\n+\t\t\t}\n+\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tpublic bool IntersectWithRectangle(RectangleFloat rectToIntersectWith)\n+\t\t{\n+\t\t\tif (Left < rectToIntersectWith.Left) Left = rectToIntersectWith.Left;\n+\t\t\tif (Bottom < rectToIntersectWith.Bottom) Bottom = rectToIntersectWith.Bottom;\n+\t\t\tif (Right > rectToIntersectWith.Right) Right = rectToIntersectWith.Right;\n+\t\t\tif (Top > rectToIntersectWith.Top) Top = rectToIntersectWith.Top;\n+\n+\t\t\tif (Left < Right && Bottom < Top)\n+\t\t\t{\n+\t\t\t\treturn true;\n+\t\t\t}\n+\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tpublic void unite_rectangles(RectangleFloat r1, RectangleFloat r2)\n+\t\t{\n+\t\t\tLeft = r1.Left;\n+\t\t\tBottom = r1.Bottom;\n+\t\t\tRight = r1.Right;\n+\t\t\tRight = r1.Top;\n+\t\t\tif (Right < r2.Right) Right = r2.Right;\n+\t\t\tif (Top < r2.Top) Top = r2.Top;\n+\t\t\tif (Left > r2.Left) Left = r2.Left;\n+\t\t\tif (Bottom > r2.Bottom) Bottom = r2.Bottom;\n+\t\t}\n+\n+\t\tpublic void ExpandToInclude(RectangleFloat rectToInclude)\n+\t\t{\n+\t\t\tif (Right < rectToInclude.Right) Right = rectToInclude.Right;\n+\t\t\tif (Top < rectToInclude.Top) Top = rectToInclude.Top;\n+\t\t\tif (Left > rectToInclude.Left) Left = rectToInclude.Left;\n+\t\t\tif (Bottom > rectToInclude.Bottom) Bottom = rectToInclude.Bottom;\n+\t\t}\n+\n+\t\tpublic void ExpandToInclude(Vector2 position)\n+\t\t{\n+\t\t\tExpandToInclude((float)position.x, (float)position.y);\n+\t\t}\n+\n+\t\tpublic void ExpandToInclude(float x, float y)\n+\t\t{\n+\t\t\tif (Right < x) Right = x;\n+\t\t\tif (Top < y) Top = y;\n+\t\t\tif (Left > x) Left = x;\n+\t\t\tif (Bottom > y) Bottom = y;\n+\t\t}\n+\n+\t\tpublic void Inflate(float inflateSize)\n+\t\t{\n+\t\t\tLeft = Left - inflateSize;\n+\t\t\tBottom = Bottom - inflateSize;\n+\t\t\tRight = Right + inflateSize;\n+\t\t\tTop = Top + inflateSize;\n+\t\t}\n+\n+\t\tpublic void Offset(Vector2 offset)\n+\t\t{\n+\t\t\tOffset((float)offset.x, (float)offset.y);\n+\t\t}\n+\n+\t\tpublic void Offset(float x, float y)\n+\t\t{\n+\t\t\tLeft = Left + x;\n+\t\t\tBottom = Bottom + y;\n+\t\t\tRight = Right + x;\n+\t\t\tTop = Top + y;\n+\t\t}\n+\n+\t\tstatic public RectangleFloat operator *(RectangleFloat a, float b)\n+\t\t{\n+\t\t\treturn new RectangleFloat(a.Left * b, a.Bottom * b, a.Right * b, a.Top * b);\n+\t\t}\n+\n+\t\tstatic public RectangleFloat operator *(float b, RectangleFloat a)\n+\t\t{\n+\t\t\treturn new RectangleFloat(a.Left * b, a.Bottom * b, a.Right * b, a.Top * b);\n+\t\t}\n+\n+\t\tpublic float XCenter\n+\t\t{\n+\t\t\tget { return (Right - Left) / 2; }\n+\t\t}\n+\n+\t\tpublic float YCenter\n+\t\t{\n+\t\t\tget { return (Top - Bottom) / 2; }\n+\t\t}\n+\n+#if false\n+\t\tpublic void Inflate(BorderFloat borderFloat)\n+\t\t{\n+\t\t\tLeft -= borderFloat.Left;\n+\t\t\tRight += borderFloat.Right;\n+\t\t\tBottom -= borderFloat.Bottom;\n+\t\t\tTop += borderFloat.Top;\n+\t\t}\n+\n+\t\tpublic void Deflate(BorderFloat borderFloat)\n+\t\t{\n+\t\t\tLeft += borderFloat.Left;\n+\t\t\tRight -= borderFloat.Right;\n+\t\t\tBottom += borderFloat.Bottom;\n+\t\t\tTop -= borderFloat.Top;\n+\t\t}\n+#endif\n+\n+\t\tpublic override string ToString()\n+\t\t{\n+\t\t\treturn string.Format("L:{0}, B:{1}, R:{2}, T:{3}", Left, Bottom, Right, Top);\n+\t\t}\n+\t}\n+}\n\\ No newline at end of file\n', 'commit_subject': 'Made a RectangleFloat class', 'repo_name': 'MatterHackers/agg-sharp', 'committer': {'name': 'larsbrubaker', 'email': 'e778e58ed9792dc86ffbb0a8f0ddd0f63c29c494@gmail.com', 'time_sec': '1430841264', 'tz_offset': '-420', 'date': {'seconds': '1430841264'}}, 'commit_tree': '5ae72b6b8e230fb19f61ce0bd0764874da1d6b94', 'commit_message': 'Made a RectangleFloat class\n', 'language_name': 'C#', 'license': 'bsd-2-clause', 'hunks': '@@ -0,0 +1,307 @@\n+\ufeff/*\n+Copyright (c) 2014, Lars Brubaker\n+All rights reserved.\n+\n+Redistribution and use in source and binary forms, with or without\n+modification, are permitted provided that the following conditions are met:\n+\n+1. Redistributions of source code must retain the above copyright notice, this\n+   list of conditions and the following disclaimer.\n+2. Redistributions in binary form must reproduce the above copyright notice,\n+   this list of conditions and the following disclaimer in the documentation\n+   and/or other materials provided with the distribution.\n+\n+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND\n+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+\n+The views and conclusions contained in the software and documentation are those\n+of the authors and should not be interpreted as representing official policies,\n+either expressed or implied, of the FreeBSD Project.\n+*/\n+\n+using MatterHackers.VectorMath;\n+using Newtonsoft.Json;\n+using System;\n+\n+namespace MatterHackers.Agg\n+{\n+\tpublic struct RectangleFloat\n+\t{\n+\t\tpublic float Left, Bottom, Right, Top;\n+\n+\t\tpublic static readonly RectangleFloat ZeroIntersection = new RectangleFloat(float.MaxValue, float.MaxValue, float.MinValue, float.MinValue);\n+\n+\t\tpublic RectangleFloat(float left, float bottom, float right, float top)\n+\t\t{\n+\t\t\tthis.Left = left;\n+\t\t\tthis.Bottom = bottom;\n+\t\t\tthis.Right = right;\n+\t\t\tthis.Top = top;\n+\t\t}\n+\n+\t\tpublic RectangleFloat(RectangleInt intRect)\n+\t\t{\n+\t\t\tLeft = intRect.Left;\n+\t\t\tBottom = intRect.Bottom;\n+\t\t\tRight = intRect.Right;\n+\t\t\tTop = intRect.Top;\n+\t\t}\n+\n+\t\tpublic void SetRect(float left, float bottom, float right, float top)\n+\t\t{\n+\t\t\tinit(left, bottom, right, top);\n+\t\t}\n+\n+\t\tpublic static bool operator ==(RectangleFloat a, RectangleFloat b)\n+\t\t{\n+\t\t\tif (a.Left == b.Left && a.Bottom == b.Bottom && a.Right == b.Right && a.Top == b.Top)\n+\t\t\t{\n+\t\t\t\treturn true;\n+\t\t\t}\n+\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tpublic static bool operator !=(RectangleFloat a, RectangleFloat b)\n+\t\t{\n+\t\t\tif (a.Left != b.Left || a.Bottom != b.Bottom || a.Right != b.Right || a.Top != b.Top)\n+\t\t\t{\n+\t\t\t\treturn true;\n+\t\t\t}\n+\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tpublic override int GetHashCode()\n+\t\t{\n+\t\t\treturn new { x1 = Left, x2 = Right, y1 = Bottom, y2 = Top }.GetHashCode();\n+\t\t}\n+\n+\t\tpublic override bool Equals(object obj)\n+\t\t{\n+\t\t\tif (obj.GetType() == typeof(RectangleFloat))\n+\t\t\t{\n+\t\t\t\treturn this == (RectangleFloat)obj;\n+\t\t\t}\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tpublic bool Equals(RectangleFloat other, float epsilon)\n+\t\t{\n+\t\t\treturn Math.Abs(Left - other.Left) <= epsilon\n+\t\t\t\t&& Math.Abs(Bottom - other.Bottom) <= epsilon\n+\t\t\t\t&& Math.Abs(Right - other.Right) <= epsilon\n+\t\t\t\t&& Math.Abs(Top - other.Top) <= epsilon;\n+\t\t}\n+\n+\t\tpublic void init(float left, float bottom, float right, float top)\n+\t\t{\n+\t\t\tLeft = left;\n+\t\t\tBottom = bottom;\n+\t\t\tRight = right;\n+\t\t\tTop = top;\n+\t\t}\n+\n+\t\t// This function assumes the rect is normalized\n+\t\t[JsonIgnoreAttribute]\n+\t\tpublic float Width\n+\t\t{\n+\t\t\tget\n+\t\t\t{\n+\t\t\t\treturn Right - Left;\n+\t\t\t}\n+\t\t}\n+\n+\t\t// This function assumes the rect is normalized\n+\t\t[JsonIgnoreAttribute]\n+\t\tpublic float Height\n+\t\t{\n+\t\t\tget\n+\t\t\t{\n+\t\t\t\treturn Top - Bottom;\n+\t\t\t}\n+\t\t}\n+\n+\t\tpublic RectangleFloat normalize()\n+\t\t{\n+\t\t\tfloat t;\n+\t\t\tif (Left > Right) { t = Left; Left = Right; Right = t; }\n+\t\t\tif (Bottom > Top) { t = Bottom; Bottom = Top; Top = t; }\n+\t\t\treturn this;\n+\t\t}\n+\n+\t\tpublic bool clip(RectangleFloat r)\n+\t\t{\n+\t\t\tif (Right > r.Right) Right = r.Right;\n+\t\t\tif (Top > r.Top) Top = r.Top;\n+\t\t\tif (Left < r.Left) Left = r.Left;\n+\t\t\tif (Bottom < r.Bottom) Bottom = r.Bottom;\n+\t\t\treturn Left <= Right && Bottom <= Top;\n+\t\t}\n+\n+\t\tpublic bool is_valid()\n+\t\t{\n+\t\t\treturn Left <= Right && Bottom <= Top;\n+\t\t}\n+\n+\t\tpublic bool Contains(float x, float y)\n+\t\t{\n+\t\t\treturn (x >= Left && x <= Right && y >= Bottom && y <= Top);\n+\t\t}\n+\n+\t\tpublic bool Contains(RectangleFloat innerRect)\n+\t\t{\n+\t\t\tif (Contains(innerRect.Left, innerRect.Bottom) && Contains(innerRect.Right, innerRect.Top))\n+\t\t\t{\n+\t\t\t\treturn true;\n+\t\t\t}\n+\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tpublic bool Contains(Vector2 position)\n+\t\t{\n+\t\t\treturn Contains((float)position.x, (float)position.y);\n+\t\t}\n+\n+\t\tpublic bool IntersectRectangles(RectangleFloat rectToCopy, RectangleFloat rectToIntersectWith)\n+\t\t{\n+\t\t\tLeft = rectToCopy.Left;\n+\t\t\tBottom = rectToCopy.Bottom;\n+\t\t\tRight = rectToCopy.Right;\n+\t\t\tTop = rectToCopy.Top;\n+\n+\t\t\tif (Left < rectToIntersectWith.Left) Left = rectToIntersectWith.Left;\n+\t\t\tif (Bottom < rectToIntersectWith.Bottom) Bottom = rectToIntersectWith.Bottom;\n+\t\t\tif (Right > rectToIntersectWith.Right) Right = rectToIntersectWith.Right;\n+\t\t\tif (Top > rectToIntersectWith.Top) Top = rectToIntersectWith.Top;\n+\n+\t\t\tif (Left < Right && Bottom < Top)\n+\t\t\t{\n+\t\t\t\treturn true;\n+\t\t\t}\n+\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tpublic bool IntersectWithRectangle(RectangleFloat rectToIntersectWith)\n+\t\t{\n+\t\t\tif (Left < rectToIntersectWith.Left) Left = rectToIntersectWith.Left;\n+\t\t\tif (Bottom < rectToIntersectWith.Bottom) Bottom = rectToIntersectWith.Bottom;\n+\t\t\tif (Right > rectToIntersectWith.Right) Right = rectToIntersectWith.Right;\n+\t\t\tif (Top > rectToIntersectWith.Top) Top = rectToIntersectWith.Top;\n+\n+\t\t\tif (Left < Right && Bottom < Top)\n+\t\t\t{\n+\t\t\t\treturn true;\n+\t\t\t}\n+\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\tpublic void unite_rectangles(RectangleFloat r1, RectangleFloat r2)\n+\t\t{\n+\t\t\tLeft = r1.Left;\n+\t\t\tBottom = r1.Bottom;\n+\t\t\tRight = r1.Right;\n+\t\t\tRight = r1.Top;\n+\t\t\tif (Right < r2.Right) Right = r2.Right;\n+\t\t\tif (Top < r2.Top) Top = r2.Top;\n+\t\t\tif (Left > r2.Left) Left = r2.Left;\n+\t\t\tif (Bottom > r2.Bottom) Bottom = r2.Bottom;\n+\t\t}\n+\n+\t\tpublic void ExpandToInclude(RectangleFloat rectToInclude)\n+\t\t{\n+\t\t\tif (Right < rectToInclude.Right) Right = rectToInclude.Right;\n+\t\t\tif (Top < rectToInclude.Top) Top = rectToInclude.Top;\n+\t\t\tif (Left > rectToInclude.Left) Left = rectToInclude.Left;\n+\t\t\tif (Bottom > rectToInclude.Bottom) Bottom = rectToInclude.Bottom;\n+\t\t}\n+\n+\t\tpublic void ExpandToInclude(Vector2 position)\n+\t\t{\n+\t\t\tExpandToInclude((float)position.x, (float)position.y);\n+\t\t}\n+\n+\t\tpublic void ExpandToInclude(float x, float y)\n+\t\t{\n+\t\t\tif (Right < x) Right = x;\n+\t\t\tif (Top < y) Top = y;\n+\t\t\tif (Left > x) Left = x;\n+\t\t\tif (Bottom > y) Bottom = y;\n+\t\t}\n+\n+\t\tpublic void Inflate(float inflateSize)\n+\t\t{\n+\t\t\tLeft = Left - inflateSize;\n+\t\t\tBottom = Bottom - inflateSize;\n+\t\t\tRight = Right + inflateSize;\n+\t\t\tTop = Top + inflateSize;\n+\t\t}\n+\n+\t\tpublic void Offset(Vector2 offset)\n+\t\t{\n+\t\t\tOffset((float)offset.x, (float)offset.y);\n+\t\t}\n+\n+\t\tpublic void Offset(float x, float y)\n+\t\t{\n+\t\t\tLeft = Left + x;\n+\t\t\tBottom = Bottom + y;\n+\t\t\tRight = Right + x;\n+\t\t\tTop = Top + y;\n+\t\t}\n+\n+\t\tstatic public RectangleFloat operator *(RectangleFloat a, float b)\n+\t\t{\n+\t\t\treturn new RectangleFloat(a.Left * b, a.Bottom * b, a.Right * b, a.Top * b);\n+\t\t}\n+\n+\t\tstatic public RectangleFloat operator *(float b, RectangleFloat a)\n+\t\t{\n+\t\t\treturn new RectangleFloat(a.Left * b, a.Bottom * b, a.Right * b, a.Top * b);\n+\t\t}\n+\n+\t\tpublic float XCenter\n+\t\t{\n+\t\t\tget { return (Right - Left) / 2; }\n+\t\t}\n+\n+\t\tpublic float YCenter\n+\t\t{\n+\t\t\tget { return (Top - Bottom) / 2; }\n+\t\t}\n+\n+#if false\n+\t\tpublic void Inflate(BorderFloat borderFloat)\n+\t\t{\n+\t\t\tLeft -= borderFloat.Left;\n+\t\t\tRight += borderFloat.Right;\n+\t\t\tBottom -= borderFloat.Bottom;\n+\t\t\tTop += borderFloat.Top;\n+\t\t}\n+\n+\t\tpublic void Deflate(BorderFloat borderFloat)\n+\t\t{\n+\t\t\tLeft += borderFloat.Left;\n+\t\t\tRight -= borderFloat.Right;\n+\t\t\tBottom += borderFloat.Bottom;\n+\t\t\tTop -= borderFloat.Top;\n+\t\t}\n+#endif\n+\n+\t\tpublic override string ToString()\n+\t\t{\n+\t\t\treturn string.Format("L:{0}, B:{1}, R:{2}, T:{3}", Left, Bottom, Right, Top);\n+\t\t}\n+\t}\n+}\n\\ No newline at end of file\n', 'addition_count': 307, 'deletion_count': 0, 'src_file': '/dev/null', 'tgt_file': 'b/agg/RectangleFloat.cs', 'file_extension': '.cs', 'before_file': 'ADDFILE', 'message': 'Made a RectangleFloat class\n', 'author_name': 'larsbrubaker', 'lang': 'cs'}