Rectangle StructureDelta Engine Documentation
Holds data for a rectangle by specifying its top left corner and the width and height. View code on GitHub

Namespace: DeltaEngine.Datatypes
Assembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public struct Rectangle : IEquatable<Rectangle>, 
	Lerp<Rectangle>, Lerp

The Rectangle type exposes the following members.

Constructors

  NameDescription
Public methodRectangle(String)
Initializes a new instance of the Rectangle class
Public methodRectangle(Vector2D, Size)
Initializes a new instance of the Rectangle class
Public methodRectangle(Single, Single, Single, Single)
Initializes a new instance of the Rectangle class
Top
Methods

  NameDescription
Public methodStatic memberBuildUVRectangle
Build UV rectangle for a given uv pixel rect and imagePixelSize. Used for FontData. View code on GitHub
Public methodContains
Public methodEquals(Object) (Overrides ValueType Equals(Object).)
Public methodEquals(Rectangle)
Public methodStatic memberFromCenter(Vector2D, Size)
Public methodStatic memberFromCenter(Single, Single, Single, Single)
Public methodStatic memberFromCorners
Public methodStatic memberFromPoints
Public methodGetBoundingBoxAfterRotation
Public methodGetHashCode (Overrides ValueType GetHashCode .)
Public methodGetInnerRectangle
Public methodGetRelativePoint
Public methodGetRotatedRectangleCorners
Public methodIncrease
Public methodIntersectsCircle
Public methodIsColliding
Public methodIsNearlyEqual
Public methodStatic memberIsProjectedAxisOutsideRectangles
Public methodLerp
Public methodMerge
Public methodMove(Vector2D)
Public methodMove(Single, Single)
Public methodReduce
Public methodToString (Overrides ValueType ToString .)
Top
Operators

  NameDescription
Public operatorStatic memberEquality
Public operatorStatic memberInequality
Top
Fields

  NameDescription
Public fieldStatic memberHalfCentered
Public fieldStatic memberOne
Public fieldStatic memberSizeInBytes
Public fieldStatic memberUnused
Public fieldStatic memberZero
Top
Properties

  NameDescription
Public propertyAspect
Public propertyBottom
Public propertyBottomLeft
Public propertyBottomRight
Public propertyCenter
Public propertyHeight
Public propertyLeft
Public propertyRight
Public propertySize
Public propertyTop
Public propertyTopLeft
Public propertyTopRight
Public propertyWidth
Top
Remarks

Tests: DeltaEngine.Tests.Datatypes.RectangleTests
Examples

39 unit tests call DeltaEngine.Datatypes.Rectangle
[Test]
public void Create()
{
    var point = new Vector2D(2f, 2f);
    var size = new Size(1f, 1f);
    var rect = new Rectangle(point, size);
    Assert.AreEqual(point.X, rect.Left);
    Assert.AreEqual(point.Y, rect.Top);
    Assert.AreEqual(size.Width, rect.Width);
    Assert.AreEqual(size.Height, rect.Height);
    Assert.AreEqual(point, rect.TopLeft);
    Assert.AreEqual(size, rect.Size);
}
[Test]
public void CreateFromFivePoints()
{
    var points = new List<Vector2D> { Vector2D.Zero, Vector2D.One, Vector2D.One * 1.5f, 
        Vector2D.Half, -Vector2D.One };
    var rectangle = Rectangle.FromPoints(points);
    Assert.AreEqual(-Vector2D.One, rectangle.TopLeft);
    Assert.AreEqual(Vector2D.One * 1.5f, rectangle.BottomRight);
}
[Test]
public void CreateFromTwoPoints()
{
    var points = new List<Vector2D> { new Vector2D(4, 4), new Vector2D(3, 2) };
    var rectangle = Rectangle.FromPoints(points);
    Assert.AreEqual(new Vector2D(3, 2), rectangle.TopLeft);
    Assert.AreEqual(new Vector2D(4, 4), rectangle.BottomRight);
}
See Also