Grid class

Constructors

Grid({required int cellSize, required int width, required int height, required List<int> data})
Grid.empty({required int cellSize, required int width, required int height})
Grid.from2d({required int cellSize, required List<List<int>> data})

Properties

cellSize int
final
data UnmodifiableListView
no setter
hashCode int
The hash code for this object.
no setterinherited
height int
final
length int
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
width int
final

Methods

clone({bool growable = false}) List<int>
debugDraw(Canvas canvas, {Vec2? position, AABB? cullArea}) → void
Draws the grid data as colored rects. Tiles with a value smaller than 0 are skipped.
downLeftNeighborTile(int idx) int?
downNeighborTile(int idx) int?
downRightNeighborTile(int idx) int?
draw(Canvas canvas, TileMap tileMap, {Vec2? position, AABB? cullArea}) → void
forEachDrawArea({required void visit(double screenX, double screenY, int tile), Vec2? position, AABB? cullArea}) → void
forEachNeighbor4(int idx, void visit(int neighborIdx)) → void
Calls visit for each 4-connected neighbor index without allocating.
forEachNeighbor8(int idx, void visit(int neighborIdx)) → void
Calls visit for each 8-connected neighbor index without allocating.
hasNeighborDown(int idx) bool
hasNeighborLeft(int idx) bool
hasNeighborRight(int idx) bool
hasNeighborUp(int idx) bool
inBounds1d(int idx) bool
inBounds2d(int x, int y) bool
inBounds2dScreen(double x, double y) bool
leftNeighborTile(int idx) int?
neighborTiles4(int idx) List<int>
4-connected neighbor tile values. Bounds safe. 1 array allocation.
neighborTiles8(int idx) List<int>
8-connected neighbor tile values. Bounds safe. 1 array allocation.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
rightNeighborTile(int idx) int?
screenToGrid(double x, double y) → (int, int)
setTile1d(int value, {required int idx}) → void
setTile2d(int value, {required int x, required int y}) → void
setTile2dScreen(int value, {required double x, required double y}) → void
tileAt1d(int idx) int
tileAt2d(int x, int y) int
to1d(int x, int y) int
to2d(int idx) → (int, int)
toJson1d() String
toJson2d() String
toString() String
A string representation of this object.
inherited
upLeftNeighborTile(int idx) int?
upNeighborTile(int idx) int?
upRightNeighborTile(int idx) int?

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

debugPalette List<Color>
getter/setter pair