Skip to content

Commit

Permalink
Fixing issue 2d-inc#39.
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi-rosso committed Feb 4, 2019
1 parent d2f9792 commit a24291e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 51 deletions.
2 changes: 1 addition & 1 deletion flare_dart/lib/actor_color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion flare_dart/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flare_dart
description: Vector design and runtime animation.
version: 1.2.1
version: 1.2.2
author: "2Dimensions Team <[email protected]>"
homepage: https://github.com/2d-inc/Flare-Flutter
environment:
Expand Down
69 changes: 22 additions & 47 deletions flare_flutter/lib/flare.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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) {
Expand All @@ -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;
}
}

Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions flare_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: flare_flutter
description: Vector design and runtime animation for Flutter.
version: 1.2.1
version: 1.2.2
author: "2Dimensions Team <[email protected]>"
homepage: https://github.com/2d-inc/Flare-Flutter
environment:
sdk: ">=2.0.0-dev.58.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
flare_dart: ^1.2.1
flare_dart: ^1.2.2
# flare_dart:
# path: ../flare_dart
dev_dependencies:
Expand Down

0 comments on commit a24291e

Please sign in to comment.