flutter/examples/spinning-square.sky
Adam Barth f3d9715455 Add a fps-counter widget to some Sky demos
This CL makes some Sky demos more interesting and adds an fps-widget to see how
fast they run.

R=esprehn@chromium.org

Review URL: https://codereview.chromium.org/803283006
2015-01-14 15:50:59 -08:00

30 lines
566 B
Plaintext

#!mojo mojo:sky_viewer
<sky>
<import src="fps-counter.sky" />
<style>
square {
margin: 50px;
height: 100px;
width: 100px;
background-color: green;
}
</style>
<square />
<fps-counter showHistory="true" />
<script>
var square = document.querySelector('square');
var timeBase = 0;
function animate(time) {
if (!timeBase)
timeBase = time;
var delta = time - timeBase;
var rotation = Math.floor(delta / 10);
square.style.transform = 'rotate(' + rotation + 'deg)';
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
</script>
</sky>