Holds data for a rectangle by specifying its top left corner and the width and height.
View code on GitHub
Namespace: DeltaEngine.DatatypesAssembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The Rectangle type exposes the following members.
Constructors
Name | Description | |
---|---|---|
Rectangle(String) | Initializes a new instance of the Rectangle class | |
Rectangle(Vector2D, Size) | Initializes a new instance of the Rectangle class | |
Rectangle(Single, Single, Single, Single) | Initializes a new instance of the Rectangle class |
Methods
Name | Description | |
---|---|---|
BuildUVRectangle |
Build UV rectangle for a given uv pixel rect and imagePixelSize. Used for FontData.
View code on GitHub | |
Contains | ||
Equals(Object) | (Overrides ValueType Equals(Object).) | |
Equals(Rectangle) | ||
FromCenter(Vector2D, Size) | ||
FromCenter(Single, Single, Single, Single) | ||
FromCorners | ||
FromPoints | ||
GetBoundingBoxAfterRotation | ||
GetHashCode | (Overrides ValueType GetHashCode .) | |
GetInnerRectangle | ||
GetRelativePoint | ||
GetRotatedRectangleCorners | ||
Increase | ||
IntersectsCircle | ||
IsColliding | ||
IsNearlyEqual | ||
IsProjectedAxisOutsideRectangles | ||
Lerp | ||
Merge | ||
Move(Vector2D) | ||
Move(Single, Single) | ||
Reduce | ||
ToString | (Overrides ValueType ToString .) |
Operators
Name | Description | |
---|---|---|
Equality | ||
Inequality |
Fields
Name | Description | |
---|---|---|
HalfCentered | ||
One | ||
SizeInBytes | ||
Unused | ||
Zero |
Properties
Name | Description | |
---|---|---|
Aspect | ||
Bottom | ||
BottomLeft | ||
BottomRight | ||
Center | ||
Height | ||
Left | ||
Right | ||
Size | ||
Top | ||
TopLeft | ||
TopRight | ||
Width |
Remarks
Examples
[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