Class CairoOp<TCell>
Class for making CairoGrids in different shapes. Copyright Gamelogic. Author Herman Tulleken Since version 1.0 See also AbstractOp
public class CairoOp<TCell> : AbstractOp<ShapeStorageInfo<CairoPoint>>
Type Parameters
TCell
- Inheritance
-
CairoOp<TCell>
- Inherited Members
- Extension Methods
Constructors
CairoOp()
public CairoOp()
CairoOp(ShapeStorageInfo<CairoPoint>, Func<ShapeStorageInfo<CairoPoint>, ShapeStorageInfo<CairoPoint>, ShapeStorageInfo<CairoPoint>>)
public CairoOp(ShapeStorageInfo<CairoPoint> leftShapeInfo, Func<ShapeStorageInfo<CairoPoint>, ShapeStorageInfo<CairoPoint>, ShapeStorageInfo<CairoPoint>> combineShapeInfo)
Parameters
leftShapeInfoShapeStorageInfo<CairoPoint>combineShapeInfoFunc<ShapeStorageInfo<CairoPoint>, ShapeStorageInfo<CairoPoint>, ShapeStorageInfo<CairoPoint>>
Methods
BeginGroup()
Starts a compound shape operation.
Any shape that is defined in terms of other shape operations must use this method, and use Endgroup() to end the definition.
public static CairoShapeInfo<TCell> MyCustomShape(this CairoOp<TCell> op)
{
return
BeginGroup()
.Shape1()
.Union()
.Shape2()
.EndGroup(op);
}
Since version 1.1
public CairoOp<TCell> BeginGroup()
Returns
- CairoOp<TCell>
Default(int, int)
Creates the grid in a shape that spans the entire storage rectangle of the given width and height.
public CairoShapeInfo<TCell> Default(int width, int height)
Parameters
Returns
- CairoShapeInfo<TCell>
FatRectangle(int, int)
[Version(1, 7, 0)]
public CairoShapeInfo<TCell> FatRectangle(int width, int height)
Parameters
Returns
- CairoShapeInfo<TCell>
Hexagon(int)
public CairoShapeInfo<TCell> Hexagon(int side)
Parameters
sideint
Returns
- CairoShapeInfo<TCell>
Parallelogram(int, int)
[Version(1, 7, 0)]
public CairoShapeInfo<TCell> Parallelogram(int width, int height)
Parameters
Returns
- CairoShapeInfo<TCell>
Rectangle(int, int)
[Version(1, 7, 0)]
public CairoShapeInfo<TCell> Rectangle(int width, int height)
Parameters
Returns
- CairoShapeInfo<TCell>
Shape(int, int, Func<CairoPoint, bool>)
The same as Shape with all parameters, but with bottomLeft Point set to CairoPoint.Zero.
public CairoShapeInfo<TCell> Shape(int width, int height, Func<CairoPoint, bool> isInside)
Parameters
widthintheightintisInsideFunc<CairoPoint, bool>
Returns
- CairoShapeInfo<TCell>
Shape(int, int, Func<CairoPoint, bool>, PointyHexPoint)
Use this function to create shapes to ensure they fit into memory.
The test function can test shapes anywhere in space.If you specify the bottom corner (in terms of the storage rectangle), the shape is automatically translated in memory to fit, assuming memory width and height is big enough.
Strategy for implementing new shapes: - First, determine the test function. - Next, draw a storage rectangle that contains the shape. - Determine the storgae rectangle width and height. - Finally, determine the grid-space coordinate of the left bottom corner of the storage rectangle.
Then define your function as follows:
public CairoShapeInfo<TCell> MyShape()
{
Shape(stargeRectangleWidth, storageRectangleHeight, isInsideMyShape, storageRectangleBottomleft);
}
public CairoShapeInfo<TCell> Shape(int width, int height, Func<CairoPoint, bool> isInside, PointyHexPoint bottomLeftCorner)
Parameters
widthintThe widh of the storage rectangle
heightintThe height of the storage rectangle
isInsideFunc<CairoPoint, bool>A function that returns true if a passed point lies inside the shape being defined
bottomLeftCornerPointyHexPointThe grid-space coordinate of the bottom left corner of the storage rect.
Returns
- CairoShapeInfo<TCell>
ShapeFromBase(PointyHexShapeInfo<TCell>)
public CairoShapeInfo<TCell> ShapeFromBase(PointyHexShapeInfo<TCell> baseShapeInfo)
Parameters
baseShapeInfoPointyHexShapeInfo<TCell>
Returns
- CairoShapeInfo<TCell>
Single()
Makes a grid with a single cell that corresponds to the origin.
public CairoShapeInfo<TCell> Single()
Returns
- CairoShapeInfo<TCell>
SingleGroup()
public CairoShapeInfo<TCell> SingleGroup()
Returns
- CairoShapeInfo<TCell>
ThinRectangle(int, int)
[Version(1, 7, 0)]
public CairoShapeInfo<TCell> ThinRectangle(int width, int height)
Parameters
Returns
- CairoShapeInfo<TCell>