Guest User

tornado

a guest
May 14th, 2015
509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. --[[ ******************************************************************
  2. Tornado by KOP
  3.  
  4. ******************************************************************* ]]
  5.  
  6. return function(pg, of, sw, sh)
  7.  
  8. pg:translate(of,0,0)
  9.  
  10. local pc, cx, cy = math.abs(of/pg.width), pg.width/2, pg.height/2
  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 = math.abs(cx-icx), math.abs(cy-icy)
  26. -- get angle of icon position
  27. local ang = math.atan(oy/ox)
  28. -- get hypotenuse
  29. local h = math.sqrt( ox^2+oy^2)
  30. local iconX = ic.x+ic.width/2
  31. local fall = (1-pc)*h
  32. local iconY = ic.y+ic.height/2
  33. -- get hypotenuse extension
  34. local oh = fx*h+fx*tg
  35. -- directions
  36. local dx, dy = 1,1
  37. if icx<cx then dx=-dx end
  38. if icy<cy then dy=-dy end
  39. if icy==cy then dy=0 end
  40. local nx = 0
  41. local ny = 0
  42. -- calc new x & y
  43. -- local nx = math.sqrt(h^2-oy^2)
  44. -- local ny = math.sqrt(h^2-ox^2)
  45. nx =midx+dx*fall*math.cos(pc*6*math.pi*ang)
  46. ny =2*midy-3*fall+math.sin(pc*4*math.pi*ang)
  47. local size=(3-fx)*(fall/h)
  48. if size>1 then size=1 end
  49. -- move!!
  50. ic:translate(fx*(nx-iconX),fx*(ny-iconY),0)
  51. -- ic:scale(size*size)
  52. -- ic:translate(-0.5*nx,-0.5*ny,0)
  53.  
  54. -- if pc>0.6 then
  55. ic.alpha = 1-pc
  56. -- end
  57.  
  58. end
  59. end
Advertisement
Add Comment
Please, Sign In to add comment