Guest User

Untitled

a guest
May 17th, 2015
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.27 KB | None | 0 0
  1. --[[ ******************************************************************
  2. Whirlpool by KnifeOfPi
  3.                
  4. ******************************************************************* ]]
  5.  
  6. return function(pg, of, sw, sh)
  7.  
  8.         pg:translate(of,0,0)
  9.  
  10.     local pc, cx, cy, ops = math.abs(of/pg.width), pg.width/2, pg.height/2, of/pg.width
  11.         -- target distance
  12. local midx =pg.width/2
  13.  
  14.         local midy =pg.height/2+7
  15.         local tg = pg.width
  16.         local fx = pc*5
  17.         if fx>1 then fx=1 end
  18. local side = -1
  19.  
  20.         -- if(of>0) then side=1 end
  21.     for i, ic in subviews(pg) do
  22.                 -- get icon center
  23.                 local icx, icy = (ic.x+ic.width/2), (ic.y+ic.height/2)
  24.                 -- get icon offset from page center
  25.                 local ox, oy = cx-icx, cy-icy
  26.                 -- get angle of icon position
  27.                 local ang = math.atan2(oy,ox)
  28.                 -- get hypotenuse
  29.                 local h = math.sqrt( ox^2+oy^2)
  30.                
  31. local iconX = ic.x+ic.width/2
  32.                 local fall = (1-pc)*h
  33.           local iconY = ic.y+ic.height/2
  34.                 -- get hypotenuse extension
  35.                 local nh = math.sqrt((iconX-midx)^2+(iconY-midy)^2)
  36.                 local oh = fx*h+fx*tg
  37.                 -- directions
  38.                 local dx, dy, dxz, dyz = 1,1,1,1
  39.                 if icx<cx then dx=0 dxz=1 end
  40.                 if icx>cx then dx=-1 dxz=-1 end
  41.                 if icy<cy then dy=0 dyz=1 end
  42.                 if icy>cy then dy=-1 dyz=-1 end
  43.                 if icy==cy then dy=1 end
  44.                 local nx = 0
  45. local ny = 0
  46.                 -- calc new x & y
  47.                 -- local nx = math.sqrt(h^2-oy^2)
  48.                 -- local ny = math.sqrt(h^2-ox^2)
  49.                 nx =0-fall*math.cos(150/(fall+35)*ops*3*math.pi+ang)
  50.                 ny =0-fall*math.sin(150/(fall+35)*ops*3*math.pi+ang)
  51.                 local size=(3-fx)*(fall/h)
  52.                 if size>1 then size=1 end
  53.                 -- move!
  54.                 -- print(ox)
  55.                 ic:translate(fx*(nx-iconX+midx),fx*(ny-iconY+midy),0)
  56. -- ic:scale(size*size)
  57. -- ic:translate(-0.5*nx,-0.5*ny,0)
  58.                
  59.                 -- if pc>0.6 then
  60.                         ic.alpha = 1-pc
  61.                 -- end
  62.  
  63.     end
  64. end
Advertisement
Add Comment
Please, Sign In to add comment