C# Class Nez.RectangleExt

ファイルを表示 Open project: prime31/Nez Class Usage Examples

Public Methods

Method 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 method

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

calculateBounds() public static method

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
return void

clone() public static method

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

collisionCheck() public static method

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.
return bool

contract() public static method

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

expandSide() public static method

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

fromFloats() public static method

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.
return Microsoft.Xna.Framework.Rectangle

fromMinMaxPoints() public static method

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.
return Microsoft.Xna.Framework.Rectangle

getCenter() public static method

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

getCenter() public static method

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

getClosestPointOnBoundsToOrigin() public static method

public static getClosestPointOnBoundsToOrigin ( Rectangle &rect ) : Vector2
rect Microsoft.Xna.Framework.Rectangle
return Vector2

getClosestPointOnRectangleBorderToPoint() public static method

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.
return Point

getClosestPointOnRectangleToPoint() public static method

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.
return Vector2

getHalfRect() public static method

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

getHalfSize() public static method

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

getIntersectionDepth() public static method

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
return Vector2

getMax() public static method

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

getPosition() public static method

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

getRectEdgePortion() public static method

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.
return Microsoft.Xna.Framework.Rectangle

getSide() public static method

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

getSweptBroadphaseBounds() public static method

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
return Microsoft.Xna.Framework.Rectangle

getSweptBroadphaseBounds() public static method

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
return Microsoft.Xna.Framework.Rectangle

intersect() public static method

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

rayIntersects() public static method

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

rayIntersects() public static method

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

scale() public static method

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

translate() public static method

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

union() public static method

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.
return void

union() public static method

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.
return void