drawCautionTape method

void drawCautionTape(
  1. Rect rect,
  2. int offsetX,
  3. int offsetY
)

Draws a patterned caution tape in the specified rectangular bounds.

Implementation

void drawCautionTape(Rect rect, int offsetX, int offsetY) {
  final clipped = _clipStack.isEmpty ? rect : activeClip.intersect(rect);
  if (clipped.width <= 0 || clipped.height <= 0) return;

  final startX = max(0, clipped.left);
  final startY = max(0, clipped.top);
  final endX = min(width, clipped.right);
  final endY = min(height, clipped.bottom);
  if (startX >= endX || startY >= endY) return;

  final yellow = 0xFFFCD116;
  final charcoal = 0xFF36454F;

  for (var y = startY; y < endY; y++) {
    final ly = y - offsetY;
    final rowOffset = y * width;
    for (var x = startX; x < endX; x++) {
      final lx = x - offsetX;
      final mod = ((lx - ly) % 3 + 3) % 3;
      final char = mod == 0 ? '\u259C' : (mod == 1 ? '\u2599' : ' ');
      final idx = rowOffset + x;
      characters[idx] = char;
      final attrIdx = idx * 3;
      attributes[attrIdx + 0] = yellow;
      attributes[attrIdx + 1] = charcoal;
    }
  }
}