draw method
Draws this drawable into screen within area.
Implementation
@override
void draw(Screen screen, Rectangle area) {
final cols = columns ?? area.width;
final rws = rows ?? area.height;
if (cols <= 0 || rws <= 0) return;
final imageSequence = KittyImage.encode(
image,
id: id,
columns: cols,
rows: rws,
quiet: quiet,
);
final sequence = clearBeforeDraw
? '${deleteSequence()}$imageSequence'
: imageSequence;
// Place the escape sequence in the top-left cell and give that cell the
// same width Kitty will advance the real cursor by. `Line.set` marks the
// rest of that row as zero-width placeholders; writing those placeholders
// manually would clear the wide origin cell again.
screen.setCell(area.minX, area.minY, Cell(content: sequence, width: cols));
// Reserve the remaining image rows without emitting text cells. Real
// spaces would be drawn after the Kitty placement and can cover the image
// with the terminal background in Ghostty/Kitty-compatible renderers.
for (var y = area.minY + 1; y < area.minY + rws && y < area.maxY; y++) {
for (var x = area.minX; x < area.minX + cols && x < area.maxX; x++) {
screen.setCell(x, y, Cell.zeroCell());
}
}
}