Guest User

Untitled

a guest
Sep 8th, 2015
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. return function(page, offset, is_inside, d)
  2.  
  3. local percent = offset/page.width
  4. page.layer.x = page.layer.x + offset
  5. local ad = percent*page.height
  6. local angle = -percent*math.pi/2
  7.  
  8. local h = page.width/2
  9. local x=0
  10. local z=0
  11.  
  12. if d==1 then
  13. x = h*math.cos(math.abs(angle)) - page.width/2
  14. z = -h*math.sin(math.abs(angle))
  15.  
  16. if percent > 0 then
  17. x = -x
  18. end
  19.  
  20. x = x - offset
  21.  
  22. if is_inside then
  23. z = -z
  24. angle = -angle
  25. end
  26. page:translate(x, 0, z)
  27. page:rotate(angle, 0, 1, 0)
  28.  
  29. end
  30. if d==2 then
  31. x = h*math.cos(math.abs(angle)) - page.width/2
  32. z = -h*math.sin(math.abs(angle))
  33. x = -x
  34. if percent<0 then
  35. x = -x
  36. end
  37.  
  38.  
  39. x = x - offset
  40.  
  41. if is_inside then
  42. z = -z
  43. angle = -angle
  44. end
  45.  
  46. page:translate(-x, 0, z)
  47. page:rotate(-angle, 0, 1, 0)
  48. end
  49. if d==3 then
  50. x = (page.height/2)*math.cos(math.abs(angle)) - page.height/2
  51. z = -(page.height/2)*math.sin(math.abs(angle))
  52. x = -x
  53. if percent<0 then
  54. x = -x
  55. end
  56.  
  57.  
  58. x = x - ad
  59.  
  60. if is_inside then
  61. z = -z
  62. angle = -angle
  63. end
  64.  
  65. page:translate(0, x, z)
  66. page:rotate(-angle, 1, 0, 0)
  67. end
  68. if d==4 then
  69. x = (page.height/2)*math.cos(math.abs(angle)) - page.height/2
  70. z = -(page.height/2)*math.sin(math.abs(angle))
  71. x = -x
  72. if percent<0 then
  73. x = -x
  74. end
  75.  
  76.  
  77. x = x - ad
  78.  
  79. if is_inside then
  80. z = -z
  81. angle = -angle
  82. end
  83.  
  84. page:translate(0, -x, z)
  85. page:rotate(angle, 1, 0, 0)
  86. end
  87. return x, z, angle
  88. end
Advertisement
Add Comment
Please, Sign In to add comment