diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-11-12 19:14:09 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-11-12 19:14:09 +1100 |
| commit | 8a0a167adbf3d9b6f8b6f16aaf20ca39ad5549de (patch) | |
| tree | 02b6cf23f591915747ec2994381854a79979c4a0 /lib/luavgl/examples/animation.lua | |
| parent | 8471046a95ab9e00f7d42b56dbbc9ce3e5b424b9 (diff) | |
| download | tangara-fw-8a0a167adbf3d9b6f8b6f16aaf20ca39ad5549de.tar.gz | |
Convert the main menu screen to lua lol
Diffstat (limited to 'lib/luavgl/examples/animation.lua')
| -rw-r--r-- | lib/luavgl/examples/animation.lua | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/lib/luavgl/examples/animation.lua b/lib/luavgl/examples/animation.lua new file mode 100644 index 00000000..95ee5f5a --- /dev/null +++ b/lib/luavgl/examples/animation.lua @@ -0,0 +1,61 @@ +local root = lvgl.Object() +root:set { w = lvgl.HOR_RES(), h = lvgl.VER_RES() } + +-- create image on root and set position/img src/etc. properties. +root:Object():Image { + src = SCRIPT_PATH .. "/assets/lvgl-logo.png", + x = 0, + y = 0, + bg_color = 0x004400, + pad_all = 0, + align = lvgl.ALIGN.CENTER, +}:Anim { + run = true, + start_value = 0, + end_value = 3600, + duration = 2000, + repeat_count = 2, + path = "bounce", + exec_cb = function(obj, value) + obj:set { + angle = value + } + end, + done_cb = function (anim, obj) + print("anim done.: ", anim, "obj:", obj) + anim:delete() + end +} + +-- second anim example with playback +local obj = root:Object { + bg_color = "#F00000", + radius = lvgl.RADIUS_CIRCLE, + align = lvgl.ALIGN.LEFT_MID, +} +obj:clear_flag(lvgl.FLAG.SCROLLABLE) + +--- @type AnimPara +local animPara = { + run = true, + start_value = 10, + end_value = 50, + duration = 1000, + playback_delay = 100, + playback_time = 500, + repeat_count = lvgl.ANIM_REPEAT_INFINITE, + path = "ease_in_out", +} + +animPara.exec_cb = function(obj, value) + obj:set { size = value } +end + +obj:Anim(animPara) + +animPara.end_value = 240 +animPara.exec_cb = function(obj, value) + obj:set { x = value } +end + +obj:Anim(animPara) |
