Example #1
0
		/// <summary>
		/// 	Draws the quad.
		/// </summary>
		/// <param name="rect">Rect.</param>
		/// <param name="uvs">Uvs.</param>
		public static void DrawQuad(Rect rect, Rect uvs)
		{
			GL.TexCoord(uvs.GetBottomLeft());
			GL.Vertex(rect.GetBottomLeft());

			GL.TexCoord(uvs.GetTopLeft());
			GL.Vertex(rect.GetTopLeft());

			GL.TexCoord(uvs.GetTopRight());
			GL.Vertex(rect.GetTopRight());

			GL.TexCoord(uvs.GetBottomRight());
			GL.Vertex(rect.GetBottomRight());
		}
Example #2
0
		/// <summary>
		/// 	Returns the number of intersections with the given rectangle.
		/// </summary>
		/// <param name="rect">Rect.</param>
		/// <param name="finiteThis">If set to <c>true</c> this line is finite.</param>
		/// <param name="intersections">Intersections.</param>
		public int Intersects(Rect rect, bool finiteThis, ref Vector2[] intersections)
		{
			int output = 0;

			Array.Resize(ref intersections, 4);

			Vector2 topLeft = rect.GetTopLeft();
			Vector2 topRight = rect.GetTopRight();
			Vector2 bottomLeft = rect.GetBottomLeft();
			Vector2 bottomRight = rect.GetBottomRight();

			Line2d top = new Line2d(topLeft, topRight);
			Line2d bottom = new Line2d(bottomLeft, bottomRight);
			Line2d left = new Line2d(topLeft, bottomLeft);
			Line2d right = new Line2d(topRight, bottomRight);

			Vector2 intersection;

			if (Intersects(top, finiteThis, true, out intersection))
			{
				intersections[output] = intersection;
				output++;
			}

			if (Intersects(bottom, finiteThis, true, out intersection))
			{
				intersections[output] = intersection;
				output++;
			}

			if (Intersects(left, finiteThis, true, out intersection))
			{
				intersections[output] = intersection;
				output++;
			}

			if (Intersects(right, finiteThis, true, out intersection))
			{
				intersections[output] = intersection;
				output++;
			}

			return output;
		}
Example #3
0
		/// <summary>
		/// 	Draws the rect.
		/// </summary>
		/// <param name="rect">Rect.</param>
		/// <param name="color">Color.</param>
		/// <param name="duration">Duration.</param>
		public static void DrawRect(Rect rect, Color color, float duration)
		{
			Vector2 topLeft = rect.GetTopLeft();
			Vector2 topRight = rect.GetTopRight();
			Vector2 bottomLeft = rect.GetBottomLeft();
			Vector2 bottomRight = rect.GetBottomRight();

			Debug.DrawLine(topLeft, topRight, color, duration);
			Debug.DrawLine(bottomLeft, bottomRight, color, duration);
			Debug.DrawLine(topLeft, bottomLeft, color, duration);
			Debug.DrawLine(topRight, bottomRight, color, duration);
		}