1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
|
module class << self def pow(val, times) return val ** times end end end module Ease class << self def linear(t, b, c, d) return c * t / d + b end
def inQuad(t, b, c, d) t = t / d p Math.pow(t, 2) return c * Math.pow(t, 2) + b end
def outQuad(t, b, c, d) t = t / d return -c * t * (t - 2) + b end
def inOutQuad(t, b, c, d) t = t / d * 2 if t < 1 return c / 2 * Math.pow(t, 2) + b else return -c / 2 * ((t - 1) * (t - 3) - 1) + b end end
def outInQuad(t, b, c, d) if t < d / 2 return outQuad(t * 2, b, c / 2, d) else return inQuad((t * 2) - d, b + c / 2, c / 2, d) end end
def inCubic (t, b, c, d) t = t / d return c * Math.pow(t, 3) + b end
def outCubic(t, b, c, d) t = t / d - 1 return c * (Math.pow(t, 3) + 1) + b end
def inOutCubic(t, b, c, d) t = t / d * 2 if t < 1 return c / 2 * t * t * t + b else t = t - 2 return c / 2 * (t * t * t + 2) + b end end
def outInCubic(t, b, c, d) if t < d / 2 return outCubic(t * 2, b, c / 2, d) else return inCubic((t * 2) - d, b + c / 2, c / 2, d) end end
def inQuart(t, b, c, d) t = t / d return c * Math.pow(t, 4) + b end
def outQuart(t, b, c, d) t = t / d - 1 return -c * (Math.pow(t, 4) - 1) + b end
def inOutQuart(t, b, c, d) t = t / d * 2 if t < 1 return c / 2 * Math.pow(t, 4) + b else t = t - 2 return -c / 2 * (Math.pow(t, 4) - 2) + b end end
def outInQuart(t, b, c, d) if t < d / 2 return outQuart(t * 2, b, c / 2, d) else return inQuart((t * 2) - d, b + c / 2, c / 2, d) end end
def inQuint(t, b, c, d) t = t / d return c * Math.pow(t, 5) + b end
def outQuint(t, b, c, d) t = t / d - 1 return c * (Math.pow(t, 5) + 1) + b end
def inOutQuint(t, b, c, d) t = t / d * 2 if t < 1 return c / 2 * Math.pow(t, 5) + b else t = t - 2 return c / 2 * (Math.pow(t, 5) + 2) + b end end
def outInQuint(t, b, c, d) if t < d / 2 return outQuint(t * 2, b, c / 2, d) else return inQuint((t * 2) - d, b + c / 2, c / 2, d) end end
def inSine(t, b, c, d) return -c * Math.cos(t / d * (Math::PI / 2)) + c + b end
def outSine(t, b, c, d) return c * Math.sin(t / d * (Math::PI / 2)) + b end
def inOutSine(t, b, c, d) return -c / 2 * (Math.cos(Math::PI * t / d) - 1) + b end
def outInSine(t, b, c, d) if t < d / 2 return outSine(t * 2, b, c / 2, d) else return inSine((t * 2) -d, b + c / 2, c / 2, d) end end
def inExpo(t, b, c, d) if t == 0 return b else return c * Math.pow(2, 10 * (t / d - 1)) + b - c * 0.001 end end
def outExpo(t, b, c, d) if t == d return b + c else return c * 1.001 * (-Math.pow(2, -10 * t / d) + 1) + b end end
def inOutExpo(t, b, c, d) return b if t == 0 return b + c if t == d t = t / d * 2 if t < 1 return c / 2 * Math.pow(2, 10 * (t - 1)) + b - c * 0.0005 else t = t - 1 return c / 2 * 1.0005 * (-Math.pow(2, -10 * t) + 2) + b end end
def outInExpo(t, b, c, d) if t < d / 2 return outExpo(t * 2, b, c / 2, d) else return inExpo((t * 2) - d, b + c / 2, c / 2, d) end end
def inCirc(t, b, c, d) t = t / d return(-c * (Math.sqrt(1 - Math.pow(t, 2)) - 1) + b) end
def outCirc(t, b, c, d) t = t / d - 1 return(c * Math.sqrt(1 - Math.pow(t, 2)) + b) end
def inOutCirc(t, b, c, d) t = t / d * 2 if t < 1 return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b else t = t - 2 return c / 2 * (Math.sqrt(1 - t * t) + 1) + b end end
def outInCirc(t, b, c, d) if t < d / 2 return outCirc(t * 2, b, c / 2, d) else return inCirc((t * 2) - d, b + c / 2, c / 2, d) end end
def inElastic(t, b, c, d, a, p=nil) return if t == 0
t = t / d
return b + c if t == 1
p = d * 0.3 if not p
s = 0
if not a or a < (c).abs a = c s = p / 4 else s = p / (2 * Math::PI) * Math.asin(c/a) end
t = t - 1
return -(a * Math.pow(2, 10 * t) * Math.sin((t * d - s) * (2 * Math::PI) / p)) + b end
def outElastic(t, b, c, d, a, p=nil) return b if t == 0
t = t / d
return b + c if t == 1
p = d * 0.3 if not p
s = 0
if not a or a < (c).abs a = c s = p / 4 else s = p / (2 * Math::PI) * Math.asin(c/a) end
return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math::PI) / p) + c + b end
def inOutElastic(t, b, c, d, a=nil, p=nil) return b if t == 0
t = t / d * 2
return b + c if t == 2
p = d * (0.3 * 1.5) if not p a = 0 if not a
s = 0
if not a or a < (c).abs a = c s = p / 4 else s = p / (2 * Math::PI) * Math.asin(c / a) end
if t < 1 t = t - 1 return -0.5 * (a * Math.pow(2, 10 * t) * Math.sin((t * d - s) * (2 * Math::PI) / p)) + b else t = t - 1 return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math::PI) / p ) * 0.5 + c + b end end
def outInElastic(t, b, c, d, a, p=nil) if t < d / 2 return outElastic(t * 2, b, c / 2, d, a, p) else return inElastic((t * 2) - d, b + c / 2, c / 2, d, a, p) end end
def inBack(t, b, c, d, s=nil) s = 1.70158 if not s t = t / d return c * t * t * ((s + 1) * t - s) + b end
def outBack(t, b, c, d, s=nil) s = 1.70158 if not s t = t / d - 1 return c * (t * t * ((s + 1) * t + s) + 1) + b end
def inOutBack(t, b, c, d, s=nil) s = 1.70158 if not s s = s * 1.525 t = t / d * 2 if t < 1 return c / 2 * (t * t * ((s + 1) * t - s)) + b else t = t - 2 return c / 2 * (t * t * ((s + 1) * t + s) + 2) + b end end
def outInBack(t, b, c, d, s) if t < d / 2 return outBack(t * 2, b, c / 2, d, s) else return inBack((t * 2) - d, b + c / 2, c / 2, d, s) end end
def outBounce(t, b, c, d) t = t / d if t < 1 / 2.75 return c * (7.5625 * t * t) + b elseif t < 2 / 2.75 t = t - (1.5 / 2.75) return c * (7.5625 * t * t + 0.75) + b elseif t < 2.5 / 2.75 t = t - (2.25 / 2.75) return c * (7.5625 * t * t + 0.9375) + b else t = t - (2.625 / 2.75) return c * (7.5625 * t * t + 0.984375) + b end end
def inBounce(t, b, c, d) return c - outBounce(d - t, 0, c, d) + b end
def inOutBounce(t, b, c, d) if t < d / 2 return inBounce(t * 2, 0, c, d) * 0.5 + b else return outBounce(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b end end
def outInBounce(t, b, c, d) if t < d / 2 return outBounce(t * 2, b, c / 2, d) else return inBounce((t * 2) - d, b + c / 2, c / 2, d) end end end end
|
近期评论