Guest User

Helix effect for Cylinder

a guest
Apr 25th, 2015
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. -- Psychospiral animation by Cylgom; modified to Helix by KnifeOfPi
  2.  
  3. return function(page, offset, screen_width, screen_height)
  4.  
  5. local percent = math.abs(offset/page.width)
  6.  
  7. side = -1
  8.  
  9. if(offset>0) then side=1 end
  10.  
  11.  
  12.  
  13. local rollup = percent*5
  14.  
  15. if(rollup>1) then rollup=1 end
  16.  
  17. local runaway = (percent-0.20)/0.6
  18.  
  19. if(runaway<0) then runaway=0 end
  20.  
  21. if(runaway>1) then runaway=1 end
  22.  
  23.  
  24.  
  25. local middleX =page.width/2
  26.  
  27. local middleY =page.height/2+7
  28.  
  29. local radiusparts = (middleY)/#page.subviews
  30.  
  31. local theta = (3.5*math.pi)/#page.subviews
  32.  
  33. local size = 1
  34.  
  35. for i, icon in subviews(page) do
  36.  
  37. local initangle =(i-1)*theta
  38.  
  39. local initradius =(i-1)*radiusparts
  40.  
  41. local angle = initangle+runaway*(3.5*math.pi-initangle)
  42.  
  43. local radius = initradius+runaway*(middleY-initradius)+45
  44.  
  45. local iconX = icon.x+icon.width/2
  46.  
  47. local iconY = icon.y+icon.height/2
  48.  
  49. local pathX = (middleX+(radius*math.sin(angle))*side)
  50.  
  51. local pathY = (middleY+(radius*math.tan(angle))*side)
  52.  
  53. local iconAngle = angle
  54.  
  55. icon:translate(rollup*(pathX-iconX), rollup*(pathY-iconY), 0)
  56.  
  57. icon:rotate(rollup*iconAngle)
  58.  
  59.  
  60.  
  61. icon:scale(size*size)
  62.  
  63. end
  64.  
  65. page:translate(offset,0,0)
  66.  
  67. end
Advertisement
Add Comment
Please, Sign In to add comment