For the specified y and one offset by half a pixel, return the
        one that results in the fewest pixels turned on, so that when
        the thickness has been enforced to be at least one pixel, no
        extra pixels are needlessly included (which would cause
        double-width lines).

def _minimal_y(self, p):
        """
        For the specified y and one offset by half a pixel, return the
        one that results in the fewest pixels turned on, so that when
        the thickness has been enforced to be at least one pixel, no
        extra pixels are needlessly included (which would cause
        double-width lines).
        """
        y0 = self.pattern_y
        y1 = y0 + self._pixelsize(p)/2.
        return y0 if self._count_pixels_on_line(y0, p) < self._count_pixels_on_line(y1, p) else y1