Adding basic SVG support (#61)

This commit is contained in:
Erick
2019-03-21 21:42:52 -03:00
committed by GitHub
parent 72448cb9a6
commit b86f53929e
12 changed files with 251 additions and 2 deletions

View File

@ -3,6 +3,7 @@ import 'dart:ui';
import 'package:flutter/painting.dart';
import '../svg.dart';
import '../sprite.dart';
import '../position.dart';
import '../anchor.dart';
@ -134,3 +135,26 @@ class SpriteComponent extends PositionComponent {
@override
void update(double t) {}
}
class SvgComponent extends PositionComponent {
Svg svg;
SvgComponent.fromSvg(double width, double height, this.svg) {
this.width = width;
this.height = height;
}
@override
render(Canvas canvas) {
prepareCanvas(canvas);
svg.render(canvas, width, height);
}
@override
bool loaded() {
return svg != null && svg.loaded() && x != null && y != null;
}
@override
void update(double t) {}
}