Skip to content

PointExtensions Class

Extensions for the SadRogue.Primitives.Point type.

C#
public static class PointExtensions

Inheritance object

Translates a surface cell position to where it appears on the screen in pixels.

C#
public static Point SurfaceLocationToPixel(this Point point, int cellWidth, int cellHeight)

point SadRogue.Primitives.Point
The current cell position.

cellWidth int
The width of a cell in pixels.

cellHeight int
The height of a cell in pixels.

SadRogue.Primitives.Point
The pixel position of the top-left of the cell.

Translates a surface cell position to where it appears on the screen in pixels.

C#
public static Point SurfaceLocationToPixel(this Point point, Point fontSize)

point SadRogue.Primitives.Point
The current cell position.

fontSize SadRogue.Primitives.Point
The font to use in calculating the position.

SadRogue.Primitives.Point
The pixel position of the top-left of the cell.

Translates a pixel to where it appears on a surface cell.

C#
public static Point PixelLocationToSurface(this Point point, int cellWidth, int cellHeight)

point SadRogue.Primitives.Point
The current world position.

cellWidth int
The width of a cell in pixels.

cellHeight int
The height of a cell in pixels.

SadRogue.Primitives.Point
The cell position on the screen.

Translates a pixel to where it appears on a surface cell.

C#
public static Point PixelLocationToSurface(this Point point, Point fontSize)

point SadRogue.Primitives.Point
The current world position.

fontSize SadRogue.Primitives.Point
The font to use in calculating the position.

SadRogue.Primitives.Point
The cell position on the screen.

Translates the coordinates of a cell from the source font size to a target font size.

C#
public static Point TranslateFont(this Point point, Point sourceFontSize, Point targetFontSize)

point SadRogue.Primitives.Point
The position of the cell in the sourceFontSize.

sourceFontSize SadRogue.Primitives.Point
The source font translating from.

targetFontSize SadRogue.Primitives.Point
The target font translating to.

SadRogue.Primitives.Point
The position of the cell in the targetFontSize.

Gets a list of indexed boolean values to indicate if the direction from the position falls in the area.

C#
public static bool[] GetValidDirections(this Point position, Rectangle area)

position SadRogue.Primitives.Point
The position to test from.

area SadRogue.Primitives.Rectangle
The area to test.

bool[]
An array of bool values indicating if the direction is valid or not; indexed by a SadRogue.Primitives.Direction.Types enumeration. Index 0 in the array represents the position.

Gets an indexed array of direction positions based on the position.

C#
public static Point[] GetDirectionPoints(this Point position)

position SadRogue.Primitives.Point
The source position.

SadRogue.Primitives.Point[]
An array of positions indexed by a SadRogue.Primitives.Direction.Types enumeration. Index 0 in the array represents the position.

GetDirectionIndexes(Point, Rectangle, int)

Section titled “GetDirectionIndexes(Point, Rectangle, int)”

Gets an array of indexes of a surface based on a position and then a relative SadRogue.Primitives.Direction.Type direction enumeration..

C#
public static int[] GetDirectionIndexes(this Point position, Rectangle area, int width)

position SadRogue.Primitives.Point
The position center.

area SadRogue.Primitives.Rectangle
The area containing the position.

width int
The width to use in converting each index to a point.

int[]
Returns the an array of values indidcating the index in the area surface of each direction where -1 represents a position outside the bounds of the area. Indexed by a SadRogue.Primitives.Direction.Types enumeration.