#!/usr/bin/env lua5.1
require[[fp]]
require[[fptheme]]
require[[fpeffects]]
bg=fp.image{style = "background"}
images = {}
filenames = {"icon_AlarmClock.png", "icon_Browser.png",
"icon_Camera.png","icon_Email.png",
"icon_Gallery.png", "icon_Music.png",
"icon_Settings.png"}
--define the movement curve
local pad = 30--pad between first icon and the top
local xoffset = 200 --the offset of x
local slope = 80 --the slope
local tall = 100 --the length of curve
function cal(m)
if not m then return false end
return tall*( (math.exp((m-xoffset)/slope) -
math.exp((-m+xoffset)/slope)) /
(math.exp((m-xoffset)/slope) +
math.exp((-m+xoffset)/slope)) +1) + pad
end
--place the icons
local N = #filenames -- icon number
local gap = 50--starting point of the first icon and the gap
local t = 20 --size getting bigger
local fade = 80 --transparency
local geometry={}
for i = 1,N do
local f ="data/icon/"..filenames[i]
images[i] =fp.create{type="image", file=f}
if i<=(#filenames+1)/2 then
geometry[i]={x=i*gap-i*t/2, y = cal(i*gap)-i*t/2,
w=i*t, h=i*t}
images[i]:transform(geometry[i])
images[i]:alpha_set(i*fade)
else geometry[i] = {x=i*gap-t*(N-i+1)/2,
y = cal(i*gap)-t*(N-i+1)/2,
w=t*(N-i+1), h=t*(N-i+1)}
images[i]:transform(geometry[i])
images[i]:alpha_set((N-i+1)*fade)
end
end
--set the timer for the movement
local k=1
t = fp.timer(0.5, function()
for i = 1,N do
images[i]:transform(geometry[(i+k-1)%N+1])
end
k = k+1
return true
end )
text = fp.text{text="Icons moving automatically", x=100,y=250}
fp.begin()