Skip to content

Commit 2375f0c

Browse files
committed
Adding animation for effects.
1 parent dee0d83 commit 2375f0c

File tree

7 files changed

+921
-757
lines changed

7 files changed

+921
-757
lines changed

flare_dart/lib/actor.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,9 @@ abstract class Actor {
162162
artboard.completeResolveHierarchy();
163163
}
164164

165-
// Sort dependencies last.
166-
artboard.sortDependencies();
165+
for (final ActorArtboard artboard in _artboards) {
166+
artboard.sortDependencies();
167+
}
167168

168169
return success;
169170
}

flare_dart/lib/actor_artboard.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ class ActorArtboard {
240240
_dependencyOrder[component.graphOrder] = localComponent;
241241
localComponent.dirtMask = 255;
242242
}
243+
243244
_flags |= ActorFlags.isDirty;
244245
_root = _components[0] as ActorNode;
245246
resolveHierarchy();

flare_dart/lib/actor_blur.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,23 @@ import 'actor_layer_effect.dart';
44
import 'stream_reader.dart';
55

66
class ActorBlur extends ActorLayerEffect {
7-
double _blurX;
8-
double _blurY;
9-
double get blurX => _blurX;
10-
double get blurY => _blurY;
7+
double blurX;
8+
double blurY;
119

1210
static ActorBlur read(
1311
ActorArtboard artboard, StreamReader reader, ActorBlur component) {
1412
component ??= ActorBlur();
1513
ActorLayerEffect.read(artboard, reader, component);
16-
component._blurX = reader.readFloat32("blurX");
17-
component._blurY = reader.readFloat32("blurY");
14+
component.blurX = reader.readFloat32("blurX");
15+
component.blurY = reader.readFloat32("blurY");
1816

1917
return component;
2018
}
2119

2220
void copyBlur(ActorBlur from, ActorArtboard resetArtboard) {
2321
copyLayerEffect(from, resetArtboard);
24-
_blurX = from._blurX;
25-
_blurY = from._blurY;
22+
blurX = from.blurX;
23+
blurY = from.blurY;
2624
}
2725

2826
@override

flare_dart/lib/actor_shadow.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,28 @@ import 'actor_blur.dart';
55
import 'stream_reader.dart';
66

77
abstract class ActorShadow extends ActorBlur {
8-
double _offsetX;
9-
double _offsetY;
8+
double offsetX;
9+
double offsetY;
1010
Float32List _color = Float32List(4);
1111
int get blendModeId;
1212
set blendModeId(int value);
1313

14-
double get offsetX => _offsetX;
15-
double get offsetY => _offsetY;
1614
Float32List get color => _color;
1715

1816
static ActorShadow read(
1917
ActorArtboard artboard, StreamReader reader, ActorShadow component) {
2018
ActorBlur.read(artboard, reader, component);
21-
component._offsetX = reader.readFloat32("offsetX");
22-
component._offsetY = reader.readFloat32("offsetY");
19+
component.offsetX = reader.readFloat32("offsetX");
20+
component.offsetY = reader.readFloat32("offsetY");
2321
component._color = reader.readFloat32Array(4, "color");
2422
component.blendModeId = reader.readUint8("blendMode");
2523
return component;
2624
}
2725

2826
void copyShadow(ActorShadow from, ActorArtboard resetArtboard) {
2927
copyBlur(from, resetArtboard);
30-
_offsetX = from._offsetX;
31-
_offsetY = from._offsetY;
28+
offsetX = from.offsetX;
29+
offsetY = from.offsetY;
3230
_color[0] = from._color[0];
3331
_color[1] = from._color[1];
3432
_color[2] = from._color[2];

flare_dart/lib/animation/actor_animation.dart

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,21 @@ class PropertyAnimation {
9090
case PropertyTypes.fillColor:
9191
keyFrameReader = KeyFrameFillColor.read;
9292
break;
93+
case PropertyTypes.color:
94+
keyFrameReader = KeyFrameShadowColor.read;
95+
break;
96+
case PropertyTypes.offsetX:
97+
keyFrameReader = KeyFrameShadowOffsetX.read;
98+
break;
99+
case PropertyTypes.offsetY:
100+
keyFrameReader = KeyFrameShadowOffsetY.read;
101+
break;
102+
case PropertyTypes.blurX:
103+
keyFrameReader = KeyFrameBlurX.read;
104+
break;
105+
case PropertyTypes.blurY:
106+
keyFrameReader = KeyFrameBlurY.read;
107+
break;
93108
case PropertyTypes.fillGradient:
94109
keyFrameReader = KeyFrameGradient.read;
95110
break;
@@ -381,13 +396,13 @@ class ActorAnimation {
381396
/// Apply the specified time to all the components of this animation.
382397
/// This operation will result in the application of the keyframe values
383398
/// at the given time, and perform interpolation if needed.
384-
///
399+
///
385400
/// @time is the current time for this animation
386401
/// @artboard is the artboard that contains it
387402
/// @mix is a value [0,1]
388-
/// This is a blending parameter to allow smoothing between concurrent
389-
/// animations.
390-
/// By setting mix to 1, the current animation will fully replace the
403+
/// This is a blending parameter to allow smoothing between concurrent
404+
/// animations.
405+
/// By setting mix to 1, the current animation will fully replace the
391406
/// existing values. By ramping up mix with values between 0 and 1, the
392407
/// transition from one animation to the next will be more gradual as it
393408
/// gets mixed in, preventing poppying effects.

0 commit comments

Comments
 (0)