Discover Packages
github.com/mknyszek/2d
grid
package
Version:
v0.0.0-...-225857b
Opens a new window with list of versions in this module.
Published: Dec 27, 2025
License: BSD-3-Clause
Opens a new window with license information.
Imports: 4
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
Documentation
¶
Ray casts a ray over a grid returning an iterator over all
the grid cells the ray touches.
The ray is assumed to be in the grid's coordinate system.
Rows correspond to Y position and columns correspond to X
position.
type Bools struct {
Rows int
Cols int
}
Bools is a 2D grid of values, one per cell.
The values are assumed to be dense (all present).
Bools is guaranteed to be plain old data if T is
also plain old data.
NewBools returns a new 2D grid of booleans with the provided number of rows and columns.
All returns an iterator over all entries in the grid.
At returns the value at the provided row and column in the grid.
Set sets the value at the provided row and column.
SetAll sets the value of every tile in the grid.
type Dense[T any ] struct {
Data []T
Rows int
Cols int
}
Dense is a 2D grid of values, one per cell.
The values are assumed to be dense (all present).
Dense is guaranteed to be plain old data if T is
also plain old data.
New returns a new 2D grid of values with the provided number of rows and columns.
All returns an iterator over all entries in the grid.
At returns the value at the provided row and column in the grid.
Set sets the value at the provided row and column.
func (d *Dense [T]) SetAll(value T)
SetAll sets the value of every cell in the grid.
type Index struct {
Row, Col int
}
Index is an index into a grid.
Idx is a convenience function for creating an Index.
AABB returns the AABB for the grid cell given the dimension of each cell.
Max returns the maximum point in the cell given the cell dimenions.
Min returns the minimum point in the cell given the cell dimenions.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.