Barcode2DMatrix.fromXY constructor

Barcode2DMatrix.fromXY(
  1. int width,
  2. int height,
  3. double ratio,
  4. bool isDark(
    1. int x,
    2. int y
    ),
)

Create a 2d barcode matrix from a function callback

Implementation

factory Barcode2DMatrix.fromXY(
  int width,
  int height,
  double ratio,
  bool Function(int x, int y) isDark,
) =>
    Barcode2DMatrix(
        width,
        height,
        ratio,
        Iterable<bool>.generate(width * height, (p) {
          final x = p % height;
          final y = p ~/ height;
          return isDark(y, x);
        }));