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.


    Set color key in scene module

    Pythonista
    2
    3
    2431
    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.
    • jb145491
      jb145491 last edited by

      Anybody here who has used the pygame module before should know about a colorkey. How do I set it?

      PS. In case anybody didn't know, a colorkey is a RGB(A) value that when bound to a picture, replaces all pixels that are the color of the colorkey with another color, or transparent.

      Any ideas?

      Some thoughts running through my mind:

      1. Maybe go pixel by pixel in a for loop. Use an if statement to determine if the pixel is that color. No clue how to do that.
      2. Find a colorkey function. No clue how to do that.
      3. Be open to suggestions. I know how to do that.
      1 Reply Last reply Reply Quote 0
      • dgelessus
        dgelessus last edited by

        Why use color-keying when PNG files have a real alpha channel? It's a lot less work to convert your textures to PNG and add a proper alpha channel, if you ask me. In any case, PIL.Image.Image.putalpha may be what you're looking for. The docs aren't very clear about what exactly the band argument means though.

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

          I have images in my clipboard I am using, plus the colorkey should be pretty easy. In pygame:

          pygame.image.set_colorkey(0, 0, 0)
          This takes any black on the image and converts it to clear.

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