Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
69 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
<style> | ||
canvas { | ||
border: 1px solid #eee; | ||
} | ||
</style> | ||
|
||
<script src="../build/build.js"></script> | ||
|
||
<canvas width=1000 height=500></canvas> | ||
|
||
<script> | ||
var Tween = require('tween'); | ||
var raf = require('component-raf'); | ||
var canvas = document.querySelector('canvas'); | ||
var ctx = canvas.getContext('2d'); | ||
var h = 500; | ||
|
||
function random(n, f) { | ||
var arr = []; | ||
while (n--) arr.push(Math.random() * f); | ||
return arr; | ||
} | ||
|
||
var tween = Tween(random(1000, 50)) | ||
.ease('out-bounce') | ||
.to(random(1000, 400)) | ||
.duration(800); | ||
|
||
tween.update(function(a){ | ||
canvas.width = canvas.width; | ||
ctx.fillStyle = '#0070ff'; | ||
for (var i = 0; i < a.length; i++) { | ||
ctx.fillRect(i, h - a[i], 1, a[i]); | ||
} | ||
}); | ||
|
||
tween.on('end', function(){ | ||
animate = function(){}; | ||
}); | ||
|
||
function animate() { | ||
raf(animate); | ||
tween.update(); | ||
} | ||
|
||
animate(); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters