esp32-lilygo-t5/assets/boot.lua

55 lines
1.1 KiB
Lua

local math = require('math')
local paper = require('paper')
paper.init()
paper.set_rotation("portrait")
paper.clear()
local width = paper.get_width()
local height = paper.get_height()
print(
'width: ' .. width,
'height: ' .. height
)
-- easing functions taken from https://easings.net/
function ease_in_sine(x)
return 1 - math.cos(x * math.pi / 2)
end
function ease_in_out_sine(x)
return -(math.cos(math.pi * x) - 1) / 2
end
--
-- actual sketch follows below
--
local x = width / 2
local max_radius = 128
local min_radius = max_radius / 6
local padding = max_radius
local max_color = 0xDD
local min_color = 0x33
local steps = 72
-- background
paper.fill_rect(0, 0, width, height, 0x22)
-- sketch
for i = 1, steps do
local n = i / steps
local e1 = ease_in_sine(n)
local e2 = 1 - ease_in_out_sine(ease_in_sine(n))
local color = math.floor(max_color - (max_color - min_color) * e2)
paper.fill_circle(
x + math.sin((math.pi * 2) / n) * 32 * e1,
padding + (height - max_radius - padding * 2) * e1,
min_radius + (max_radius - min_radius) * e1,
color
)
end
paper.update()