From a24291e5e891e3dd2ac996a971861782a139bab9 Mon Sep 17 00:00:00 2001 From: Luigi Rosso Date: Mon, 4 Feb 2019 12:26:44 +0100 Subject: [PATCH] Fixing issue #39. --- flare_dart/lib/actor_color.dart | 2 +- flare_dart/pubspec.yaml | 2 +- flare_flutter/lib/flare.dart | 69 +++++++++++---------------------- flare_flutter/pubspec.yaml | 4 +- 4 files changed, 26 insertions(+), 51 deletions(-) diff --git a/flare_dart/lib/actor_color.dart b/flare_dart/lib/actor_color.dart index 4aed4c4..f69666f 100644 --- a/flare_dart/lib/actor_color.dart +++ b/flare_dart/lib/actor_color.dart @@ -68,7 +68,7 @@ abstract class ActorColor extends ActorPaint { Float32List _color = Float32List(4); Float32List get color { - return _color; + return artboard?.overrideColor ?? _color; } set color(Float32List value) { diff --git a/flare_dart/pubspec.yaml b/flare_dart/pubspec.yaml index 12747ee..35f796c 100644 --- a/flare_dart/pubspec.yaml +++ b/flare_dart/pubspec.yaml @@ -1,6 +1,6 @@ name: flare_dart description: Vector design and runtime animation. -version: 1.2.1 +version: 1.2.2 author: "2Dimensions Team " homepage: https://github.com/2d-inc/Flare-Flutter environment: diff --git a/flare_flutter/lib/flare.dart b/flare_flutter/lib/flare.dart index ef43334..eb16553 100644 --- a/flare_flutter/lib/flare.dart +++ b/flare_flutter/lib/flare.dart @@ -184,42 +184,12 @@ class FlutterActorShape extends ActorShape { for (ActorFill actorFill in fills) { FlutterFill fill = actorFill as FlutterFill; fill.paint(actorFill, canvas, renderPath); - // ui.Paint paint = fill.getPaint(paintTransform, opacity); - // if (paint == null) { - // continue; - // } - // if (overrideColor != null) { - // paint.color = overrideColor.withOpacity( - // (overrideColor.opacity * paint.color.opacity).clamp(0.0, 1.0)); - // } - - // switch ((fill as ActorFill).fillRule) { - // case FillRule.EvenOdd: - // renderPath.fillType = ui.PathFillType.evenOdd; - // break; - // case FillRule.NonZero: - // renderPath.fillType = ui.PathFillType.nonZero; - // break; - // } - // canvas.drawPath(renderPath, paint); } } if (strokes != null) { for (ActorStroke actorStroke in strokes) { FlutterStroke stroke = actorStroke as FlutterStroke; stroke.paint(actorStroke, canvas, renderPath); - // ui.Paint paint = stroke.getPaint(paintTransform, opacity); - // if (paint == null) { - // continue; - // } - // if (overrideColor != null) { - // paint.color = overrideColor.withOpacity( - // (overrideColor.opacity * paint.color.opacity).clamp(0.0, 1.0)); - // } - // ui.Path trimmedPath = Path.from(renderPath); - // trimmedPath.trim(trimStart, 0.2 + trimStart, false); - // trimStart += 0.01; - // canvas.drawPath(trimmedPath, paint); } } @@ -242,8 +212,11 @@ class FlutterColorFill extends ColorFill with FlutterFill { Color get uiColor { Float32List c = color; - return Color.fromRGBO((c[0] * 255.0).round(), (c[1] * 255.0).round(), - (c[2] * 255.0).round(), c[3]); + return Color.fromRGBO( + (c[0] * 255.0).round(), + (c[1] * 255.0).round(), + (c[2] * 255.0).round(), + c[3] * artboard.modulateOpacity * opacity * shape.renderOpacity); } set uiColor(Color c) { @@ -254,11 +227,7 @@ class FlutterColorFill extends ColorFill with FlutterFill { @override void update(int dirt) { super.update(dirt); - _paint.color = ui.Color.fromRGBO( - (color[0] * 255.0).round(), - (color[1] * 255.0).round(), - (color[2] * 255.0).round(), - color[3] * opacity * shape.renderOpacity); + _paint.color = uiColor; } } @@ -269,19 +238,25 @@ class FlutterColorStroke extends ColorStroke with FlutterStroke { return instanceNode; } + Color get uiColor { + Float32List c = color; + return Color.fromRGBO( + (c[0] * 255.0).round(), + (c[1] * 255.0).round(), + (c[2] * 255.0).round(), + c[3] * artboard.modulateOpacity * opacity * shape.renderOpacity); + } + + set uiColor(Color c) { + color = Float32List.fromList( + [c.red / 255, c.green / 255, c.blue / 255, c.opacity]); + } + @override void update(int dirt) { super.update(dirt); - Float32List paintColor = artboard.overrideColor ?? color; _paint - ..color = ui.Color.fromRGBO( - (paintColor[0] * 255.0).round(), - (paintColor[1] * 255.0).round(), - (paintColor[2] * 255.0).round(), - paintColor[3] * - artboard.modulateOpacity * - opacity * - shape.renderOpacity) + ..color = uiColor ..strokeWidth = width; } } @@ -410,7 +385,7 @@ class FlutterRadialFill extends RadialGradientFill with FlutterFill { radius, colors, stops, - ui.TileMode.clamp); //, transform.mat4); + ui.TileMode.clamp); Color paintColor; if (artboard.overrideColor == null) { diff --git a/flare_flutter/pubspec.yaml b/flare_flutter/pubspec.yaml index c454fc8..8ca8012 100644 --- a/flare_flutter/pubspec.yaml +++ b/flare_flutter/pubspec.yaml @@ -1,6 +1,6 @@ name: flare_flutter description: Vector design and runtime animation for Flutter. -version: 1.2.1 +version: 1.2.2 author: "2Dimensions Team " homepage: https://github.com/2d-inc/Flare-Flutter environment: @@ -8,7 +8,7 @@ environment: dependencies: flutter: sdk: flutter - flare_dart: ^1.2.1 + flare_dart: ^1.2.2 # flare_dart: # path: ../flare_dart dev_dependencies: