Struct Box2
Defines a 2d box (rectangle).
Implements
Inherited Members
Namespace: OpenTK
Assembly: OpenTK.dll
Syntax
public struct Box2 : IEquatable<Box2>
Constructors
Box2(Vector2, Vector2)
Constructs a new Box2 with the specified dimensions.
Declaration
public Box2(Vector2 topLeft, Vector2 bottomRight)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | topLeft | An OpenTK.Vector2 describing the top-left corner of the Box2. |
Vector2 | bottomRight | An OpenTK.Vector2 describing the bottom-right corner of the Box2. |
Box2(Single, Single, Single, Single)
Constructs a new Box2 with the specified dimensions.
Declaration
public Box2(float left, float top, float right, float bottom)
Parameters
Type | Name | Description |
---|---|---|
Single | left | The position of the left boundary. |
Single | top | The position of the top boundary. |
Single | right | The position of the right boundary. |
Single | bottom | The position of the bottom boundary. |
Fields
Bottom
The bottom boundary of the structure.
Declaration
public float Bottom
Field Value
Type | Description |
---|---|
Single |
Left
The left boundary of the structure.
Declaration
public float Left
Field Value
Type | Description |
---|---|
Single |
Right
The right boundary of the structure.
Declaration
public float Right
Field Value
Type | Description |
---|---|
Single |
Top
The top boundary of the structure.
Declaration
public float Top
Field Value
Type | Description |
---|---|
Single |
Properties
Height
Gets a float describing the height of the Box2 structure.
Declaration
public readonly float Height { get; }
Property Value
Type | Description |
---|---|
Single |
Width
Gets a float describing the width of the Box2 structure.
Declaration
public readonly float Width { get; }
Property Value
Type | Description |
---|---|
Single |
Methods
Contains(Vector2)
Returns whether the box contains the specified point on the closed region described by this Box2.
Declaration
public bool Contains(Vector2 point)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | point | The point to query. |
Returns
Type | Description |
---|---|
Boolean | Whether this box contains the point. |
Contains(Vector2, Boolean)
Returns whether the box contains the specified point.
Declaration
public bool Contains(Vector2 point, bool closedRegion)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | point | The point to query. |
Boolean | closedRegion | Whether to include the box boundary in the test region. |
Returns
Type | Description |
---|---|
Boolean | Whether this box contains the point. |
Equals(Box2)
Functional equality comparator.
Declaration
public bool Equals(Box2 other)
Parameters
Type | Name | Description |
---|---|---|
Box2 | other |
Returns
Type | Description |
---|---|
Boolean |
Equals(Object)
Implements Object.Equals.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj |
Returns
Type | Description |
---|---|
Boolean |
Overrides
FromDimensions(Vector2, Vector2)
Creates a new Box2 with the specified dimensions.
Declaration
public static Box2 FromDimensions(Vector2 position, Vector2 size)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | position | The position of the top left corner. |
Vector2 | size | The size of the box. |
Returns
Type | Description |
---|---|
Box2 | A new OpenTK.Box2 with the specfied dimensions. |
FromDimensions(Single, Single, Single, Single)
Creates a new Box2 with the specified dimensions.
Declaration
public static Box2 FromDimensions(float left, float top, float width, float height)
Parameters
Type | Name | Description |
---|---|---|
Single | left | The position of the left boundary. |
Single | top | The position of the top boundary. |
Single | width | The width of the box. |
Single | height | The height of the box. |
Returns
Type | Description |
---|---|
Box2 | A new OpenTK.Box2 with the specfied dimensions. |
FromTLRB(Single, Single, Single, Single)
Creates a new Box2 with the specified dimensions.
Declaration
public static Box2 FromTLRB(float top, float left, float right, float bottom)
Parameters
Type | Name | Description |
---|---|---|
Single | top | The position of the top boundary. |
Single | left | The position of the left boundary. |
Single | right | The position of the right boundary. |
Single | bottom | The position of the bottom boundary. |
Returns
Type | Description |
---|---|
Box2 | A new OpenTK.Box2 with the specfied dimensions. |
GetHashCode()
Gets the hash code for this Box2.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 |
Overrides
ToString()
Returns a String describing the current instance.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |
Overrides
Translate(Vector2)
Translates this Box2 by the given amount.
Declaration
public void Translate(Vector2 point)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | point |
Translated(Vector2)
Returns a Box2 translated by the given amount.
Declaration
public Box2 Translated(Vector2 point)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | point |
Returns
Type | Description |
---|---|
Box2 |
Operators
Equality(Box2, Box2)
Equality comparator.
Declaration
public static bool operator ==(Box2 left, Box2 right)
Parameters
Type | Name | Description |
---|---|---|
Box2 | left | |
Box2 | right |
Returns
Type | Description |
---|---|
Boolean |
Inequality(Box2, Box2)
Inequality comparator.
Declaration
public static bool operator !=(Box2 left, Box2 right)
Parameters
Type | Name | Description |
---|---|---|
Box2 | left | |
Box2 | right |
Returns
Type | Description |
---|---|
Boolean |