Skip to content

Commit 86b8f41

Browse files
committed
Squashed commit of the following:
commit 373c14a Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Wed Oct 9 14:21:47 2019 -0700 Fixing issue with image clipping. commit ae1c901 Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Wed Oct 9 11:19:16 2019 -0700 Fix merge bugs. commit d8cb780 Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Wed Oct 9 11:09:42 2019 -0700 Adding support for difference clipping. commit bf99a76 Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Tue Oct 8 19:07:26 2019 -0700 Matching stable version commit 9becc74 Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Tue Oct 8 13:58:11 2019 -0700 Bumping flare_dart to 2.0 due to breaking changes. commit 0a292cc Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Tue Oct 8 13:39:57 2019 -0700 Bumping versions and changelogs. commit 431a98e Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Tue Oct 8 13:35:26 2019 -0700 Fixing up analysis issues for #169 commit 72fb6fc Merge: 4d00202 dc68dea Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Tue Oct 8 13:02:17 2019 -0700 Merge branch 'master' of https://github.com/2d-inc/Flare-Flutter commit 4d00202 Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Tue Oct 8 13:02:11 2019 -0700 Cleaning up analysis issues. commit dc68dea Merge: 5ca8d49 f1d9749 Author: Luigi Rosso <luigi-rosso@users.noreply.github.com> Date: Tue Oct 8 11:06:53 2019 -0700 Merge pull request #168 from mehmetf/master Escalate the severity of unused imports in analyzer commit f1d9749 Author: Mehmet Fidanboylu <mehmetf@google.com> Date: Tue Oct 8 10:20:58 2019 -0700 Do the same changes to flare_dart commit 64f395e Author: Mehmet Fidanboylu <mehmetf@google.com> Date: Tue Oct 8 10:17:51 2019 -0700 Escalate the severity of unused imports in analyzer commit 5ca8d49 Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Mon Oct 7 11:22:38 2019 -0700 Bumping versions and changelog. commit 874ce8e Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Mon Oct 7 11:20:28 2019 -0700 Adding support for nodes inside of shapes. commit 4d06431 Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Fri Oct 4 18:06:09 2019 -0700 Introducing FlareTesting.setup(); commit 2c5f420 Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Fri Oct 4 13:44:25 2019 -0700 Clamping trim start/end. commit daba34d Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Mon Sep 30 21:21:55 2019 +0200 Cherry picking critical lints from #1 63 and updating for pub.
1 parent 63b7b2c commit 86b8f41

File tree

4 files changed

+57
-54
lines changed

4 files changed

+57
-54
lines changed

flare_dart/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [2.2.0] - 2019-10-09 11:19:06
2+
3+
- Fix merge bug that sneaked into pub.
4+
15
## [2.1.0] - 2019-10-09 11:08:05
26

37
- Adding support for difference clipping.

flare_flutter/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [1.6.1] - 2019-10-09 14:20:54
2+
3+
- Image and Shapes share clipping logic. Fixes issue with image clipping.
4+
15
## [1.6.0] - 2019-10-09 11:08:52
26

37
- Using latest flare_dart with support for difference clipping.

flare_flutter/lib/flare.dart

Lines changed: 48 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,51 @@ abstract class FlutterActorDrawable {
5353
void onBlendModeChanged(ui.BlendMode blendMode);
5454

5555
void draw(ui.Canvas canvas);
56+
57+
List<List<ClipShape>> get clipShapes;
58+
ActorArtboard get artboard;
59+
60+
void clip(ui.Canvas canvas) {
61+
for (final List<ClipShape> clips in clipShapes) {
62+
for (final ClipShape clipShape in clips) {
63+
var shape = clipShape.shape;
64+
if (shape.renderCollapsed) {
65+
continue;
66+
}
67+
if (clipShape.intersect) {
68+
canvas.clipPath((shape as FlutterActorShape).path);
69+
} else {
70+
var artboardRect = Rect.fromLTWH(
71+
artboard.origin[0] * artboard.width,
72+
artboard.origin[1] * artboard.height,
73+
artboard.width,
74+
artboard.height);
75+
76+
if (shape.fill != null && shape.fill.fillRule == FillRule.evenOdd) {
77+
// One single clip path with subtraction rect and all sub paths.
78+
var clipPath = ui.Path();
79+
clipPath.addRect(artboardRect);
80+
for (final path in shape.paths) {
81+
clipPath.addPath((path as FlutterPath).path, ui.Offset.zero,
82+
matrix4: path.pathTransform?.mat4);
83+
}
84+
clipPath.fillType = PathFillType.evenOdd;
85+
canvas.clipPath(clipPath);
86+
} else {
87+
// One clip path with rect per shape path.
88+
for (final path in shape.paths) {
89+
var clipPath = ui.Path();
90+
clipPath.addRect(artboardRect);
91+
clipPath.addPath((path as FlutterPath).path, ui.Offset.zero,
92+
matrix4: path.pathTransform?.mat4);
93+
clipPath.fillType = PathFillType.evenOdd;
94+
canvas.clipPath(clipPath);
95+
}
96+
}
97+
}
98+
}
99+
}
100+
}
56101
}
57102

58103
abstract class FlutterFill {
@@ -231,46 +276,7 @@ class FlutterActorShape extends ActorShape with FlutterActorDrawable {
231276

232277
canvas.save();
233278

234-
// Get Clips
235-
for (final List<ClipShape> clips in clipShapes) {
236-
for (final ClipShape clipShape in clips) {
237-
var shape = clipShape.shape;
238-
if (shape.renderCollapsed) {
239-
continue;
240-
}
241-
if (clipShape.intersect) {
242-
canvas.clipPath((shape as FlutterActorShape).path);
243-
} else {
244-
var artboardRect = Rect.fromLTWH(
245-
artboard.origin[0] * artboard.width,
246-
artboard.origin[1] * artboard.height,
247-
artboard.width,
248-
artboard.height);
249-
250-
if (shape.fill != null && shape.fill.fillRule == FillRule.evenOdd) {
251-
// One single clip path with subtraction rect and all sub paths.
252-
var clipPath = ui.Path();
253-
clipPath.addRect(artboardRect);
254-
for (final path in shape.paths) {
255-
clipPath.addPath((path as FlutterPath).path, ui.Offset.zero,
256-
matrix4: path.pathTransform?.mat4);
257-
}
258-
clipPath.fillType = PathFillType.evenOdd;
259-
canvas.clipPath(clipPath);
260-
} else {
261-
// One clip path with rect per shape path.
262-
for (final path in shape.paths) {
263-
var clipPath = ui.Path();
264-
clipPath.addRect(artboardRect);
265-
clipPath.addPath((path as FlutterPath).path, ui.Offset.zero,
266-
matrix4: path.pathTransform?.mat4);
267-
clipPath.fillType = PathFillType.evenOdd;
268-
canvas.clipPath(clipPath);
269-
}
270-
}
271-
}
272-
}
273-
}
279+
clip(canvas);
274280

275281
ui.Path renderPath = getRenderPath(canvas);
276282

@@ -1129,19 +1135,8 @@ class FlutterActorImage extends ActorImage with FlutterActorDrawable {
11291135
return;
11301136
}
11311137
canvas.save();
1132-
// Get Clips
1133-
for (final List<ClipShape> clips in clipShapes) {
1134-
if (clips.length == 1) {
1135-
canvas.clipPath((clips[0] as FlutterActorShape).path);
1136-
} else {
1137-
ui.Path clippingPath = ui.Path();
1138-
for (final ClipShape clipShape in clips) {
1139-
clippingPath.addPath(
1140-
(clipShape.shape as FlutterActorShape).path, ui.Offset.zero);
1141-
}
1142-
canvas.clipPath(clippingPath);
1143-
}
1144-
}
1138+
1139+
clip(canvas);
11451140

11461141
_paint.color =
11471142
_paint.color.withOpacity(renderOpacity.clamp(0.0, 1.0).toDouble());

flare_flutter/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flare_flutter
22
description: Vector design and runtime animation for Flutter.
3-
version: 1.6.0
3+
version: 1.6.1
44
author: "2Dimensions Team <info@2dimensions.com>"
55
homepage: https://github.com/2d-inc/Flare-Flutter
66
environment:

0 commit comments

Comments
 (0)