import 'dart:html' as html;
import 'dart:math' as math;
import 'package:stagexl/stagexl.dart';
ResourceManager resourceManager;
RenderLoop renderLoop;
Juggler juggler;
var canvas;
Stage stage;
Bitmap logo;
void main() {
canvas = html.querySelector('#stage');
stage = new Stage(canvas);
renderLoop = new RenderLoop();
juggler = renderLoop.juggler;
renderLoop.addStage(stage);
resourceManager = new ResourceManager()
..addBitmapData('logo', 'img/orig.png');
resourceManager.load().then(onAssetsLoaded);
}
void onAssetsLoaded(var result) {
logo = new Bitmap(resourceManager.getBitmapData('logo'));
logo.pivotX = logo.width/2;
logo.pivotY = logo.width/2;
stage.addChild(logo);
playAnimation();
}
void playAnimation() {
logo
..x=0
..y=100
..scaleX=0.1
..scaleY=0.1
..alpha=0.1
..rotation=0;
juggler.tween(logo, 6, TransitionFunction.easeOutBounce)
..animate.x.to(750)
..animate.scaleX.to(1)
..animate.scaleY.to(1)
..animate.alpha.to(1)
..animate.rotation.to((math.PI*2)*3)
..onComplete = () => juggler.delayCall(playAnimation, 3);
}