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;

  if (cols <= 0 || rws <= 0) return;

  final resized = _resizeForTarget(cols, rws);

  final sequence = SixelImage.encode(resized, maxColors: maxColors);

  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));
      }
    }
  }
}