class

Opal::UI::MaskMap

Inherits Reference < Object

A 2D normalized weight map (values from 0.0 to 1.0) used for alpha stencil masking, spotlights, and feathered dithering effects in terminal screen buffers.

Constants

DITHER_CHARS = Opal::Glyphs::Shades

Shading characters for dithering fractional alpha values: 0.0 -> 1.0

Constructors

box(bx : Int32, by : Int32, bw : Int32, bh : Int32, feather : Float64 = 0.0, width : Int32 = 80, height : Int32 = 25) : MaskMap

Generates a rectangular box mask with optional feathering around its perimeter

Source
checkerboard(tile_w : Int32 = 4, tile_h : Int32 = 2, width : Int32 = 80, height : Int32 = 25) : MaskMap

Generates a checkerboard mask pattern

Source
linear_gradient(angle_degrees : Float64, width : Int32 = 80, height : Int32 = 25, start_val : Float64 = 0.0, end_val : Float64 = 1.0) : MaskMap

Generates a linear gradient mask along a specified angle (in degrees, 0 = left-to-right, 90 = top-to-bottom)

Source
new(width : Int32, height : Int32, initial_weight : Float64 = 1.0)
Source
radial(cx : Float64 | Int32, cy : Float64 | Int32, radius : Float64, feather : Float64 = 0.0, width : Int32 = 80, height : Int32 = 25, aspect_ratio : Float64 = 2.0) : MaskMap

Generates a circular or elliptical radial mask centered at (cx, cy) with optional feathering. Terminal cells have an aspect ratio of roughly 2:1 (height:width), which is compensated for.

Source
stencil(lines : Array(String), width : Int32 | Nil = nil, height : Int32 | Nil = nil) : MaskMap

Generates a stencil mask from an array of ASCII strings (non-space characters become 1.0)

Source

Class methods

dither_char(weight : Float64) : Char

Returns a dither shade character for a given alpha weight (0.0..1.0)

Source

Instance methods

[](x : Int32, y : Int32) : Float64
Source
[]=(x : Int32, y : Int32, weight : Float64) : Nil
Source
blend(other : MaskMap, mode : Symbol = :multiply) : MaskMap

Blends this mask with another mask using :multiply, :screen, :add, or :subtract

Source
fill(weight : Float64) : Nil
Source
get(x : Int32, y : Int32) : Float64
Source
height
Source
in_bounds?(x : Int32, y : Int32) : Bool
Source
invert

Inverts all mask weights (1.0 - weight)

Source
set(x : Int32, y : Int32, weight : Float64) : Nil
Source
weights
Source
width
Source