mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 10:38:17 +08:00
Adding basic SVG support (#61)
This commit is contained in:
@ -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) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user