Disable canvas AA
I am trying to build a custom ray renderer in Pythonista, using canvas as a buffer to draw pixels on the screen. It’s probably not the best approach but anyway, when I disable AA with
pythonista still smooths everything out. Keep in mind I am drawing pixel by pixel as 1:1 rectangles.
One tricky bit is that pixels in iOS are not really physical pixels. You draw in points, but you probably have a 2x or 4x device.
A better way to do pixel mashing is to use a numpy array, and use that as a backing to an IOSurface.
For a long thread about a few different topics about doing fast real time things in pythonista, see
In particular, take a look at the IOSurfaceWrapper, included at the start of
This exposes a numpy array that is m x n x 4, which allows you to set pixels as desired, inside the .Lock() context manager.
Since you are doing raycasting, you may be able to do efficient vectorized equations that lets you calculate the whole array at once.