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.


    Gradients?

    Pythonista
    2
    2
    1790
    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.
    • wsa
      wsa last edited by

      Any chance for linear and radial gradients in the canvas and scene modules in some future update?

      There are ways to do this in pure python, but it ain't speedy.

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

        To some degree, you can simulate gradients with tinted images. Example:

        from scene import *
        
        class MyScene (Scene):
        	def draw(self):
        		background(0, 0, 0)
        		fill(0, 0, 1) #blue
        		rect(0, 0, 256, 256)
        		tint(1, 0, 0) #red
        		image('Gradient-1', 0, 0, 256, 256)
        		
        run(MyScene())
        

        There are built-in 256x256 pixel images for different types of gradients ('Gradient-1' ... 'Gradient-5'). The gradients all go from fully-transparent to white, so you can achieve different 2-color gradients by drawing a filled rectangle behind the gradient image (which can be tinted with the second color, as in the example above).

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