Class PointExtensions
Contains set of operators that match ones defined by other packages for interoperability, so syntax may be uniform. Functionality is similar to the corresponding actual operators for Point.
Namespace: SadRogue.Primitives
Assembly: TheSadRogue.Primitives.dll
Syntax
public static class PointExtensions : Object
Methods
Add(Point, Direction)
Translates the current position by one unit in the given direction.
Declaration
public static Point Add(this Point self, Direction dir)
Parameters
Type | Name | Description |
---|---|---|
Point | self | |
Direction | dir |
Returns
Type | Description |
---|---|
Point | Position (self.X + dir.DeltaX, self.Y + dir.DeltaY) |
Add(Point, Point)
Adds the given Point's x/y values to the current Point's x/y values.
Declaration
public static Point Add(this Point self, Point other)
Parameters
Type | Name | Description |
---|---|---|
Point | self | |
Point | other |
Returns
Type | Description |
---|---|
Point | Position (self.X + other.X, self.Y + other.Y). |
Add(Point, Int32)
Adds the given scalar to the current Point's x/y values.
Declaration
public static Point Add(this Point self, int i)
Parameters
Type | Name | Description |
---|---|---|
Point | self | |
Int32 | i |
Returns
Type | Description |
---|---|
Point | Position (self.X + i, self.Y + i). |
Divide(Point, Point)
Divides the current Point's x/y values by the given Point's x/y values, rounding to the nearest integer.
Declaration
public static Point Divide(this Point self, Point other)
Parameters
Type | Name | Description |
---|---|---|
Point | self | |
Point | other |
Returns
Type | Description |
---|---|
Point | Position (self.X / other.X, self.Y / other.Y), with each value rounded to the nearest integer. |
Divide(Point, Double)
Divides the current Point's x/y values by the given scalar, rounding to the nearest integer.
Declaration
public static Point Divide(this Point self, double d)
Parameters
Type | Name | Description |
---|---|---|
Point | self | |
Double | d |
Returns
Type | Description |
---|---|
Point | Position(self.X / d, self.Y / d), with each value rounded to the nearest integer. |
Divide(Point, Int32)
Divides the current Point's x/y values by the given scalar, rounding to the nearest integer.
Declaration
public static Point Divide(this Point self, int i)
Parameters
Type | Name | Description |
---|---|---|
Point | self | |
Int32 | i |
Returns
Type | Description |
---|---|
Point | Position(self.X / i, self.Y / i), with each value rounded to the nearest integer. |
Matches(Point, Point)
Compares the two points for equality; equivalent to Matches(Point).
Declaration
public static bool Matches(this Point self, Point other)
Parameters
Type | Name | Description |
---|---|---|
Point | self | |
Point | other |
Returns
Type | Description |
---|---|
Boolean | True if the two points are equal; false otherwise. |
Multiply(Point, Point)
Multiplies the current Point's x/y values by the given Point's x/y values.
Declaration
public static Point Multiply(this Point self, Point other)
Parameters
Type | Name | Description |
---|---|---|
Point | self | |
Point | other |
Returns
Type | Description |
---|---|
Point | Position (self.X * other.X, self.Y * other.Y). |
Multiply(Point, Double)
Multiplies the current Point's x/y values by the given scalar, rounding to the nearest integer.
Declaration
public static Point Multiply(this Point self, double d)
Parameters
Type | Name | Description |
---|---|---|
Point | self | |
Double | d |
Returns
Type | Description |
---|---|
Point | Position (self.X * d, self.Y * d), with each value rounded to the nearest integer. |
Multiply(Point, Int32)
Multiplies the current Point's x/y values by the given scalar.
Declaration
public static Point Multiply(this Point self, int i)
Parameters
Type | Name | Description |
---|---|---|
Point | self | |
Int32 | i |
Returns
Type | Description |
---|---|
Point | Position (self.X * i, self.Y * i). |
Subtract(Point, Direction)
Translates the current position by one unit in the opposite of the given direction.
Declaration
public static Point Subtract(this Point self, Direction dir)
Parameters
Type | Name | Description |
---|---|---|
Point | self | |
Direction | dir |
Returns
Type | Description |
---|---|
Point | Position (self.X - dir.DeltaX, self.Y - dir.DeltaY) |
Subtract(Point, Point)
Subtracts the given Point's x/y values from the current Point's x/y values.
Declaration
public static Point Subtract(this Point self, Point other)
Parameters
Type | Name | Description |
---|---|---|
Point | self | |
Point | other |
Returns
Type | Description |
---|---|
Point | Position (self.X - other.X, self.Y - other.Y). |
Subtract(Point, Int32)
Subtracts the given scalar from the current Point's x/y values.
Declaration
public static Point Subtract(this Point self, int i)
Parameters
Type | Name | Description |
---|---|---|
Point | self | |
Int32 | i |
Returns
Type | Description |
---|---|
Point | Position (self.X - i, self.Y - i). |