snap method

List<Color> snap(
  1. int w,
  2. int h
)

Implementation

List<Color> snap(int w, int h) {
  List<Color> f = List.generate(w * h, (_) => Colors.transparent);
  for (int x = 0; x < w; x++) {
    for (int y = 0; y < h; y++) {
      f[y * w + x] = getColorAtPixel(
          (x * (image.width - 1) / (w - 1)).floor(),
          (y * (image.height - 1) / (h - 1)).floor());
    }
  }

  return f;
}