Guest User

Untitled

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