adding micropython examples (#2286)
* adding micropython examples * adding micropython examples
This commit is contained in:
41
examples/anim/lv_example_anim_1.py
Normal file
41
examples/anim/lv_example_anim_1.py
Normal file
@@ -0,0 +1,41 @@
|
||||
def anim_x_cb(label, v):
|
||||
label.set_x(v)
|
||||
|
||||
def sw_event_cb(e,label):
|
||||
sw = e.get_target()
|
||||
|
||||
if sw.has_state(lv.STATE.CHECKED):
|
||||
a = lv.anim_t()
|
||||
a.init()
|
||||
a.set_var(label)
|
||||
a.set_values(label.get_x(), 100)
|
||||
a.set_time(500)
|
||||
a.set_path_cb(lv.anim_t.path_overshoot)
|
||||
a.set_custom_exec_cb(lambda a,val: anim_x_cb(label,val))
|
||||
lv.anim_t.start(a)
|
||||
else:
|
||||
a = lv.anim_t()
|
||||
a.init()
|
||||
a.set_var(label)
|
||||
a.set_values(label.get_x(), -label.get_width())
|
||||
a.set_time(500)
|
||||
a.set_path_cb(lv.anim_t.path_ease_in)
|
||||
a.set_custom_exec_cb(lambda a,val: anim_x_cb(label,val))
|
||||
lv.anim_t.start(a)
|
||||
|
||||
#
|
||||
# Start animation on an event
|
||||
#
|
||||
|
||||
label = lv.label(lv.scr_act())
|
||||
label.set_text("Hello animations!")
|
||||
label.set_pos(100, 10)
|
||||
|
||||
|
||||
sw = lv.switch(lv.scr_act())
|
||||
sw.center()
|
||||
sw.add_state(lv.STATE.CHECKED)
|
||||
sw.add_event_cb(lambda e: sw_event_cb(e,label), lv.EVENT.VALUE_CHANGED, None)
|
||||
|
||||
|
||||
|
||||
41
examples/anim/lv_example_anim_2.py
Normal file
41
examples/anim/lv_example_anim_2.py
Normal file
@@ -0,0 +1,41 @@
|
||||
def anim_x_cb(obj, v):
|
||||
obj.set_x(v)
|
||||
|
||||
def anim_size_cb(obj, v):
|
||||
obj.set_size(v, v)
|
||||
|
||||
|
||||
#
|
||||
# Create a playback animation
|
||||
#
|
||||
obj = lv.obj(lv.scr_act())
|
||||
obj.set_style_bg_color(lv.palette_main(lv.PALETTE.RED), 0)
|
||||
obj.set_style_radius(lv.RADIUS.CIRCLE, 0)
|
||||
|
||||
obj.align(lv.ALIGN.LEFT_MID, 10, 0)
|
||||
|
||||
a1 = lv.anim_t()
|
||||
a1.init()
|
||||
a1.set_var(obj)
|
||||
a1.set_values(10, 50)
|
||||
a1.set_time(1000)
|
||||
a1.set_playback_delay(100)
|
||||
a1.set_playback_time(300)
|
||||
a1.set_repeat_delay(500)
|
||||
a1.set_repeat_count(lv.ANIM_REPEAT.INFINITE)
|
||||
a1.set_path_cb(lv.anim_t.path_ease_in_out)
|
||||
a1.set_custom_exec_cb(lambda a1,val: anim_size_cb(obj,val))
|
||||
lv.anim_t.start(a1)
|
||||
|
||||
a2 = lv.anim_t()
|
||||
a2.init()
|
||||
a2.set_var(obj)
|
||||
a2.set_values(10, 240)
|
||||
a2.set_time(1000)
|
||||
a2.set_playback_delay(100)
|
||||
a2.set_playback_time(300)
|
||||
a2.set_repeat_delay(500)
|
||||
a2.set_repeat_count(lv.ANIM_REPEAT.INFINITE)
|
||||
a2.set_path_cb(lv.anim_t.path_ease_in_out)
|
||||
a2.set_custom_exec_cb(lambda a1,val: anim_x_cb(obj,val))
|
||||
lv.anim_t.start(a2)
|
||||
Reference in New Issue
Block a user