Grid<T> class

Available extensions

Constructors

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

Properties

cellSize int
final
data UnmodifiableListView<T>
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<T>
debugDraw(Canvas canvas, {Vec2? position, AABB? cullArea, List<Color> palette = const [Color(0xFFFFB74D), Color(0xFF64B5F6), Color(0xFF81C784), Color(0xFFE57373), Color(0xFFBA68C8), Color(0xFF4DD0E1), Color(0xFFFFD54F), Color(0xFFA1887F)]}) → void

Available on Grid<int>, provided by the IntGridX extension

Draws the grid data as colored rects. Tiles with a value smaller than 0 are skipped.
downLeftNeighborTile(int idx) → T?
downNeighborTile(int idx) → T?
downRightNeighborTile(int idx) → T?
draw(Canvas canvas, TileMap tileMap, {Vec2? position, AABB? cullArea}) → void

Available on Grid<int>, provided by the IntGridX extension

forEachDrawArea({required void visit(double screenX, double screenY, int tile), Vec2? position, AABB? cullArea}) → void

Available on Grid<int>, provided by the IntGridX extension

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) → T?
neighborTiles4(int idx) List<T>
4-connected neighbor tile values. Bounds safe. 1 array allocation.
neighborTiles8(int idx) List<T>
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) → T?
screenToGrid(double x, double y) → (int, int)
setTile1d(T value, {required int idx}) → void
setTile2d(T value, {required int x, required int y}) → void
setTile2dScreen(T value, {required double x, required double y}) → void
tileAt1d(int idx) → T
tileAt2d(int x, int y) → T
to1d(int x, int y) int
to2d(int idx) → (int, int)
toJson1d() String

Available on Grid<int>, provided by the IntGridX extension

toJson2d() String

Available on Grid<int>, provided by the IntGridX extension

toString() String
A string representation of this object.
inherited
upLeftNeighborTile(int idx) → T?
upNeighborTile(int idx) → T?
upRightNeighborTile(int idx) → T?

Operators

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