diff --git a/flare_dart/lib/actor_rectangle.dart b/flare_dart/lib/actor_rectangle.dart index dbc2053..4a6a838 100644 --- a/flare_dart/lib/actor_rectangle.dart +++ b/flare_dart/lib/actor_rectangle.dart @@ -1,12 +1,12 @@ +import 'dart:math'; + import "actor_artboard.dart"; +import "actor_component.dart"; import "actor_node.dart"; -import "math/vec2d.dart"; -import "stream_reader.dart"; import "actor_path.dart"; +import "math/vec2d.dart"; import "path_point.dart"; -import "actor_component.dart"; - -const double CircleConstant = 0.55; +import "stream_reader.dart"; class ActorRectangle extends ActorProceduralPath { double _radius = 0.0; @@ -14,6 +14,7 @@ class ActorRectangle extends ActorProceduralPath { @override void invalidatePath() {} + @override ActorComponent makeInstance(ActorArtboard resetArtboard) { ActorRectangle instance = ActorRectangle(); instance.copyRectangle(this, resetArtboard); @@ -41,17 +42,18 @@ class ActorRectangle extends ActorProceduralPath { @override List get points { - double halfWidth = width / 2.0; - double halfHeight = height / 2.0; + double halfWidth = width / 2; + double halfHeight = height / 2; + double renderRadius = min(_radius, min(halfWidth, halfHeight)); List _rectanglePathPoints = []; _rectanglePathPoints.add(StraightPathPoint.fromValues( - Vec2D.fromValues(-halfWidth, -halfHeight), _radius)); + Vec2D.fromValues(-halfWidth, -halfHeight), renderRadius)); _rectanglePathPoints.add(StraightPathPoint.fromValues( - Vec2D.fromValues(halfWidth, -halfHeight), _radius)); + Vec2D.fromValues(halfWidth, -halfHeight), renderRadius)); _rectanglePathPoints.add(StraightPathPoint.fromValues( - Vec2D.fromValues(halfWidth, halfHeight), _radius)); + Vec2D.fromValues(halfWidth, halfHeight), renderRadius)); _rectanglePathPoints.add(StraightPathPoint.fromValues( - Vec2D.fromValues(-halfWidth, halfHeight), _radius)); + Vec2D.fromValues(-halfWidth, halfHeight), renderRadius)); return _rectanglePathPoints; } diff --git a/flare_flutter/lib/flare.dart b/flare_flutter/lib/flare.dart index 607bb46..cc4b48c 100644 --- a/flare_flutter/lib/flare.dart +++ b/flare_flutter/lib/flare.dart @@ -235,14 +235,25 @@ class FlutterActorShape extends ActorShape with FlutterActorDrawable { // Get Clips for (final List clips in clipShapes) { if (clips.length == 1) { - canvas.clipPath((clips[0] as FlutterActorShape).path); + if (clips.first.renderCollapsed) { + continue; + } + canvas.clipPath((clips.first as FlutterActorShape).path); } else { ui.Path clippingPath = ui.Path(); + bool empty = true; for (final ActorShape clipShape in clips) { + if (clipShape.renderCollapsed) { + continue; + } clippingPath.addPath( (clipShape as FlutterActorShape).path, ui.Offset.zero); + empty = false; + } + + if (!empty) { + canvas.clipPath(clippingPath); } - canvas.clipPath(clippingPath); } } if (fills != null) {