omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Disable canvas AA

    Pythonista
    2
    2
    767
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Minatory
      Minatory last edited by

      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 canvas.set_aa_enabled(False)
      pythonista still smooths everything out. Keep in mind I am drawing pixel by pixel as 1:1 rectangles.

      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        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
        https://forum.omz-software.com/topic/5155/real-time-audio-buffer-synth-real-time-image-smudge-tool

        In particular, take a look at the IOSurfaceWrapper, included at the start of
        https://gist.github.com/medericmotte/37e43e477782ce086880e18f5dbefcc8

        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.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Powered by NodeBB Forums | Contributors