drawRectFilled method

Future<void> drawRectFilled(
  1. int x,
  2. int y,
  3. int w,
  4. int h,
  5. int borderWidth,
  6. PaletteColors borderColor,
  7. PaletteColors fillColor,
)

Draws a filled rectangle with a border on the display.

Args: x (int): The left pixel position of the rectangle. y (int): The top pixel position of the rectangle. w (int): The width of the rectangle. h (int): The height of the rectangle. borderWidth (int): The width of the border. borderColor (PaletteColors): The color of the border. fillColor (PaletteColors): The fill color of the rectangle.

Implementation

Future<void> drawRectFilled(
  int x,
  int y,
  int w,
  int h,
  int borderWidth,
  PaletteColors borderColor,
  PaletteColors fillColor,
) async {
  String luaToSend = '';
  w = (w ~/ 8) * 8;
  if (borderWidth > 0) {
    borderWidth = (borderWidth ~/ 8) * 8;
    if (borderWidth == 0) {
      borderWidth = 8;
    }
  } else {
    await frame.runLua(_drawRectLua(x, y, w, h, fillColor), checked: true);
    return;
  }

  luaToSend += _drawRectLua(x, y, w, h, borderColor);
  luaToSend += _drawRectLua(
    x + borderWidth,
    y + borderWidth,
    w - borderWidth * 2,
    h - borderWidth * 2,
    fillColor,
  );
  await frame.runLua(luaToSend, checked: true);
}