jitterOffset function

(double, double) jitterOffset(
  1. int frame,
  2. int length
)

Frame frame's sub-pixel offset, in pixels within [-0.5, 0.5), from a Halton(2, 3) sequence that repeats every length frames — R1.

Counted from one, as the sequence usually is: its first point, (0, 0), is the pixel centre on both axes, and a cycle that spent a frame there would weight the centre twice.

Implementation

(double, double) jitterOffset(int frame, int length) {
  final index = frame % (length < 1 ? 1 : length) + 1;
  return (_halton(index, 2) - 0.5, _halton(index, 3) - 0.5);
}