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.


    Fading images at load

    Pythonista
    3
    6
    2251
    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.
    • rb
      rb last edited by

      Hi I’m trying to load in an image using ui.imageView then setting the alpha to 0.0 and then using ui.animate to alter that alpha to a non zero value. I can’t get this to gradually fade however - the alpha just jumps after the specified time.
      What am I doing wrong here? This simple solution has worked fine for me previously for buttons etc.
      I’m going for a gradually blending slideshow effect.

      cvp 1 Reply Last reply Reply Quote 0
      • cvp
        cvp @rb last edited by

        @rb try this

        import ui
        iv = ui.ImageView()
        iv.frame = (0,0,400,400)
        v = ui.View()
        v.frame = iv.frame
        v.background_color = (1,1,1,0)
        iv.add_subview(v)
        iv.present('sheet')
        iv.image = ui.Image.named('test:Peppers')
        def anim():
        	v.background_color = (1,1,1,1)	
        ui.animate(anim,5) 
        
        1 Reply Last reply Reply Quote 0
        • rb
          rb last edited by

          Thankyou - that’s masking an image with a colour and altering the alpha of the colour - isnt there a way to gradually alter an imageViews alpha over time?

          cvp 1 Reply Last reply Reply Quote 0
          • cvp
            cvp @rb last edited by

            @rb try

            import ui
            from objc_util import *
            iv = ui.ImageView()
            iv.frame = (0,0,400,400)
            ObjCInstance(iv).alpha = 0
            iv.present('sheet')
            iv.image = ui.Image.named('test:Peppers')
            def anim():
            	ObjCInstance(iv).alpha = 1
            ui.animate(anim,5) 
            
            1 Reply Last reply Reply Quote 0
            • rb
              rb last edited by

              Thanks that’s exactly what I’m after!

              mikael 1 Reply Last reply Reply Quote 0
              • mikael
                mikael @rb last edited by

                @rb, if you do a lot of little animations, I will once again plug the scripter lib. You can pip install it.

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