源战役客户端
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

157 líneas
5.7 KiB

hace 4 semanas
  1. TweenFunc = TweenFunc or {}
  2. local TweenFunc = TweenFunc
  3. TweenFunc.LINEAR = "linear" --线性
  4. TweenFunc.EASE_IN = "easeIn"
  5. TweenFunc.EASE_OUT = "easeOut"
  6. TweenFunc.EASE_IN_OUT = "easeInOut"
  7. TweenFunc.EASE_OUT_IN = "easeOutIn"
  8. TweenFunc.EASE_IN_BACK = "easeInBack"
  9. TweenFunc.EASE_OUT_BACK = "easeOutBack"
  10. TweenFunc.EASE_IN_OUT_BACK = "easeInOutBack"
  11. TweenFunc.EASE_OUT_IN_BACK = "easeOutInBack"
  12. TweenFunc.EASE_IN_ELASTIC = "easeInElastic"
  13. TweenFunc.EASE_OUT_ELASTIC = "easeOutElastic"
  14. TweenFunc.EASE_IN_OUT_ELASTIC = "easeInOutElastic"
  15. TweenFunc.EASE_OUT_IN_ELASTIC = "easeOutInElastic"
  16. TweenFunc.EASE_IN_BOUNCE = "easeInBounce"
  17. TweenFunc.EASE_OUT_BOUNCE = "easeOutBounce"
  18. TweenFunc.EASE_IN_OUT_BOUNCE = "easeInOutBounce"
  19. TweenFunc.EASE_OUT_IN_BOUNCE = "easeOutInBounce"
  20. TweenFunc.EASE_IN_TO_OUT_BACK = "easeInToOutBack"
  21. TweenFunc.PINGPONG = "pingPong"
  22. TweenFunc.EASE_OUT_QUINT = "easeOutQuint"
  23. TweenFunc.EASE_IN_QUINT = "easeInQuint"
  24. function TweenFunc.linear(ratio)
  25. return ratio
  26. end
  27. function TweenFunc.easeIn(ratio)
  28. return ratio * ratio * ratio
  29. end
  30. function TweenFunc.easeOut(ratio)
  31. local invRatio = ratio - 1.0
  32. return invRatio * invRatio * invRatio + 1
  33. end
  34. function TweenFunc.easeInOut(ratio)
  35. return TweenFunc.easeCombined(TweenFunc.easeIn, TweenFunc.easeOut, ratio)
  36. end
  37. function TweenFunc.easeOutIn(ratio)
  38. return TweenFunc.easeCombined(TweenFunc.easeOut, TweenFunc.easeIn, ratio)
  39. end
  40. function TweenFunc.easeInBack(ratio)
  41. local s = 1.70158
  42. return ratio * ratio * ((s + 1.0)*ratio - s)
  43. end
  44. function TweenFunc.easeOutBack(ratio)
  45. local invRatio = ratio - 1.0
  46. local s = 1.70158
  47. return invRatio * invRatio * ((s + 1.0)*invRatio + s) + 1.0
  48. end
  49. function TweenFunc.easeInOutBack(ratio)
  50. return TweenFunc.easeCombined(TweenFunc.easeInBack, TweenFunc.easeOutBack, ratio)
  51. end
  52. function TweenFunc.easeOutInBack(ratio)
  53. return TweenFunc.easeCombined(TweenFunc.easeOutBack, TweenFunc.easeInBack, ratio)
  54. end
  55. function TweenFunc.easeInElastic(ratio)
  56. if ratio == 0 or ratio == 1 then
  57. return ratio
  58. else
  59. local p = 0.3
  60. local s = p/4.0
  61. local invRatio = ratio - 1
  62. return -1.0 * math.pow(2.0, 10.0*invRatio) * math.sin((invRatio-s)*(2.0*math.pi)/p)
  63. end
  64. end
  65. function TweenFunc.easeOutElastic(ratio)
  66. if ratio == 0 or ratio == 1 then
  67. return ratio
  68. else
  69. local p = 0.3
  70. local s = p/4.0
  71. return math.pow(2.0, -10.0*ratio) * math.sin((ratio-s)*(2.0*math.pi)/p) + 1
  72. end
  73. end
  74. function TweenFunc.easeInOutElastic(ratio)
  75. return TweenFunc.easeCombined(TweenFunc.easeInElastic, TweenFunc.easeOutElastic, ratio)
  76. end
  77. function TweenFunc.easeOutInElastic(ratio)
  78. return TweenFunc.easeCombined(TweenFunc.easeOutElastic, TweenFunc.easeInElastic, ratio)
  79. end
  80. function TweenFunc.easeInBounce(ratio)
  81. return 1.0 - TweenFunc.easeOutBounce(1.0 - ratio)
  82. end
  83. function TweenFunc.easeOutBounce(ratio)
  84. local s = 7.5625
  85. local p = 2.75
  86. local l = nil
  87. if ratio < (1.0/p) then
  88. l = s * math.pow(ratio, 2)
  89. else
  90. if ratio < (2.0/p) then
  91. ratio = ratio - 1.5/p
  92. l = s * math.pow(ratio, 2) + 0.75
  93. else
  94. if ratio < 2.5/p then
  95. ratio = ratio - 2.25/p
  96. l = s * math.pow(ratio, 2) + 0.9375
  97. else
  98. ratio = ratio - 2.625/p
  99. l = s * math.pow(ratio, 2) + 0.984375
  100. end
  101. end
  102. end
  103. return l
  104. end
  105. function TweenFunc.easeInOutBounce(ratio)
  106. return TweenFunc.easeCombined(TweenFunc.easeInBounce, TweenFunc.easeOutBounce, ratio)
  107. end
  108. function TweenFunc.easeOutInBounce(ratio)
  109. return TweenFunc.easeCombined(TweenFunc.easeOutBounce, TweenFunc.easeInBounce, ratio)
  110. end
  111. function TweenFunc.easeInToOutBack(ratio)
  112. return TweenFunc.easeCombined(TweenFunc.easeIn, TweenFunc.easeOutBack, ratio)
  113. end
  114. function TweenFunc.easeCombined(startFunc, endFunc, ratio)
  115. if ratio < 0.5 then
  116. return 0.5 * startFunc(ratio*2.0)
  117. else
  118. return 0.5 * endFunc((ratio-0.5)*2.0) + 0.5
  119. end
  120. end
  121. function TweenFunc.pingPong(ratio)
  122. if ratio < 0.5 then
  123. return TweenFunc.linear(ratio * 2)
  124. else
  125. return TweenFunc.linear( 2 - ratio * 2 )
  126. end
  127. end
  128. function TweenFunc.easeOutQuint(ratio)
  129. local invRatio = ratio - 1.0
  130. return invRatio * invRatio * invRatio * invRatio * invRatio + 1
  131. end
  132. function TweenFunc.easeInQuint(ratio)
  133. return ratio * ratio * ratio * ratio
  134. end
  135. TweenFunc[TweenFunc.LINEAR] = TweenFunc.linear
  136. TweenFunc[TweenFunc.EASE_IN] = TweenFunc.easeIn
  137. TweenFunc[TweenFunc.EASE_OUT] = TweenFunc.easeOut
  138. TweenFunc[TweenFunc.EASE_IN_OUT] = TweenFunc.easeInOut
  139. TweenFunc[TweenFunc.EASE_OUT_IN] = TweenFunc.easeOutIn
  140. TweenFunc[TweenFunc.EASE_IN_BACK] = TweenFunc.easeInBack
  141. TweenFunc[TweenFunc.EASE_OUT_BACK] = TweenFunc.easeOutBack
  142. TweenFunc[TweenFunc.EASE_IN_OUT_BACK] = TweenFunc.easeInOutBack
  143. TweenFunc[TweenFunc.EASE_OUT_IN_BACK] = TweenFunc.easeOutInBack
  144. TweenFunc[TweenFunc.EASE_IN_ELASTIC] = TweenFunc.easeInElastic
  145. TweenFunc[TweenFunc.EASE_OUT_ELASTIC] = TweenFunc.easeOutElastic
  146. TweenFunc[TweenFunc.EASE_IN_OUT_ELASTIC] = TweenFunc.easeInOutElastic
  147. TweenFunc[TweenFunc.EASE_OUT_IN_ELASTIC] = TweenFunc.easeOutInElastic
  148. TweenFunc[TweenFunc.EASE_IN_BOUNCE] = TweenFunc.easeInBounce
  149. TweenFunc[TweenFunc.EASE_OUT_BOUNCE] = TweenFunc.easeOutBounce
  150. TweenFunc[TweenFunc.EASE_IN_OUT_BOUNCE] = TweenFunc.easeInOutBounce
  151. TweenFunc[TweenFunc.EASE_OUT_IN_BOUNCE] = TweenFunc.easeOutInBounce
  152. TweenFunc[TweenFunc.EASE_IN_TO_OUT_BACK] = TweenFunc.easeInToOutBack
  153. TweenFunc[TweenFunc.PINGPONG] = TweenFunc.pingPong
  154. TweenFunc[TweenFunc.EASE_OUT_QUINT] = TweenFunc.easeOutQuint
  155. TweenFunc[TweenFunc.EASE_IN_QUINT] = TweenFunc.easeInQuint