applyBleedingPixel method

void applyBleedingPixel({
  1. required Vector2 position,
  2. required Vector2 size,
  3. double factor = 0.04,
  4. double offsetX = 0,
  5. double offsetY = 0,
  6. bool calculatePosition = false,
})

Implementation

void applyBleedingPixel({
  required Vector2 position,
  required Vector2 size,
  double factor = 0.04,
  double offsetX = 0,
  double offsetY = 0,
  bool calculatePosition = false,
}) {
  double bleedingPixel = max(size.x, size.y) * factor;

  bleedingPixel = bleedingPixel > 2 ? 2 : bleedingPixel;
  bleedingPixel = bleedingPixel < 0.6 ? 0.6 : bleedingPixel;
  bool xIsEven = position.x % 2 == 0;
  bool yIsEven = position.y % 2 == 0;
  Vector2 baseP = position;
  if (calculatePosition) {
    baseP = Vector2(position.x * size.x, position.y * size.y);
  }
  this.position = Vector2(
    baseP.x - (xIsEven ? (bleedingPixel / 2) : 0) + offsetX,
    baseP.y - (yIsEven ? (bleedingPixel / 2) : 0) + offsetY,
  );
  this.size = Vector2(
    size.x + (xIsEven ? bleedingPixel : 0),
    size.y + (yIsEven ? bleedingPixel : 0),
  );
}