Is it possible to show the line being drawn instead of the line instantly appearing. I tried to make multiple loading bars and rotate but figured that making the Lines would be a bit simpler.
I have my outline that I would like to follow and every right angle would be its own line being drawn. On_pre_enter my out line is already given and on_enter the red line is already drawn but I would like that to be drawn when entering over a given time. I added in amin
lines after with self.canvas.before:
but the screen is animated and not the Line.
mazeupdate.py
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
from kivy.clock import Clock
from kivy.properties import NumericProperty
from kivy.uix.progressbar import ProgressBar
from kivy.config import Config
from kivy.graphics import Line, Color, Rectangle
from kivy.animation import Animation
class results(Screen):
def on_pre_enter(self):
with self.canvas.before:
Color(1,1,1)
Line(points=[100, 100, 100, 200, 200, 200, 200, 100, 300, 100, 300, 200], width=3)
def on_enter(self):
with self.canvas.before:
Color(1,0,0)
Line(points=[100, 100, 100, 200], width=5)
anim = Animation(pos=(80, 10))
anim &= Animation(size=(800, 800), duration=5)
anim.start(self)
class mazeupdateApp(App):
Config.set('graphics', 'width', '800')
Config.set('graphics', 'height', '600')
def build(self):
FadeTransition.clearcolor = (1,1,1,1)
sm = ScreenManager(transition=FadeTransition())
sm.add_widget(results(name='one'))
return sm
if __name__ == '__main__':
mazeupdateApp().run()
You can animate the end point of the line, and then redraw the line with every change to the end point:
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
from kivy.properties import ListProperty
from kivy.config import Config
from kivy.graphics import Line, Color
from kivy.animation import Animation
class results(Screen):
anim_pt = ListProperty([]) # this is the line endpoint
def on_pre_enter(self):
with self.canvas.before:
Color(1,1,1)
Line(points=[100, 100, 100, 200, 200, 200, 200, 100, 300, 100, 300, 200], width=3)
def on_enter(self):
# start the red line with no points
with self.canvas.before:
Color(1,0,0)
self.line = Line(width=5) # saves a reference to the line
# animate the end point (self.anim_pt)
self.anim_pt = [100, 100]
anim = Animation(anim_pt=[100, 200], d=3)
anim.start(self)
def on_anim_pt(self, widget, progress):
# called when anim_pt changes
# set up the line points
points = [100, 100]
points.extend(self.anim_pt)
# remove the old line
self.canvas.before.remove(self.line)
# draw the updated line
with self.canvas.before:
self.line = Line(points=points, width=5)
class mazeupdateApp(App):
Config.set('graphics', 'width', '800')
Config.set('graphics', 'height', '600')
def build(self):
FadeTransition.clearcolor = (1,1,1,1)
sm = ScreenManager(transition=FadeTransition())
sm.add_widget(results(name='one'))
return sm
if __name__ == '__main__':
mazeupdateApp().run()