|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | + <head> |
| 4 | + <title>Tween.js / easing with a power of number</title> |
| 5 | + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 6 | + <style> |
| 7 | + body { |
| 8 | + margin: 0px; |
| 9 | + } |
| 10 | + |
| 11 | + #target { |
| 12 | + font-size: 13px; |
| 13 | + padding: 0px 32px; |
| 14 | + } |
| 15 | + </style> |
| 16 | + <link href="css/style.css" media="screen" rel="stylesheet" type="text/css" /> |
| 17 | + </head> |
| 18 | + <body> |
| 19 | + <div id="info" style="position: relative;"> |
| 20 | + <h1><a href="http://github.com/tweenjs/tween.js">tween.js</a></h1> |
| 21 | + <h2>17 _ Easing with Pow</h2> |
| 22 | + <p>TWEEN.Easing.generatePow() provides easing with a power of number.</p> |
| 23 | + </div> |
| 24 | + |
| 25 | + <div id="target"></div> |
| 26 | + |
| 27 | + <script src="../dist/tween.umd.js"></script> |
| 28 | + <script src="js/RequestAnimationFrame.js"></script> |
| 29 | + <script src="js/createGraph.js"></script> |
| 30 | + <script> |
| 31 | + window.addEventListener('load', function () { |
| 32 | + init() |
| 33 | + animate() |
| 34 | + }) |
| 35 | + |
| 36 | + function init() { |
| 37 | + var target = document.getElementById('target') |
| 38 | + |
| 39 | + const addGraph = pow => { |
| 40 | + target.appendChild(createGraph(`Power"${pow}".In`, TWEEN.Easing.generatePow(pow).In)) |
| 41 | + target.appendChild(createGraph(`Power"${pow}".Out`, TWEEN.Easing.generatePow(pow).Out)) |
| 42 | + target.appendChild(createGraph(`Power"${pow}".InOut`, TWEEN.Easing.generatePow(pow).InOut)) |
| 43 | + } |
| 44 | + target.appendChild(createGraph('Power1', TWEEN.Easing.generatePow(1).In)) |
| 45 | + |
| 46 | + target.appendChild(document.createElement('br')) |
| 47 | + |
| 48 | + addGraph(2) |
| 49 | + addGraph(3) |
| 50 | + |
| 51 | + target.appendChild(document.createElement('br')) |
| 52 | + |
| 53 | + addGraph(4) |
| 54 | + addGraph(5) |
| 55 | + |
| 56 | + target.appendChild(document.createElement('br')) |
| 57 | + |
| 58 | + addGraph(5.8) |
| 59 | + target.appendChild(createGraph(`Exponential.In`, TWEEN.Easing.Exponential.In)) |
| 60 | + target.appendChild(createGraph(`Exponential.Out`, TWEEN.Easing.Exponential.Out)) |
| 61 | + target.appendChild(createGraph(`Exponential.InOut`, TWEEN.Easing.Exponential.InOut)) |
| 62 | + } |
| 63 | + |
| 64 | + function animate(time) { |
| 65 | + requestAnimationFrame(animate) |
| 66 | + |
| 67 | + TWEEN.update(time) |
| 68 | + } |
| 69 | + </script> |
| 70 | + </body> |
| 71 | +</html> |
0 commit comments