stagexl 0.13.7 stagexl: ^0.13.7 copied to clipboard
A fast and universal 2D rendering engine for HTML5 and Dart.
import 'dart:async';
import 'dart:html' as html;
import 'package:stagexl/stagexl.dart';
Future main() async {
StageXL.stageOptions.renderEngine = RenderEngine.WebGL;
StageXL.stageOptions.backgroundColor = 0xFF303030;
StageXL.stageOptions.transparent = true;
StageXL.bitmapDataLoadOptions.maxPixelRatio = 3;
// init Stage and RenderLoop
var canvas = html.querySelector('#stage');
var stage = new Stage(canvas, width: 400, height: 600);
var renderLoop = new RenderLoop();
renderLoop.addStage(stage);
var shape = new Shape();
shape.graphics.moveTo(20,20);
shape.graphics.lineTo(50,70);
shape.graphics.lineTo(80,60);
shape.graphics.strokeColor(Color.Red, 20, JointStyle.ROUND);
var bitmapData = new BitmapData(100,100, Color.Transparent);
bitmapData.draw(shape);
var png = bitmapData.toDataUrl();
print(png);
// ---------
var bitmapData2 = await BitmapData.load(png);
var bitmap = new Bitmap(bitmapData2);
stage.addChild(bitmap);
}