mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Update Raster example to use onFrame.
This commit is contained in:
parent
ba0c6dafea
commit
520e540da7
1 changed files with 7 additions and 5 deletions
|
@ -7,14 +7,16 @@
|
||||||
<script type="text/javascript" src="../../src/load.js"></script>
|
<script type="text/javascript" src="../../src/load.js"></script>
|
||||||
<script type="text/paperscript" canvas="canvas">
|
<script type="text/paperscript" canvas="canvas">
|
||||||
// http://en.wikipedia.org/wiki/Lenna
|
// http://en.wikipedia.org/wiki/Lenna
|
||||||
var raster = new Raster('lenna');
|
var raster = new Raster('lenna'),
|
||||||
var count = 0, lastScale = 1;
|
count = 0,
|
||||||
setInterval(draw, 30);
|
lastScale = 1,
|
||||||
function draw() {
|
center = document.bounds.center;
|
||||||
|
|
||||||
|
function onFrame() {
|
||||||
count++;
|
count++;
|
||||||
var scale = Math.sin(count / 15) + 1;
|
var scale = Math.sin(count / 15) + 1;
|
||||||
raster.scale(scale / lastScale);
|
raster.scale(scale / lastScale);
|
||||||
raster.position = [Math.sin(count / 20) * 256 + 512, 384];
|
raster.position = center + [Math.sin(count / 20) * 256, 0];
|
||||||
raster.rotate(5);
|
raster.rotate(5);
|
||||||
document.redraw();
|
document.redraw();
|
||||||
lastScale = scale;
|
lastScale = scale;
|
||||||
|
|
Loading…
Reference in a new issue