mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-13 19:30:14 +08:00
fix: Added useArtboardSize functionality (#2294)
This commit is contained in:
@@ -17,25 +17,32 @@ class RiveComponent extends PositionComponent {
|
|||||||
RiveComponent({
|
RiveComponent({
|
||||||
required this.artboard,
|
required this.artboard,
|
||||||
bool antialiasing = true,
|
bool antialiasing = true,
|
||||||
bool useArtboardSize = true,
|
@Deprecated(
|
||||||
|
"Will be removed in v1.8.0, use size's default value for ArtboardSize",
|
||||||
|
)
|
||||||
|
bool useArtboardSize = true,
|
||||||
BoxFit fit = BoxFit.contain,
|
BoxFit fit = BoxFit.contain,
|
||||||
Alignment alignment = Alignment.center,
|
Alignment alignment = Alignment.center,
|
||||||
|
|
||||||
// position component arguments
|
// position component arguments
|
||||||
super.position,
|
super.position,
|
||||||
super.size,
|
|
||||||
|
/// The logical size of the component.
|
||||||
|
/// Default value is ArtboardSize
|
||||||
|
Vector2? size,
|
||||||
super.scale,
|
super.scale,
|
||||||
double super.angle = 0.0,
|
double super.angle = 0.0,
|
||||||
Anchor super.anchor = Anchor.topLeft,
|
Anchor super.anchor = Anchor.topLeft,
|
||||||
super.children,
|
super.children,
|
||||||
super.priority,
|
super.priority,
|
||||||
}) : _renderer = RiveArtboardRenderer(
|
}) : _renderer = RiveArtboardRenderer(
|
||||||
antialiasing: antialiasing,
|
antialiasing: antialiasing,
|
||||||
useArtboardSize: useArtboardSize,
|
useArtboardSize: useArtboardSize,
|
||||||
fit: fit,
|
fit: fit,
|
||||||
alignment: alignment,
|
alignment: alignment,
|
||||||
artboard: artboard,
|
artboard: artboard,
|
||||||
);
|
),
|
||||||
|
super(size: size ?? Vector2(artboard.width, artboard.height));
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void render(ui.Canvas canvas) {
|
void render(ui.Canvas canvas) {
|
||||||
|
|||||||
@@ -125,6 +125,28 @@ void main() {
|
|||||||
expect(riveComponent.artboard.antialiasing, isFalse);
|
expect(riveComponent.artboard.antialiasing, isFalse);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
group('Component size', () {
|
||||||
|
test('use specifiy size', () async {
|
||||||
|
final skillsArtboard = await loadArtboard(riveFile);
|
||||||
|
final riveComponent = RiveComponent(
|
||||||
|
artboard: skillsArtboard,
|
||||||
|
size: Vector2.all(250.0),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(riveComponent.size, Vector2.all(250.0));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('deafult value (ArtboardSize)', () async {
|
||||||
|
final skillsArtboard = await loadArtboard(riveFile);
|
||||||
|
final riveComponent = RiveComponent(artboard: skillsArtboard);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
riveComponent.size,
|
||||||
|
Vector2(skillsArtboard.width, skillsArtboard.height),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user