module

MJ::Prop

The "prop machine": a rough flat-colour template -> a 2D game prop with a transparent background.

Recipe (validated on barrel / plant / clown):

  1. Nano Banana (edit_references) paints the subject over a solid, known background colour. The template is a rough reference for subject + size/placement; the model paints outside the lines, so we cut the prop out of the RENDER, never the template.
  2. Key on distance-from-background: each pixel's alpha ramps from 0 (equal to the bg colour) to 1 (far from it). This generalises the old black->transparent trick to ANY background colour, so a dark/black subject can be rendered on a contrasting bg (white / chroma green) and still key cleanly.
  3. Optional box-blur on the alpha channel to soften the edge.

No matting model, no strict silhouette fit — soft edges tolerate the drift.

Class methods

generate(client : RunwareClient, template_path : String, spec : PropSpec) : Result

Convenience: read the template from disk. Delegates to the in-memory form. The spec's extra references are read from beside the template.

Source
generate(client : RunwareClient, template_bytes : Bytes, spec : PropSpec, extras : Array(Bytes) = [] of Bytes) : Result

Fully in-memory: template PNG bytes (and any further references) in, {render, prop} canvases out. No disk I/O.

Source
key_out(render : StumpyPNG::Canvas, spec : PropSpec) : StumpyPNG::Canvas

Build the transparent prop from a finished render by keying out the bg colour.

Source

Nested types