From f6955940a248bdf839b93c279688c61e0fd08444 Mon Sep 17 00:00:00 2001 From: Luigi Rosso Date: Wed, 9 Oct 2019 14:27:55 -0700 Subject: [PATCH] Squashed commit of the following: commit 86b8f41231411432ef89114c0ed4d7da7f5a2490 Author: Luigi Rosso Date: Wed Oct 9 14:26:06 2019 -0700 Squashed commit of the following: commit 373c14a4f3b2360c4252a8ac834c23bb28068f6e Author: Luigi Rosso Date: Wed Oct 9 14:21:47 2019 -0700 Fixing issue with image clipping. commit ae1c901441306953f09549b4c3bdd4612cc86af4 Author: Luigi Rosso Date: Wed Oct 9 11:19:16 2019 -0700 Fix merge bugs. commit d8cb780a543fe9fd35d60bcfcb198b70622c524f Author: Luigi Rosso Date: Wed Oct 9 11:09:42 2019 -0700 Adding support for difference clipping. commit bf99a765746f321937315e7ecd96aaa190a3d20b Author: Luigi Rosso Date: Tue Oct 8 19:07:26 2019 -0700 Matching stable version commit 9becc744d0d50f10533e3ad1f7c0b4daee6604c2 Author: Luigi Rosso Date: Tue Oct 8 13:58:11 2019 -0700 Bumping flare_dart to 2.0 due to breaking changes. commit 0a292cc67ea8d261057b9f9e5c32028e3436436c Author: Luigi Rosso Date: Tue Oct 8 13:39:57 2019 -0700 Bumping versions and changelogs. commit 431a98e4804efe6d073a9b55a9ce1a5f23c7ca4d Author: Luigi Rosso Date: Tue Oct 8 13:35:26 2019 -0700 Fixing up analysis issues for #169 commit 72fb6fc743ed3a241c7c51e5a8ebc90836f734ba Merge: 4d00202 dc68dea Author: Luigi Rosso Date: Tue Oct 8 13:02:17 2019 -0700 Merge branch 'master' of https://github.com/2d-inc/Flare-Flutter commit 4d00202a4f24b2c3d581b28cb15b953ec91c9f3c Author: Luigi Rosso Date: Tue Oct 8 13:02:11 2019 -0700 Cleaning up analysis issues. commit dc68dea6d57cb504d1a867c7e4c5b6768ec5dfe2 Merge: 5ca8d49 f1d9749 Author: Luigi Rosso 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 f1d97496a2679f470202f17298cd76a0411d7a8c Author: Mehmet Fidanboylu Date: Tue Oct 8 10:20:58 2019 -0700 Do the same changes to flare_dart commit 64f395edf7c6f8419a7a461e46664ff3723cfa78 Author: Mehmet Fidanboylu Date: Tue Oct 8 10:17:51 2019 -0700 Escalate the severity of unused imports in analyzer commit 5ca8d49c09406d1ac62ffffd4d0c5082744be7a3 Author: Luigi Rosso Date: Mon Oct 7 11:22:38 2019 -0700 Bumping versions and changelog. commit 874ce8e0b77a8ffc3eea9027cb31e2b75437da01 Author: Luigi Rosso Date: Mon Oct 7 11:20:28 2019 -0700 Adding support for nodes inside of shapes. commit 4d06431f341b426dd5cc41529a49c115e6354c51 Author: Luigi Rosso Date: Fri Oct 4 18:06:09 2019 -0700 Introducing FlareTesting.setup(); commit 2c5f4200535d679fd3092d1b6aa15ff71d85b869 Author: Luigi Rosso Date: Fri Oct 4 13:44:25 2019 -0700 Clamping trim start/end. commit daba34d11233391e7277b157bc117b8bbb626982 Author: Luigi Rosso Date: Mon Sep 30 21:21:55 2019 +0200 Cherry picking critical lints from #1 63 and updating for pub. commit 63b7b2cdf3f0036f1c817c21f078be985b1f1044 Author: Luigi Rosso Date: Wed Oct 9 11:18:18 2019 -0700 Fixing merge issues. commit ea16c60615ecc4e411d05a8e6a99c8996871062d Author: Luigi Rosso Date: Wed Oct 9 11:10:54 2019 -0700 Squashed commit of the following: commit d8cb780a543fe9fd35d60bcfcb198b70622c524f Author: Luigi Rosso Date: Wed Oct 9 11:09:42 2019 -0700 Adding support for difference clipping. commit bf99a765746f321937315e7ecd96aaa190a3d20b Author: Luigi Rosso Date: Tue Oct 8 19:07:26 2019 -0700 Matching stable version commit 9becc744d0d50f10533e3ad1f7c0b4daee6604c2 Author: Luigi Rosso Date: Tue Oct 8 13:58:11 2019 -0700 Bumping flare_dart to 2.0 due to breaking changes. commit 0a292cc67ea8d261057b9f9e5c32028e3436436c Author: Luigi Rosso Date: Tue Oct 8 13:39:57 2019 -0700 Bumping versions and changelogs. commit 431a98e4804efe6d073a9b55a9ce1a5f23c7ca4d Author: Luigi Rosso Date: Tue Oct 8 13:35:26 2019 -0700 Fixing up analysis issues for #169 commit 72fb6fc743ed3a241c7c51e5a8ebc90836f734ba Merge: 4d00202 dc68dea Author: Luigi Rosso Date: Tue Oct 8 13:02:17 2019 -0700 Merge branch 'master' of https://github.com/2d-inc/Flare-Flutter commit 4d00202a4f24b2c3d581b28cb15b953ec91c9f3c Author: Luigi Rosso Date: Tue Oct 8 13:02:11 2019 -0700 Cleaning up analysis issues. commit dc68dea6d57cb504d1a867c7e4c5b6768ec5dfe2 Merge: 5ca8d49 f1d9749 Author: Luigi Rosso 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 f1d97496a2679f470202f17298cd76a0411d7a8c Author: Mehmet Fidanboylu Date: Tue Oct 8 10:20:58 2019 -0700 Do the same changes to flare_dart commit 64f395edf7c6f8419a7a461e46664ff3723cfa78 Author: Mehmet Fidanboylu Date: Tue Oct 8 10:17:51 2019 -0700 Escalate the severity of unused imports in analyzer commit 5ca8d49c09406d1ac62ffffd4d0c5082744be7a3 Author: Luigi Rosso Date: Mon Oct 7 11:22:38 2019 -0700 Bumping versions and changelog. commit 874ce8e0b77a8ffc3eea9027cb31e2b75437da01 Author: Luigi Rosso Date: Mon Oct 7 11:20:28 2019 -0700 Adding support for nodes inside of shapes. commit 4d06431f341b426dd5cc41529a49c115e6354c51 Author: Luigi Rosso Date: Fri Oct 4 18:06:09 2019 -0700 Introducing FlareTesting.setup(); commit 2c5f4200535d679fd3092d1b6aa15ff71d85b869 Author: Luigi Rosso Date: Fri Oct 4 13:44:25 2019 -0700 Clamping trim start/end. commit daba34d11233391e7277b157bc117b8bbb626982 Author: Luigi Rosso Date: Mon Sep 30 21:21:55 2019 +0200 Cherry picking critical lints from #1 63 and updating for pub. --- flare_dart/CHANGELOG.md | 4 ++ flare_flutter/CHANGELOG.md | 4 ++ flare_flutter/lib/flare.dart | 101 +++++++++++++++++------------------ flare_flutter/pubspec.yaml | 2 +- 4 files changed, 57 insertions(+), 54 deletions(-) diff --git a/flare_dart/CHANGELOG.md b/flare_dart/CHANGELOG.md index 4643720..9866c97 100644 --- a/flare_dart/CHANGELOG.md +++ b/flare_dart/CHANGELOG.md @@ -1,3 +1,7 @@ +## [2.2.0] - 2019-10-09 11:19:06 + +- Fix merge bug that sneaked into pub. + ## [2.1.0] - 2019-10-09 11:08:05 - Adding support for difference clipping. diff --git a/flare_flutter/CHANGELOG.md b/flare_flutter/CHANGELOG.md index ef31e9c..c9846ef 100644 --- a/flare_flutter/CHANGELOG.md +++ b/flare_flutter/CHANGELOG.md @@ -1,3 +1,7 @@ +## [1.6.1] - 2019-10-09 14:20:54 + +- Image and Shapes share clipping logic. Fixes issue with image clipping. + ## [1.6.0] - 2019-10-09 11:08:52 - Using latest flare_dart with support for difference clipping. diff --git a/flare_flutter/lib/flare.dart b/flare_flutter/lib/flare.dart index 483b639..aa3edbb 100644 --- a/flare_flutter/lib/flare.dart +++ b/flare_flutter/lib/flare.dart @@ -53,6 +53,51 @@ abstract class FlutterActorDrawable { void onBlendModeChanged(ui.BlendMode blendMode); void draw(ui.Canvas canvas); + + List> get clipShapes; + ActorArtboard get artboard; + + void clip(ui.Canvas canvas) { + for (final List clips in clipShapes) { + for (final ClipShape clipShape in clips) { + var shape = clipShape.shape; + if (shape.renderCollapsed) { + continue; + } + if (clipShape.intersect) { + canvas.clipPath((shape as FlutterActorShape).path); + } else { + var artboardRect = Rect.fromLTWH( + artboard.origin[0] * artboard.width, + artboard.origin[1] * artboard.height, + artboard.width, + artboard.height); + + if (shape.fill != null && shape.fill.fillRule == FillRule.evenOdd) { + // One single clip path with subtraction rect and all sub paths. + var clipPath = ui.Path(); + clipPath.addRect(artboardRect); + for (final path in shape.paths) { + clipPath.addPath((path as FlutterPath).path, ui.Offset.zero, + matrix4: path.pathTransform?.mat4); + } + clipPath.fillType = PathFillType.evenOdd; + canvas.clipPath(clipPath); + } else { + // One clip path with rect per shape path. + for (final path in shape.paths) { + var clipPath = ui.Path(); + clipPath.addRect(artboardRect); + clipPath.addPath((path as FlutterPath).path, ui.Offset.zero, + matrix4: path.pathTransform?.mat4); + clipPath.fillType = PathFillType.evenOdd; + canvas.clipPath(clipPath); + } + } + } + } + } + } } abstract class FlutterFill { @@ -231,46 +276,7 @@ class FlutterActorShape extends ActorShape with FlutterActorDrawable { canvas.save(); - // Get Clips - for (final List clips in clipShapes) { - for (final ClipShape clipShape in clips) { - var shape = clipShape.shape; - if (shape.renderCollapsed) { - continue; - } - if (clipShape.intersect) { - canvas.clipPath((shape as FlutterActorShape).path); - } else { - var artboardRect = Rect.fromLTWH( - artboard.origin[0] * artboard.width, - artboard.origin[1] * artboard.height, - artboard.width, - artboard.height); - - if (shape.fill != null && shape.fill.fillRule == FillRule.evenOdd) { - // One single clip path with subtraction rect and all sub paths. - var clipPath = ui.Path(); - clipPath.addRect(artboardRect); - for (final path in shape.paths) { - clipPath.addPath((path as FlutterPath).path, ui.Offset.zero, - matrix4: path.pathTransform?.mat4); - } - clipPath.fillType = PathFillType.evenOdd; - canvas.clipPath(clipPath); - } else { - // One clip path with rect per shape path. - for (final path in shape.paths) { - var clipPath = ui.Path(); - clipPath.addRect(artboardRect); - clipPath.addPath((path as FlutterPath).path, ui.Offset.zero, - matrix4: path.pathTransform?.mat4); - clipPath.fillType = PathFillType.evenOdd; - canvas.clipPath(clipPath); - } - } - } - } - } + clip(canvas); ui.Path renderPath = getRenderPath(canvas); @@ -1129,19 +1135,8 @@ class FlutterActorImage extends ActorImage with FlutterActorDrawable { return; } canvas.save(); - // Get Clips - for (final List clips in clipShapes) { - if (clips.length == 1) { - canvas.clipPath((clips[0] as FlutterActorShape).path); - } else { - ui.Path clippingPath = ui.Path(); - for (final ClipShape clipShape in clips) { - clippingPath.addPath( - (clipShape.shape as FlutterActorShape).path, ui.Offset.zero); - } - canvas.clipPath(clippingPath); - } - } + + clip(canvas); _paint.color = _paint.color.withOpacity(renderOpacity.clamp(0.0, 1.0).toDouble()); diff --git a/flare_flutter/pubspec.yaml b/flare_flutter/pubspec.yaml index 4b4f69d..89dfcc8 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.6.0 +version: 1.6.1 author: "2Dimensions Team " homepage: https://github.com/2d-inc/Flare-Flutter environment: