diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a4a31d..fbda23a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ -## [0.6.6] - Not yet released +## [0.6.6] - 2021-01-18 16:40:10 - Adds getters for start/endTime and reset() in LinearAnimationInstance +- Fixes an issue with artboard background gradients when rendering with non-default origin values. +- Fixes an issue with trim paths across open paths. ## [0.6.5] - 2020-12-22 16:49:39 diff --git a/example/macos/Runner.xcodeproj/project.pbxproj b/example/macos/Runner.xcodeproj/project.pbxproj index d85789b..2e5079f 100644 --- a/example/macos/Runner.xcodeproj/project.pbxproj +++ b/example/macos/Runner.xcodeproj/project.pbxproj @@ -26,10 +26,6 @@ 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; - 33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; }; - 33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - D73912F022F37F9E000D13A0 /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; }; - D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -49,8 +45,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */, - 33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */, ); name = "Bundle Framework"; runOnlyForDeploymentPostprocessing = 0; @@ -69,13 +63,11 @@ 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; - 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FlutterMacOS.framework; path = Flutter/ephemeral/FlutterMacOS.framework; sourceTree = SOURCE_ROOT; }; 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; - D73912EF22F37F9E000D13A0 /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/ephemeral/App.framework; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -83,8 +75,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - D73912F022F37F9E000D13A0 /* App.framework in Frameworks */, - 33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -138,8 +128,6 @@ 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, - D73912EF22F37F9E000D13A0 /* App.framework */, - 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */, ); path = Flutter; sourceTree = ""; @@ -260,7 +248,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename\n"; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; }; 33CC111E2044C6BF0003C045 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; diff --git a/lib/src/rive_core/animation/keyed_property.dart b/lib/src/rive_core/animation/keyed_property.dart index bbe4e82..7b2d6ae 100644 --- a/lib/src/rive_core/animation/keyed_property.dart +++ b/lib/src/rive_core/animation/keyed_property.dart @@ -93,10 +93,7 @@ class KeyedProperty extends KeyedPropertyBase int get numFrames => _keyframes.length; KeyFrame getFrameAt(int index) => _keyframes[index]; - void apply(double seconds, double mix, Core object) { - if (_keyframes.isEmpty) { - return; - } + int closestFrameIndex(double seconds) { int idx = 0; int mid = 0; double closestSeconds = 0; @@ -115,6 +112,14 @@ class KeyedProperty extends KeyedPropertyBase } idx = start; } + return idx; + } + + void apply(double seconds, double mix, Core object) { + if (_keyframes.isEmpty) { + return; + } + int idx = closestFrameIndex(seconds); int pk = propertyKey; if (idx == 0) { var first = _keyframes[0]; diff --git a/lib/src/rive_core/animation/linear_animation_instance.dart b/lib/src/rive_core/animation/linear_animation_instance.dart index 8ebbcc8..1f8b6f9 100644 --- a/lib/src/rive_core/animation/linear_animation_instance.dart +++ b/lib/src/rive_core/animation/linear_animation_instance.dart @@ -3,16 +3,12 @@ import 'package:rive/src/rive_core/animation/loop.dart'; class LinearAnimationInstance { final LinearAnimation animation; - double _time; + double _time = 0; int _direction = 1; - LinearAnimationInstance(this.animation) - : assert(animation != null), - _time = + : _time = (animation.enableWorkArea ? animation.workStart : 0).toDouble() / animation.fps; - - /// Note that when time is set, the direction will be changed to 1 set time(double value) { if (_time == value) { return; @@ -21,30 +17,17 @@ class LinearAnimationInstance { _direction = 1; } - /// Returns the current time position of the animation in seconds double get time => _time; - - /// Direction should only be +1 or -1 set direction(int value) => _direction = value == -1 ? -1 : 1; - - /// Returns the animation's play direction: 1 for forwards, -1 for backwards int get direction => _direction; - - /// Returns the end time of the animation in seconds double get endTime => (animation.enableWorkArea ? animation.workEnd : animation.duration) .toDouble() / animation.fps; - - /// Returns the start time of the animation in seconds double get startTime => (animation.enableWorkArea ? animation.workStart : 0).toDouble() / animation.fps; - - /// Resets the animation to the starting frame void reset() => _time = startTime; - - /// Advances the animation by the time provided bool advance(double elapsedSeconds) { _time += elapsedSeconds * animation.speed * _direction; double frames = _time * animation.fps; diff --git a/lib/src/rive_core/artboard.dart b/lib/src/rive_core/artboard.dart index d3d1e43..7000fad 100644 --- a/lib/src/rive_core/artboard.dart +++ b/lib/src/rive_core/artboard.dart @@ -118,7 +118,8 @@ class Artboard extends ArtboardBase with ShapePaintContainer { @override void update(int dirt) { if (dirt & ComponentDirt.worldTransform != 0) { - var rect = Rect.fromLTWH(0, 0, width, height); + var rect = Rect.fromLTWH( + width * (-originX ?? 0), height * (-originY ?? 0), width, height); path.reset(); path.addRect(rect); } @@ -163,12 +164,12 @@ class Artboard extends ArtboardBase with ShapePaintContainer { } void draw(Canvas canvas) { - for (final fill in fills) { - fill.draw(canvas, path); - } canvas.save(); canvas.clipRect(Rect.fromLTWH(0, 0, width, height)); canvas.translate(width * (originX ?? 0), height * (originY ?? 0)); + for (final fill in fills) { + fill.draw(canvas, path); + } for (var drawable = _firstDrawable; drawable != null; drawable = drawable.prev) { diff --git a/lib/src/rive_core/shapes/paint/trim_path_drawing.dart b/lib/src/rive_core/shapes/paint/trim_path_drawing.dart index 14f0c21..71e0e67 100644 --- a/lib/src/rive_core/shapes/paint/trim_path_drawing.dart +++ b/lib/src/rive_core/shapes/paint/trim_path_drawing.dart @@ -26,7 +26,11 @@ _FirstExtractedPath _appendPathSegmentSequential( first = _FirstExtractedPath(extracted, metric, extractLength); } else if (first.metric == metric) { first.length += extractLength; - first.path.extendWithPath(extracted, Offset.zero); + if (metric.isClosed) { + first.path.extendWithPath(extracted, Offset.zero); + } else { + result.addPath(extracted, Offset.zero); + } } else { if (metric.isClosed && extractLength == metric.length) { extracted.close(); diff --git a/lib/src/rive_core/shapes/shape.dart b/lib/src/rive_core/shapes/shape.dart index b159dae..8b8d286 100644 --- a/lib/src/rive_core/shapes/shape.dart +++ b/lib/src/rive_core/shapes/shape.dart @@ -41,6 +41,8 @@ class Shape extends ShapeBase with ShapePaintContainer { void pathChanged(Path path) => _markComposerDirty(); void paintChanged() { addDirt(ComponentDirt.path); + _markBlendModeDirty(); + _markRenderOpacityDirty(); for (final d in dependents) { d.addDirt(ComponentDirt.worldTransform); } @@ -155,21 +157,14 @@ class Shape extends ShapeBase with ShapePaintContainer { } void _markBlendModeDirty() => addDirt(ComponentDirt.blendMode); + void _markRenderOpacityDirty() => addDirt(ComponentDirt.worldTransform); @override void onPaintMutatorChanged(ShapePaintMutator mutator) { paintChanged(); - _markBlendModeDirty(); } @override - void onStrokesChanged() { - paintChanged(); - _markBlendModeDirty(); - } - + void onStrokesChanged() => paintChanged(); @override - void onFillsChanged() { - paintChanged(); - _markBlendModeDirty(); - } + void onFillsChanged() => paintChanged(); } diff --git a/pubspec.yaml b/pubspec.yaml index 9e1ae2a..1a54939 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: rive description: Rive 2 Flutter Runtime. This package provides runtime functionality for playing back and interacting with animations built with the Rive editor available at https://rive.app. -version: 0.6.5 +version: 0.6.6 repository: https://github.com/rive-app/rive-flutter homepage: https://rive.app