← back to roto on ba3a.dev

Mask

class Mask

A rectangular grid of foreground (true) and background (false) pixels, row-major from the top-left corner: which pixels of a frame belong to the figure.

The binary counterpart of Raster. Equality is by size and content, and it is mutable through set in the same way, so brush fixes can paint into a copy.

Constructors

Link copied to clipboard
constructor(width: Int, height: Int)

An all-background mask.

Types

Link copied to clipboard
object Companion

Creation of whole grids.

Properties

Link copied to clipboard
val height: Int

the height in pixels

Link copied to clipboard
val width: Int

the width in pixels

Functions

Link copied to clipboard
fun contains(x: Int, y: Int): Boolean

Whether (x, y) lies inside the grid.

Link copied to clipboard
fun copy(): Mask

A copy; later writes to either one do not show in the other.

Link copied to clipboard
fun count(): Int

How many pixels are foreground.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Equal when the size and every pixel are.

Link copied to clipboard
operator fun get(x: Int, y: Int): Boolean

Whether the pixel at (x, y) is foreground.

Link copied to clipboard
open override fun hashCode(): Int

Consistent with equals.

Link copied to clipboard
operator fun set(x: Int, y: Int, foreground: Boolean)

Marks the pixel at (x, y) as foreground or background.

Link copied to clipboard

The pixels as a fresh row-major array; writing to it does not change this mask.

Link copied to clipboard

Foreground as opaque white, background as transparent: how a mask is stored and previewed.

Link copied to clipboard
open override fun toString(): String

The size, for messages and tests.