Grid
The grid module and package provide a generic implementation of a
two-dimensional matrix slice type. The API is inspired both by the standard Go
slice builtin functions and the image standard package.
It makes no assumptions on the type of the cells, and provides optimized
generic methods for grid iteration and manipulation.
Here's a simple example of usage:
gd := grid.NewGrid[rune](10, 10)
gd.Fill('.')
rg := grid.NewRange(3, 3, 7, 7)
rectangle := gd.Slice(rg)
rectangle.Fill('#')
it := gd.Iterator()
max := gd.Size()
for it.Next() {
fmt.Printf("%c", it.V())
if it.P().X == max.X-1 {
fmt.Print("\n")
}
}
See the documentation for more examples.