Guest User

Untitled

a guest
May 15th, 2015
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. --[[ ******************************************************************
  2. Focus - modified Explosion by KnifeOfPi
  3. ******************************************************************* ]]
  4.  
  5. return function(pg, of, sw, sh)
  6.  
  7. pg:translate(of,0,0)
  8.  
  9. local pc, cx, cy = math.abs(of/pg.width), pg.width/2, pg.height/2
  10. -- target distance
  11. local tg = pg.width
  12. local fnum=1;
  13. for i, ic in subviews(pg) do
  14. -- get icon center
  15. local icx, icy = (ic.x+ic.width/2), (ic.y+ic.height/2)
  16. -- get icon offset from page center
  17. local ox, oy = cx-icx, cy-icy
  18. -- get angle of icon position
  19. local ang = math.atan(oy/ox)
  20. -- get hypotenuse
  21. local h = math.sqrt( ox^2+oy^2)
  22. -- get hypotenuse extension
  23. local oh = pc*tg+pc*h
  24. -- directions
  25. local dx, dy = 1,1
  26. if icx<cx then dx=-dx end
  27. if icy<cy then dy=-dy end
  28. if icy==cy then dy=0 end
  29. if ang>=math.pi then fnum=-1 end
  30. if ang<math.pi then fnum=1 end
  31. -- calc new x & y
  32. local nx = oh * math.cos(ang) * dx
  33. local ny = oh * math.sin(ang) * dy
  34.  
  35. -- move!
  36.  
  37. ic:rotate(pc*math.pi/(0.0008*(h+200)), 0-ox, 0-oy, 0)
  38.  
  39. -- if pc>0.6 then
  40. ic.alpha = 1-pc
  41. -- end
  42.  
  43. end
  44. end
Advertisement
Add Comment
Please, Sign In to add comment