draw method

  1. @override
void draw(
  1. Screen screen,
  2. Rectangle area
)
override

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;

  final sequence = ITerm2Image.encode(
    image,
    name: name,
    columns: cols,
    rows: rws,
  );

  for (var y = area.minY; y < area.minY + rws && y < area.maxY; y++) {
    for (var x = area.minX; x < area.minX + cols && x < area.maxX; x++) {
      if (x == area.minX && y == area.minY) {
        screen.setCell(x, y, Cell(content: sequence, width: 1));
      } else {
        screen.setCell(x, y, Cell(content: '', width: 0));
      }
    }
  }
}