nominalRect static method

Rect nominalRect(
  1. Vector2 renderedSize,
  2. Vector2 nominalSize, {
  3. required bool pixelPerfect,
})

Area of renderedSize that the tile art really covers.

applyBleedingPixel grows the component by up to two pixels and moves it back by half of that, so the nominal area sits centred inside the rendered one.

Implementation

static Rect nominalRect(
  Vector2 renderedSize,
  Vector2 nominalSize, {
  required bool pixelPerfect,
}) {
  if (!pixelPerfect) {
    return Rect.fromLTWH(0, 0, renderedSize.x, renderedSize.y);
  }
  return Rect.fromLTWH(
    (renderedSize.x - nominalSize.x) / 2,
    (renderedSize.y - nominalSize.y) / 2,
    nominalSize.x,
    nominalSize.y,
  );
}