module

MJ::CanvasUtil

Pure-Crystal image compositing helpers built on stumpy. Used by the scenery-strip pipeline to crop tile edges, build inpaint masks, and stitch tiles + generated bridges into one long image.

Constants

BLACK = StumpyPNG::RGBA.new(0_u16, 0_u16, 0_u16, 65535_u16)
WHITE = StumpyPNG::RGBA.new(65535_u16, 65535_u16, 65535_u16, 65535_u16)

Class methods

bridge_mask(width : Int32, height : Int32, context_a : Int32, gap : Int32, feather : Int32) : StumpyPNG::Canvas

Build an inpaint mask for a bridge canvas laid out as [ context_a | gap | context_b ]. White = regenerate, black = preserve. A feather-pixel gray ramp on each side of the gap softens the seam.

Source
crop(src : StumpyPNG::Canvas, x : Int32, y : Int32, w : Int32, h : Int32) : StumpyPNG::Canvas

Copy a sub-rectangle out of a canvas.

Source
fill_edge_extend(dst : StumpyPNG::Canvas, left : StumpyPNG::Canvas, left_x : Int32, right : StumpyPNG::Canvas, right_x : Int32, gx : Int32, gw : Int32, height : Int32)

Fill a gap [gx, gx+gw) by extending each neighbour's facing column across its half of the gap (left column over the left half, right over the right). Preserves vertical structure (horizon, deck) without horizontal smearing — a cleaner seed for reference-image editors than a cross-blend.

Source
fill_hblend(dst : StumpyPNG::Canvas, left : StumpyPNG::Canvas, left_x : Int32, right : StumpyPNG::Canvas, right_x : Int32, gx : Int32, gw : Int32, height : Int32)

Fill a gap [gx, gx+gw) in dst with a per-row linear blend between left's column left_x and right's column right_x. Gives an inpaint model coherent pixels to refine instead of an empty hole.

Source
from_png_bytes(bytes : Bytes) : StumpyPNG::Canvas
Source
from_png_file(path : String) : StumpyPNG::Canvas
Source
hconcat(canvases : Array(StumpyPNG::Canvas)) : StumpyPNG::Canvas

Concatenate canvases left-to-right. Height is the max of the inputs; shorter canvases are top-aligned on a black background.

Source
paste(dst : StumpyPNG::Canvas, src : StumpyPNG::Canvas, ox : Int32, oy : Int32)

Paste src onto dst with its top-left at (ox, oy).

Source
resize(src : StumpyPNG::Canvas, w : Int32, h : Int32) : StumpyPNG::Canvas

Bilinear resize to exactly (w, h). Returns src unchanged if already that size.

Source
to_png_bytes(canvas : StumpyPNG::Canvas) : Bytes
Source
write_png_file(canvas : StumpyPNG::Canvas, path : String)
Source