generateRectWithBleedingPixel method

Vector2Rect generateRectWithBleedingPixel(
  1. Vector2 position,
  2. double width,
  3. double height, {
  4. double offsetX = 0,
  5. double offsetY = 0,
})

Implementation

Vector2Rect generateRectWithBleedingPixel(
  Vector2 position,
  double width,
  double height, {
  double offsetX = 0,
  double offsetY = 0,
}) {
  double sizeMax = max(width, height);
  double blendingPixel = sizeMax * 0.05;

  if (blendingPixel > 2) {
    blendingPixel = 2;
  }

  return Rect.fromLTWH(
    (position.x * width) -
        (position.x % 2 == 0 ? (blendingPixel / 2) : 0) +
        offsetX,
    (position.y * height) -
        (position.y % 2 != 0 ? (blendingPixel / 2) : 0) +
        offsetY,
    width + (position.x % 2 == 0 ? blendingPixel : 0),
    height + (position.y % 2 != 0 ? blendingPixel : 0),
  ).toVector2Rect();
}