public PointyTriShapeInfo <TCell> Default(int width, int height) { var rawInfow = MakeShapeStorageInfo <PointyTriPoint>( width, height, x => PointyTriGrid <TCell> .DefaultContains(x, width, height)); return(new PointyTriShapeInfo <TCell>(rawInfow)); }
public IGrid <TNewCell, PointyTriPoint> MakeVertexGrid <TNewCell>() { var vertices = this.SelectMany(x => x.GetVertices()); var storage = PointyTriGrid <TNewCell> .CalculateStorage(vertices); var offset = PointyTriGrid <TNewCell> .GridPointFromArrayPoint(storage.offset); return(new PointyTriGrid <TNewCell>(storage.dimensions.X, storage.dimensions.Y, x => IsInsideVertexGrid(x + offset), offset)); }
/** * @param n Must be positive */ public PointyTriHexagonWrapper(int side) { if (side <= 0) { throw new Exception("n Must be a positive integer."); } int colorCount = 3 * side * side; colorFunc = x => x.GetColor(colorCount / side, side, side); wrappedPoints = new PointyTriPoint[colorCount * 2]; var grid = PointyTriGrid <int> .Hexagon(side); foreach (var point in grid) { int color = colorFunc(point); wrappedPoints[color] = point; } }
public static bool __CompilerHint__PointyTri__MeshTileCell() { var grid1 = new FlatHexGrid <MeshTileCell[]>(1, 1); foreach (var point in grid1) { grid1[point] = new MeshTileCell[1]; } var grid2 = new PointyTriGrid <MeshTileCell>(1, 1); foreach (var point in grid2) { grid2[point] = null; } var shapeStorageInfo = new ShapeStorageInfo <PointyTriPoint>(new IntRect(), p => true); var shapeInfo = new PointyTriShapeInfo <MeshTileCell>(shapeStorageInfo); return(grid1[grid1.First()][0] == null || grid2[grid2.First()] == null || shapeInfo.IncIndex(0) != null); }
protected override void InitGrid() { VectorPoint rectDimensions = Dimensions; switch (shape) { case Shape.Rectangle: base.Grid = PointyTriGrid <TileCell> .Rectangle(rectDimensions.X, rectDimensions.Y); break; case Shape.Parallelogram: base.Grid = PointyTriGrid <TileCell> .ParallelogramXY(rectDimensions.X, rectDimensions.Y); break; case Shape.ThinRectangle: base.Grid = PointyTriGrid <TileCell> .ThinRectangle(rectDimensions.X, rectDimensions.Y); break; case Shape.FatRectangle: base.Grid = PointyTriGrid <TileCell> .FatRectangle(rectDimensions.X, rectDimensions.Y); break; case Shape.LeftTriangle: base.Grid = PointyTriGrid <TileCell> .LeftTriangle(size); break; case Shape.RightTriangle: base.Grid = PointyTriGrid <TileCell> .RightTriangle(size); break; case Shape.Hexagon: base.Grid = PointyTriGrid <TileCell> .Hexagon(size); break; case Shape.Star: base.Grid = PointyTriGrid <TileCell> .Star(size); break; case Shape.Single: base.Grid = PointyTriGrid <TileCell> .Single(); break; case Shape.SingleGroup: base.Grid = PointyTriGrid <TileCell> .SingleGroup(); break; case Shape.Custom: base.Grid = GetCustomGrid(); break; default: throw new ArgumentOutOfRangeException(); } }
protected override ArrayPoint ArrayPointFromGridPoint(FlatHexPoint point) { return(PointyTriGrid <TCell> .ArrayPointFromGridPoint(point)); }
protected override FlatHexPoint GridPointFromArrayPoint(ArrayPoint point) { return(PointyTriGrid <TCell> .GridPointFromArrayPoint(point)); }
/** * 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 PointyTriShapeInfo<TCell> MyCustomShape(this PointyTriOp<TCell> op) * { * return * BeginGroup() * .Shape1() * .Union() * .Shape2() * .EndGroup(op); * } * * @since 1.1 */ public PointyTriOp <TCell> BeginGroup() { return(PointyTriGrid <TCell> .BeginShape()); }