C# Class Nez.RectangleExt

Afficher le fichier Open project: prime31/Nez Class Usage Examples

Méthodes publiques

Méthode Description
boundsFromPolygonPoints ( Vector2 points ) : Rectangle

given the points of a polygon calculates the bounds

calculateBounds ( Rectangle &rect, Vector2 parentPosition, Vector2 position, Vector2 origin, Vector2 scale, float rotation, float width, float height ) : void
clone ( this rect ) : Rectangle

clones and returns a new Rectangle with the same data as the current rectangle

collisionCheck ( Rectangle &rect, Rectangle &other, float &moveX, float &moveY ) : bool

returns true if the boxes are colliding moveX and moveY will return the movement that b1 must move to avoid the collision

contract ( Rectangle &rect, int horizontalAmount, int verticalAmount ) : void
expandSide ( Rectangle &rect, System.Edge edge, int amount ) : void
fromFloats ( float x, float y, float width, float height ) : Rectangle

returns a rectangle from the passed in floats

fromMinMaxPoints ( Point min, Point max ) : Rectangle

creates a Rectangle given min/max points (top-left, bottom-right points)

getCenter ( Rectangle &rect ) : Vector2

gets the center point of the rectangle as a Vector2

getCenter ( this rect ) : Vector2

gets the center point of the rectangle as a Vector2

getClosestPointOnBoundsToOrigin ( Rectangle &rect ) : Vector2
getClosestPointOnRectangleBorderToPoint ( Rectangle &rect, Vector2 point ) : Point

gets the closest point that is on the rectangle border to the given point

getClosestPointOnRectangleToPoint ( Rectangle &rect, Vector2 point ) : Vector2

returns the closest point that is in or on the Rectangle to the given point

getHalfRect ( this rect, System.Edge edge ) : Rectangle
getHalfSize ( this rect ) : Vector2

gets the half size of the rect

getIntersectionDepth ( Rectangle &rectA, Rectangle &rectB ) : Vector2

Calculates the signed depth of intersection between two rectangles.

getMax ( Rectangle &rect ) : Point

gets the max point of the rectangle, the bottom-right corner

getPosition ( Rectangle &rect ) : Vector2

gets the position of the rectangle as a Vector2

getRectEdgePortion ( this rect, System.Edge edge, int size = 1 ) : Rectangle

gets a portion of the Rectangle with a width/height of size that is on the Edge of the Rectangle but still contained within it.

getSide ( this rect, System.Edge edge ) : int

gets the position of the specified side

getSweptBroadphaseBounds ( Rectangle &rect, float deltaX, float deltaY ) : Rectangle

returns a Bounds the spans the current bounds and the provided delta positions

getSweptBroadphaseBounds ( Rectangle &rect, int deltaX, int deltaY ) : Rectangle

returns a Bounds the spans the current bounds and the provided delta positions

intersect ( Rectangle &rect1, Rectangle &rect2 ) : bool

returns true if rect1 intersects rect2

rayIntersects ( Rectangle &rect, Ray2D &ray, float &distance ) : bool
rayIntersects ( this rectangle, Microsoft.Xna.Framework.Ray ray ) : float?
scale ( Rectangle &rect, Vector2 scale ) : void

scales the rect

translate ( Rectangle &rect, Vector2 vec ) : void
union ( Rectangle &first, Point &point, Rectangle &result ) : void

Update first to be the union of first and point

union ( Rectangle &value1, Rectangle &value2, Rectangle &result ) : void

calculates the union of the two Rectangles. The result will be a rectangle that encompasses the other two.

Method Details

boundsFromPolygonPoints() public static méthode

given the points of a polygon calculates the bounds
public static boundsFromPolygonPoints ( Vector2 points ) : Rectangle
points Vector2 Points.
Résultat Microsoft.Xna.Framework.Rectangle

calculateBounds() public static méthode

public static calculateBounds ( Rectangle &rect, Vector2 parentPosition, Vector2 position, Vector2 origin, Vector2 scale, float rotation, float width, float height ) : void
rect Microsoft.Xna.Framework.Rectangle
parentPosition Vector2
position Vector2
origin Vector2
scale Vector2
rotation float
width float
height float
Résultat void

clone() public static méthode

clones and returns a new Rectangle with the same data as the current rectangle
public static clone ( this rect ) : Rectangle
rect this Rect.
Résultat Microsoft.Xna.Framework.Rectangle

collisionCheck() public static méthode

returns true if the boxes are colliding moveX and moveY will return the movement that b1 must move to avoid the collision
public static collisionCheck ( Rectangle &rect, Rectangle &other, float &moveX, float &moveY ) : bool
rect Microsoft.Xna.Framework.Rectangle
other Microsoft.Xna.Framework.Rectangle Other.
moveX float Move x.
moveY float Move y.
Résultat bool

contract() public static méthode

public static contract ( Rectangle &rect, int horizontalAmount, int verticalAmount ) : void
rect Microsoft.Xna.Framework.Rectangle
horizontalAmount int
verticalAmount int
Résultat void

expandSide() public static méthode

public static expandSide ( Rectangle &rect, System.Edge edge, int amount ) : void
rect Microsoft.Xna.Framework.Rectangle
edge System.Edge
amount int
Résultat void

fromFloats() public static méthode

returns a rectangle from the passed in floats
public static fromFloats ( float x, float y, float width, float height ) : Rectangle
x float The x coordinate.
y float The y coordinate.
width float Width.
height float Height.
Résultat Microsoft.Xna.Framework.Rectangle

fromMinMaxPoints() public static méthode

creates a Rectangle given min/max points (top-left, bottom-right points)
public static fromMinMaxPoints ( Point min, Point max ) : Rectangle
min Point Minimum.
max Point Max.
Résultat Microsoft.Xna.Framework.Rectangle

getCenter() public static méthode

gets the center point of the rectangle as a Vector2
public static getCenter ( Rectangle &rect ) : Vector2
rect Microsoft.Xna.Framework.Rectangle Rect.
Résultat Vector2

getCenter() public static méthode

gets the center point of the rectangle as a Vector2
public static getCenter ( this rect ) : Vector2
rect this Rect.
Résultat Vector2

getClosestPointOnBoundsToOrigin() public static méthode

public static getClosestPointOnBoundsToOrigin ( Rectangle &rect ) : Vector2
rect Microsoft.Xna.Framework.Rectangle
Résultat Vector2

getClosestPointOnRectangleBorderToPoint() public static méthode

gets the closest point that is on the rectangle border to the given point
public static getClosestPointOnRectangleBorderToPoint ( Rectangle &rect, Vector2 point ) : Point
rect Microsoft.Xna.Framework.Rectangle Rect.
point Vector2 Point.
Résultat Point

getClosestPointOnRectangleToPoint() public static méthode

returns the closest point that is in or on the Rectangle to the given point
public static getClosestPointOnRectangleToPoint ( Rectangle &rect, Vector2 point ) : Vector2
rect Microsoft.Xna.Framework.Rectangle Rect.
point Vector2 Point.
Résultat Vector2

getHalfRect() public static méthode

public static getHalfRect ( this rect, System.Edge edge ) : Rectangle
rect this
edge System.Edge
Résultat Microsoft.Xna.Framework.Rectangle

getHalfSize() public static méthode

gets the half size of the rect
public static getHalfSize ( this rect ) : Vector2
rect this Rect.
Résultat Vector2

getIntersectionDepth() public static méthode

Calculates the signed depth of intersection between two rectangles.
public static getIntersectionDepth ( Rectangle &rectA, Rectangle &rectB ) : Vector2
rectA Microsoft.Xna.Framework.Rectangle
rectB Microsoft.Xna.Framework.Rectangle
Résultat Vector2

getMax() public static méthode

gets the max point of the rectangle, the bottom-right corner
public static getMax ( Rectangle &rect ) : Point
rect Microsoft.Xna.Framework.Rectangle Rect.
Résultat Point

getPosition() public static méthode

gets the position of the rectangle as a Vector2
public static getPosition ( Rectangle &rect ) : Vector2
rect Microsoft.Xna.Framework.Rectangle Rect.
Résultat Vector2

getRectEdgePortion() public static méthode

gets a portion of the Rectangle with a width/height of size that is on the Edge of the Rectangle but still contained within it.
public static getRectEdgePortion ( this rect, System.Edge edge, int size = 1 ) : Rectangle
rect this Rect.
edge System.Edge Edge.
size int Size.
Résultat Microsoft.Xna.Framework.Rectangle

getSide() public static méthode

gets the position of the specified side
public static getSide ( this rect, System.Edge edge ) : int
rect this
edge System.Edge Side.
Résultat int

getSweptBroadphaseBounds() public static méthode

returns a Bounds the spans the current bounds and the provided delta positions
public static getSweptBroadphaseBounds ( Rectangle &rect, float deltaX, float deltaY ) : Rectangle
rect Microsoft.Xna.Framework.Rectangle
deltaX float
deltaY float
Résultat Microsoft.Xna.Framework.Rectangle

getSweptBroadphaseBounds() public static méthode

returns a Bounds the spans the current bounds and the provided delta positions
public static getSweptBroadphaseBounds ( Rectangle &rect, int deltaX, int deltaY ) : Rectangle
rect Microsoft.Xna.Framework.Rectangle
deltaX int
deltaY int
Résultat Microsoft.Xna.Framework.Rectangle

intersect() public static méthode

returns true if rect1 intersects rect2
public static intersect ( Rectangle &rect1, Rectangle &rect2 ) : bool
rect1 Microsoft.Xna.Framework.Rectangle
rect2 Microsoft.Xna.Framework.Rectangle
Résultat bool

rayIntersects() public static méthode

public static rayIntersects ( Rectangle &rect, Ray2D &ray, float &distance ) : bool
rect Microsoft.Xna.Framework.Rectangle
ray Ray2D
distance float
Résultat bool

rayIntersects() public static méthode

public static rayIntersects ( this rectangle, Microsoft.Xna.Framework.Ray ray ) : float?
rectangle this
ray Microsoft.Xna.Framework.Ray
Résultat float?

scale() public static méthode

scales the rect
public static scale ( Rectangle &rect, Vector2 scale ) : void
rect Microsoft.Xna.Framework.Rectangle Rect.
scale Vector2 Scale.
Résultat void

translate() public static méthode

public static translate ( Rectangle &rect, Vector2 vec ) : void
rect Microsoft.Xna.Framework.Rectangle
vec Vector2
Résultat void

union() public static méthode

Update first to be the union of first and point
public static union ( Rectangle &first, Point &point, Rectangle &result ) : void
first Microsoft.Xna.Framework.Rectangle First.
point Point Point.
result Microsoft.Xna.Framework.Rectangle Result.
Résultat void

union() public static méthode

calculates the union of the two Rectangles. The result will be a rectangle that encompasses the other two.
public static union ( Rectangle &value1, Rectangle &value2, Rectangle &result ) : void
value1 Microsoft.Xna.Framework.Rectangle
value2 Microsoft.Xna.Framework.Rectangle
result Microsoft.Xna.Framework.Rectangle Result.
Résultat void