Created
May 6, 2019 01:05
-
-
Save Dirk-Sandberg/5576c23252709870e633227520a3e7df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kivy.app import App | |
from kivy.lang import Builder | |
from kivy.clock import Clock | |
from kivy.animation import Animation | |
# Loads an image from the web, changes it's color and angle. | |
kv = """ | |
<AnimatedImage@AsyncImage>: | |
color: (1,1,1,1) # Setting color for images works best on white images | |
color2: (1,0,0,1) | |
angle: 0 | |
source: "https://www.pinclipart.com/picdir/big/53-534936_up-white-arrows-white-up-arrow-png-clipart.png" | |
canvas.before: | |
PushMatrix | |
Rotate: | |
angle: root.angle | |
axis: 0, 0, 1 | |
origin: root.center | |
Color: | |
rgba: self.color2 | |
Ellipse: | |
pos: self.pos | |
size: self.size#200 * wm.value, 201 * hm.value | |
canvas.after: | |
PopMatrix | |
FloatLayout: | |
AnimatedImage: | |
id: animated_widget | |
size_hint: .1, .1 | |
pos_hint: {"center_x": .5, "center_y": .5} | |
""" | |
kv = Builder.load_string(kv) | |
class MainApp(App): | |
def build(self): | |
return kv | |
def on_start(self): | |
Clock.schedule_interval(self.animate, 4) | |
def animate(self, *args): | |
anim = Animation(color=(1,0,0,1), color2=(1,1,1,1), angle=90, duration=2) | |
anim.bind(on_complete=self.reset_anim) | |
anim.start(self.root.ids.animated_widget) | |
def reset_anim(self, *args): | |
widget = self.root.ids.animated_widget | |
widget.color = (1,1,1,1) | |
widget.color2 = (1,0,0,1) | |
widget.angle= 0 | |
MainApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment