stagexl 0.13.6 copy "stagexl: ^0.13.6" to clipboard
stagexl: ^0.13.6 copied to clipboard

outdatedDart 1 only

A fast and universal 2D rendering engine for HTML5 and Dart.

example/example.dart

import 'dart:html' show CanvasElement, document, window;
import 'package:stagexl/stagexl.dart';

void main()
{
  const w = 200;
  const h = 200;

  final canvas = new CanvasElement(width: w, height: h);

  document.body.children.add(canvas);

  // This bug occurs with both renderers
  StageXL.stageOptions
    ..renderEngine = RenderEngine.Canvas2D
    ..stageAlign = StageAlign.TOP_LEFT;

  final stage = new Stage(canvas);

  new RenderLoop()..addStage(stage);

  // Gradient that goes from blue to red, straight across
  final gradient = new GraphicsGradient.linear(0, h / 2, w, h / 2)
    ..addColorStop(0, Color.Blue)
    ..addColorStop(1, Color.Red);

  // Draw rect with gradient
  final sh = new Shape()..addTo(stage);
  sh.graphics..rect(0, 0, w, h)..fillGradient(gradient);

  // This color filter should result in red to green
  sh.filters = [new ColorMatrixFilter.adjust(hue: 0.75)];

  // Apply cache, Note: If we don't do this, we just get a solid
  // pink rectangle

  var sw = new Stopwatch();
  sw.start();
  for(int i = 0; i < 100; i++) {
    final r = sh.bounds;
    sh.applyCache(r.left, r.top, r.width, r.height);
  }
  print(sw.elapsed);
}
36
likes
0
pub points
62%
popularity

Publisher

unverified uploader

A fast and universal 2D rendering engine for HTML5 and Dart.

Homepage

Documentation

Documentation

License

unknown (LICENSE)

Dependencies

xml

More

Packages that depend on stagexl