class
Opal::UI::MaskMap
- Opal::UI::MaskMap
- Reference
- Object
Overview
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.
Defined in:
opal/ui/mask.crConstant Summary
-
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
-
.checkerboard(tile_w : Int32 = 4, tile_h : Int32 = 2, width : Int32 = 80, height : Int32 = 25) : MaskMap
Generates a checkerboard mask pattern
-
.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)
- .new(width : Int32, height : Int32, initial_weight : Float64 = 1.0)
-
.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.
-
.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)
Class Method Summary
-
.dither_char(weight : Float64) : Char
Returns a dither shade character for a given alpha weight (0.0..1.0)
Instance Method Summary
- #[](x : Int32, y : Int32) : Float64
- #[]=(x : Int32, y : Int32, weight : Float64) : Nil
-
#blend(other : MaskMap, mode : Symbol = :multiply) : MaskMap
Blends this mask with another mask using :multiply, :screen, :add, or :subtract
- #fill(weight : Float64) : Nil
- #get(x : Int32, y : Int32) : Float64
- #height : Int32
- #in_bounds?(x : Int32, y : Int32) : Bool
-
#invert : MaskMap
Inverts all mask weights (1.0 - weight)
- #set(x : Int32, y : Int32, weight : Float64) : Nil
- #weights : Array(Float64)
- #width : Int32
Constructor Detail
Generates a rectangular box mask with optional feathering around its perimeter
Generates a checkerboard mask pattern
Generates a linear gradient mask along a specified angle (in degrees, 0 = left-to-right, 90 = top-to-bottom)
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.
Generates a stencil mask from an array of ASCII strings (non-space characters become 1.0)
Class Method Detail
Returns a dither shade character for a given alpha weight (0.0..1.0)
Instance Method Detail
Blends this mask with another mask using :multiply, :screen, :add, or :subtract