Add HTTP server
This commit is contained in:
parent
6b2d89340a
commit
8bd9a9b1d0
7 changed files with 206 additions and 8 deletions
|
|
@ -13,12 +13,43 @@ print(
|
|||
'height: ' .. height
|
||||
)
|
||||
|
||||
for i = 1, 50 do
|
||||
x = math.random() * width
|
||||
y = math.random() * height
|
||||
r = 24 + math.ceil(math.random() * 12)
|
||||
-- easing functions taken from https://easings.net/
|
||||
|
||||
paper.fill_circle(x, y, r, math.floor(math.random() * 0xFF))
|
||||
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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue