Skip to content

Commit 0b759df

Browse files
committed
Squashed commit of the following:
commit e9712a4 Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Thu Nov 7 12:32:17 2019 -0800 Bumping versions. commit 366cdc0 Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Thu Nov 7 12:27:53 2019 -0800 Adding support for runtime image swapping, requires marking image nodes as isDynamic in Flare. Issue #183. commit 53a7c65 Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Wed Nov 6 17:30:42 2019 -0800 Updating flare_flutter version. commit b391dd4 Merge: 1e9b22e 9ec074b Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Wed Nov 6 17:28:34 2019 -0800 Merge branch 'warmth_fix' commit 9ec074b Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Wed Nov 6 15:43:31 2019 -0800 Call setState if mounted. commit c66ac64 Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Wed Nov 6 15:38:06 2019 -0800 Addressing an issue found in #177 with FlareCacheBuilder setting state when widget is no longer mounted. commit 1e9b22e Author: Umberto Sonnino <rimher@gmail.com> Date: Wed Nov 6 19:02:25 2019 +0100 Init mat before inverting commit bc07b87 Author: Umberto Sonnino <rimher@gmail.com> Date: Wed Nov 6 19:00:13 2019 +0100 Remove local flare_dart from examples pubspec #184 commit e1cca7c Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Tue Oct 29 12:50:30 2019 -0700 Bumping versions, merging optimal_load branch, and persisting settings in checkbox example. commit 55cae39 Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Tue Oct 29 12:41:43 2019 -0700 Copy transform affects stroke properly when instancing shapes. commit 43716dd Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Mon Oct 28 12:52:09 2019 -0700 Prevent coldLoad (async) from happening when widget isn’t ready to load. commit 506837e Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Fri Oct 25 13:00:56 2019 -0700 Improving loading. commit 9ee95b9 Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Fri Oct 25 10:42:42 2019 -0700 Make sure overrideColor is set even when drawableNodes is null. commit 7d59de1 Author: Umberto Sonnino <rimher@gmail.com> Date: Fri Oct 25 13:15:34 2019 +0100 Move null check commit 528af53 Author: Umberto Sonnino <rimher@gmail.com> Date: Fri Oct 25 13:10:17 2019 +0100 Insert null checks for artboards with no drawables #178 commit 33f23a7 Author: Umberto Sonnino <rimher@gmail.com> Date: Fri Oct 25 12:16:16 2019 +0100 Remove GradientColor override of ActorPaint opacity getter #179 commit 59ba2f0 Author: Umberto Sonnino <rimher@gmail.com> Date: Thu Oct 24 09:31:41 2019 +0100 Document the `actor_animatino.apply()` function commit d77438f Author: Umberto Sonnino <rimher@gmail.com> Date: Thu Oct 24 09:31:10 2019 +0100 Fix division by 0 on transform constraint commit f0cf988 Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Fri Oct 11 12:59:13 2019 -0700 Fix reading of JSON clip values. Issue #172 commit a7796e0 Author: Luigi Rosso <luigi.rosso@gmail.com> Date: Fri Oct 11 12:39:48 2019 -0700 Mitigating issue #172. 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 ee997b7 commit 0b759df

File tree

6 files changed

+83
-3
lines changed

6 files changed

+83
-3
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.4] - 2019-11-07 12:14:49
2+
3+
- Adding support for ActorImage.isDynamic which allows Flare to pacakge source UV coordinates for the image such that it can be swapped at runtime. This requires re-exporting files from Flare after marking the image as dynamic in the Flare UI.
4+
15
## [2.2.3] - 2019-10-29 12:44:02
26

37
- Copy transformAffectsStroke from the source shape when instancing.

flare_dart/lib/actor_image.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class ActorImage extends ActorDrawable with ActorSkinnable {
2828

2929
int _textureIndex = -1;
3030
Float32List _vertices;
31+
Float32List _dynamicUV;
32+
Float32List get dynamicUV => _dynamicUV;
3133
Uint16List _triangles;
3234
int _vertexCount = 0;
3335
int _triangleCount = 0;
@@ -141,6 +143,15 @@ class ActorImage extends ActorDrawable with ActorSkinnable {
141143
node._vertices =
142144
reader.readFloat32Array(numVertices * node.vertexStride, "vertices");
143145

146+
// In version 24 we started packing the original UV coordinates if the
147+
// image was marked for dynamic runtime swapping.
148+
if (artboard.actor.version >= 24) {
149+
bool isDynamic = reader.readBool("isDynamic");
150+
if (isDynamic) {
151+
node._dynamicUV = reader.readFloat32Array(numVertices * 2, "uv");
152+
}
153+
}
154+
144155
int numTris = reader.readUint32("numTriangles");
145156
node._triangles = Uint16List(numTris * 3);
146157
node._triangleCount = numTris;
@@ -217,6 +228,7 @@ class ActorImage extends ActorDrawable with ActorSkinnable {
217228
_triangleCount = node._triangleCount;
218229
_vertices = node._vertices;
219230
_triangles = node._triangles;
231+
_dynamicUV = node._dynamicUV;
220232
if (node._animationDeformedVertices != null) {
221233
_animationDeformedVertices =
222234
Float32List.fromList(node._animationDeformedVertices);

flare_dart/pubspec.yaml

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

flare_flutter/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [1.7.0] - 2019-11-07 12:16:35
2+
3+
- Adding support for runtime image swapping.
4+
15
## [1.6.5] - 2019-11-06 17:29:43
26

37
- Fixed an issue with FlareCacheBuilder calling setState when the widget is no longer mounted.

flare_flutter/lib/flare.dart

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,67 @@ class FlutterActorImage extends ActorImage with FlutterActorDrawable {
10671067
}
10681068
}
10691069

1070+
/// Swap the image used to draw the mesh for this image node.
1071+
/// Returns true when successful.
1072+
bool changeImage(ui.Image image) {
1073+
if (triangles == null || dynamicUV == null) {
1074+
return false;
1075+
}
1076+
_uvBuffer = makeVertexUVBuffer();
1077+
int count = vertexCount;
1078+
1079+
// SKIA requires texture coordinates in full image space, not traditional
1080+
// normalized uv coordinates.
1081+
int idx = 0;
1082+
for (int i = 0; i < count; i++) {
1083+
_uvBuffer[idx] = dynamicUV[idx] * image.width;
1084+
_uvBuffer[idx + 1] = dynamicUV[idx + 1] * image.height;
1085+
idx += 2;
1086+
}
1087+
1088+
_paint.shader = image != null
1089+
? ui.ImageShader(
1090+
image, ui.TileMode.clamp, ui.TileMode.clamp, _identityMatrix)
1091+
: null;
1092+
1093+
_canvasVertices = ui.Vertices.raw(ui.VertexMode.triangles, _vertexBuffer,
1094+
indices: _indices, textureCoordinates: _uvBuffer);
1095+
1096+
onPaintUpdated(_paint);
1097+
1098+
return true;
1099+
}
1100+
1101+
/// Change the image for this node via a network url.
1102+
/// Returns true when successful.
1103+
Future<bool> changeImageFromNetwork(String url) async {
1104+
var networkImage = NetworkImage(url);
1105+
var val = await networkImage.obtainKey(const ImageConfiguration());
1106+
var load = networkImage.load(val, (Uint8List bytes,
1107+
{int cacheWidth, int cacheHeight}) {
1108+
return PaintingBinding.instance.instantiateImageCodec(bytes,
1109+
cacheWidth: cacheWidth, cacheHeight: cacheHeight);
1110+
});
1111+
1112+
final completer = Completer<bool>();
1113+
load.addListener(ImageStreamListener((ImageInfo info, bool syncCall) {
1114+
changeImage(info.image);
1115+
completer.complete(true);
1116+
}));
1117+
return completer.future;
1118+
}
1119+
1120+
/// Change the image for this node with one in an asset bundle.
1121+
/// Returns true when successful.
1122+
Future<bool> changeImageFromBundle(
1123+
AssetBundle bundle, String filename) async {
1124+
ByteData data = await bundle.load(filename);
1125+
ui.Codec codec =
1126+
await ui.instantiateImageCodec(Uint8List.view(data.buffer));
1127+
ui.FrameInfo frame = await codec.getNextFrame();
1128+
return changeImage(frame.image);
1129+
}
1130+
10701131
@override
10711132
void initializeGraphics() {
10721133
super.initializeGraphics();
@@ -1139,7 +1200,6 @@ class FlutterActorImage extends ActorImage with FlutterActorDrawable {
11391200
canvas.save();
11401201

11411202
clip(canvas);
1142-
11431203
_paint.color =
11441204
_paint.color.withOpacity(renderOpacity.clamp(0.0, 1.0).toDouble());
11451205

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.5
3+
version: 1.7.0
44
author: "2Dimensions Team <info@2dimensions.com>"
55
homepage: https://github.com/2d-inc/Flare-Flutter
66
environment:

0 commit comments

Comments
 (0)