Skip to content

Commit

Permalink
Fixing rounded rectangle. Issue #107
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi-rosso committed Jun 20, 2019
1 parent 1427296 commit 0230aab
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions flare_dart/lib/actor_rectangle.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
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;

@override
void invalidatePath() {}

@override
ActorComponent makeInstance(ActorArtboard resetArtboard) {
ActorRectangle instance = ActorRectangle();
instance.copyRectangle(this, resetArtboard);
Expand Down Expand Up @@ -41,17 +42,18 @@ class ActorRectangle extends ActorProceduralPath {

@override
List<PathPoint> 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<PathPoint> _rectanglePathPoints = <PathPoint>[];
_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;
}
Expand Down

0 comments on commit 0230aab

Please sign in to comment.