VecPoint.generate constructor

VecPoint.generate(
  1. int length,
  2. Point generator(
    1. int i
    ), {
  3. bool dispose = true,
})

Implementation

factory VecPoint.generate(int length, Point Function(int i) generator, {bool dispose = true}) {
  final pp = calloc<cvg.VecPoint>()..ref.length = length;
  pp.ref.ptr = calloc<cvg.CvPoint>(length);
  for (var i = 0; i < length; i++) {
    final v = generator(i);
    pp.ref.ptr[i] = v.ref;
    if (dispose) v.dispose();
  }
  return VecPoint.fromPointer(pp);
}