Grid

io.github.srs.model.illumination.model.Grid$package.Grid
object Grid

Companion object for the Grid type, providing utility methods for grid manipulation.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Grid.type

Members list

Value members

Concrete methods

def overlayMax[A : ClassTag](base: Grid[A], over: Grid[A])(using evidence$1: ClassTag[A], num: Numeric[A]): Grid[A]

Overlay two grids taking the maximum at each cell.

Overlay two grids taking the maximum at each cell.

Value parameters

base

The base grid.

over

The overlay grid.

Attributes

Returns

A new grid where each cell contains the maximum value from the corresponding cells of the base and overlay grids.

def tabulate[A : ClassTag](w: Int, h: Int)(f: (Int, Int) => A): Array[Array[A]]

Create a grid by tabulating a function over coordinates.

Create a grid by tabulating a function over coordinates.

Type parameters

A

The type of elements in the grid.

Value parameters

f

A function that takes the x and y coordinates and returns the value for that cell.

h

The height of the grid (number of rows).

w

The width of the grid (number of columns).

Attributes

Returns

A two-dimensional array representing the grid.

Extensions

Extensions

extension [A](g: Array[Array[A]])
inline def height: Int

Gets the height (cells) of the grid (number of rows).

Gets the height (cells) of the grid (number of rows).

Attributes

Returns

The height of the grid.

inline def inBounds(x: Int, y: Int): Boolean

Checks if the given coordinates are within the bounds of the grid.

Checks if the given coordinates are within the bounds of the grid.

Value parameters

x

The x-coordinate to check.

y

The y-coordinate to check.

Attributes

Returns

true if the coordinates are within bounds, false otherwise.

inline def isEmpty: Boolean

Checks if the grid is empty.

Checks if the grid is empty.

Attributes

Returns

true if the grid is empty, false otherwise.

inline def width: Int

Gets the width (cells) of the grid (number of columns).

Gets the width (cells) of the grid (number of columns).

Attributes

Returns

The width of the grid.

extension [A](g: Array[Array[A]])
def flattenRowMajor: ArraySeq[A]

Flattens the grid in row-major order (x-fast).

Flattens the grid in row-major order (x-fast).

Attributes

Returns

An ArraySeq containing all elements of the grid in row-major order.