squeezed function

void squeezed(
  1. Painter p,
  2. ActorDefinition actor,
  3. Uint8List sh,
  4. double sx,
  5. int body,
  6. int edge, [
  7. double a = 1.0,
  8. double dx = 0.0,
])

Implementation

void squeezed(
  Painter p,
  ActorDefinition actor,
  Uint8List sh,
  double sx,
  int body,
  int edge, [
  double a = 1.0,
  double dx = 0.0,
]) {
  if (sx <= 0.02) return;
  final cx = actor.x + actor.w / 2.0;
  final half = actor.w / 2.0 + 1.0;
  for (var y = 0; y < actor.h; y++) {
    for (var x = (cx - half * sx).floor();
        x <= (cx + half * sx).ceil();
        x++) {
      final raw = cx + (x + 0.5 - cx) / sx - 0.5;
      final i = (raw + 0.5).floor() - actor.x;
      final v = (i < 0 || i >= actor.w) ? 0 : sh[y * actor.w + i];
      if (v != 0) {
        p.dot(x + dx, (actor.y + y).toDouble(), v == 1 ? edge : body, a);
      }
    }
  }
}