stagexl 0.13.4 stagexl: ^0.13.4 copied to clipboard
A fast and universal 2D rendering engine for HTML5 and Dart.
library slot_machine;
import 'dart:async';
import 'dart:math' as math;
import 'dart:html' as html;
import 'package:stagexl/stagexl.dart';
Future main() async {
// configure StageXL default options
StageXL.stageOptions.renderEngine = RenderEngine.WebGL;
StageXL.stageOptions.backgroundColor = Color.Black;
StageXL.bitmapDataLoadOptions.webp = false;
// init Stage and RenderLoop
var canvas = html.querySelector('#stage');
var stage = new Stage(canvas, width: 800, height: 600);
var renderLoop = new RenderLoop();
renderLoop.addStage(stage);
var bitmapData = new BitmapData(32, 32, Color.Red);
var maskBitmapData = new BitmapData(64, 64, Color.Transparent);
var maskShape = new Shape();
maskShape.graphics.circle(32,32,30);
maskShape.graphics.fillColor(Color.Blue);
maskBitmapData.draw(maskShape);
for(int i = 0 ; i < 60; i++) {
var sprite = new Sprite();
sprite.x = (i % 10) * 80;
sprite.y = (i ~/ 10) * 80;
sprite.filters = [new AlphaMaskFilter(maskBitmapData)];
sprite.addTo(stage);
for(int j = 0; j <= i; j++) {
var bitmap = new Bitmap(bitmapData);
bitmap.x = j * 3;
bitmap.y = j * 3;
bitmap.addTo(sprite);
}
}
int frame = 0;
stage.onEnterFrame.listen((e) => print("frame: ${++frame}"));
}