Small fixes (#331)

This commit is contained in:
Xavier H
2024-01-11 13:41:39 +01:00
committed by GitHub
parent cad1806f2e
commit 1c665c7756
29 changed files with 845 additions and 222 deletions

View File

@ -10,6 +10,8 @@ This repository is an unofficial conversion of the [Lottie-android](https://gith
It works on Android, iOS, macOS, linux, windows and web.
<a href="https://www.buymeacoffee.com/xvrh" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60" width="217"></a>
## Usage
### Simple animation

View File

@ -10,6 +10,8 @@ This repository is an unofficial conversion of the [Lottie-android](https://gith
It works on Android, iOS, macOS, linux, windows and web.
<a href="https://www.buymeacoffee.com/xvrh" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60" width="217"></a>
## Usage
### Simple animation

View File

@ -0,0 +1,522 @@
{
"v": "4.8.0",
"meta": {
"g": "LottieFiles AE 3.5.2",
"a": "",
"k": "",
"d": "",
"tc": "#000000"
},
"fr": 24,
"ip": 0,
"op": 6912,
"w": 312,
"h": 312,
"nm": "Master_1-4a- GREEN",
"ddd": 0,
"assets": [],
"layers": [
{
"ddd": 0,
"ind": 30,
"ty": 4,
"nm": "Background_Layers",
"sr": 1,
"ks": {
"o": {
"a": 0,
"k": 100,
"ix": 11
},
"r": {
"a": 0,
"k": 0,
"ix": 10
},
"p": {
"a": 0,
"k": [
158,
154,
0
],
"ix": 2
},
"a": {
"a": 0,
"k": [
0,
0,
0
],
"ix": 1
},
"s": {
"a": 0,
"k": [
50,
50,
100
],
"ix": 6
}
},
"ao": 0,
"shapes": [
{
"ty": "gr",
"it": [
{
"ind": 0,
"ty": "sh",
"ix": 1,
"ks": {
"a": 0,
"k": {
"i": [
[
149.841,
0
],
[
0,
-149.841
],
[
-149.841,
0
],
[
0,
149.841
]
],
"o": [
[
-149.841,
0
],
[
0,
149.841
],
[
149.841,
0
],
[
0,
-149.841
]
],
"v": [
[
0,
-271.311
],
[
-271.311,
0
],
[
0,
271.311
],
[
271.311,
0
]
],
"c": true
},
"ix": 2
},
"nm": "Path 1",
"mn": "ADBE Vector Shape - Group",
"hd": false
},
{
"ty": "st",
"c": {
"a": 0,
"k": [
1,
1,
1,
1
],
"ix": 3
},
"o": {
"a": 0,
"k": 100,
"ix": 4
},
"w": {
"a": 0,
"k": 0,
"ix": 5
},
"lc": 1,
"lj": 1,
"ml": 4,
"bm": 0,
"nm": "Stroke 1",
"mn": "ADBE Vector Graphic - Stroke",
"hd": false
},
{
"ty": "gf",
"o": {
"a": 0,
"k": 60,
"ix": 10
},
"r": 1,
"bm": 0,
"g": {
"p": 3,
"k": {
"a": 1,
"k": [
{
"i": {
"x": 0.833,
"y": 0.833
},
"o": {
"x": 0.167,
"y": 0.167
},
"t": 898.499,
"s": [
0.799,
0.988,
0.875,
0.435,
0.9,
0.994,
0.937,
0.718,
1,
1,
1,
1,
0.072,
1,
0.536,
0.5,
1,
0
]
},
{
"i": {
"x": 0.833,
"y": 0.833
},
"o": {
"x": 0.167,
"y": 0.167
},
"t": 1112.312,
"s": [
0.799,
0.988,
0.875,
0.435,
0.9,
0.994,
0.937,
0.718,
1,
1,
1,
1,
0.072,
1,
0.536,
0.5,
1,
0
]
},
{
"i": {
"x": 0.833,
"y": 0.833
},
"o": {
"x": 0.167,
"y": 0.167
},
"t": 1330.13,
"s": [
0.799,
0.828,
0.855,
0.554,
0.9,
0.914,
0.928,
0.777,
1,
1,
1,
1,
0.072,
1,
0.536,
0.5,
1,
0
]
},
{
"i": {
"x": 0.833,
"y": 0.833
},
"o": {
"x": 0.167,
"y": 0.167
},
"t": 1420.621,
"s": [
0.799,
0.761,
0.847,
0.604,
0.9,
0.88,
0.924,
0.802,
1,
1,
1,
1,
0.072,
1,
0.536,
0.5,
1,
0
]
},
{
"i": {
"x": 0.833,
"y": 0.833
},
"o": {
"x": 0.167,
"y": 0.167
},
"t": 4054.455,
"s": [
0.799,
0.761,
0.847,
0.604,
0.9,
0.88,
0.924,
0.802,
1,
1,
1,
1,
0.072,
1,
0.536,
0.5,
1,
0
]
},
{
"i": {
"x": 0.833,
"y": 0.833
},
"o": {
"x": 0.167,
"y": 0.167
},
"t": 4311.512,
"s": [
0.799,
0.675,
0.859,
0.894,
0.9,
0.837,
0.929,
0.947,
1,
1,
1,
1,
0.072,
1,
0.536,
0.5,
1,
0
]
},
{
"i": {
"x": 0.833,
"y": 0.833
},
"o": {
"x": 0.167,
"y": 0.167
},
"t": 6439.239,
"s": [
0.799,
0.675,
0.859,
0.894,
0.9,
0.837,
0.929,
0.947,
1,
1,
1,
1,
0.072,
1,
0.536,
0.5,
1,
0
]
},
{
"t": 6672.2724609375,
"s": [
0.799,
0.71,
0.098,
0.392,
0.9,
0.855,
0.549,
0.696,
1,
1,
1,
1,
0.072,
1,
0.536,
0.5,
1,
0
]
}
],
"ix": 9
}
},
"s": {
"a": 0,
"k": [
0.798,
1.032
],
"ix": 5
},
"e": {
"a": 0,
"k": [
244.484,
0
],
"ix": 6
},
"t": 2,
"h": {
"a": 0,
"k": 0,
"ix": 7
},
"a": {
"a": 0,
"k": 0,
"ix": 8
},
"nm": "Gradient Fill 1",
"mn": "ADBE Vector Graphic - G-Fill",
"hd": false
},
{
"ty": "tr",
"p": {
"a": 0,
"k": [
-4.865,
2.221
],
"ix": 2
},
"a": {
"a": 0,
"k": [
0,
0
],
"ix": 1
},
"s": {
"a": 0,
"k": [
108.71,
108.71
],
"ix": 3
},
"r": {
"a": 0,
"k": 0,
"ix": 6
},
"o": {
"a": 0,
"k": 100,
"ix": 7
},
"sk": {
"a": 0,
"k": 0,
"ix": 4
},
"sa": {
"a": 0,
"k": 0,
"ix": 5
},
"nm": "Transformieren"
}
],
"nm": "Ellipse 1",
"np": 3,
"cix": 2,
"bm": 0,
"ix": 1,
"mn": "ADBE Vector Group",
"hd": false
}
],
"ip": -8.80880880880881,
"op": 7462.66266266266,
"st": -8.80880880880881,
"bm": 0
}
],
"markers": []
}

View File

@ -0,0 +1,222 @@
{
"v": "5.9.1",
"fr": 25,
"ip": 0,
"op": 75,
"w": 1200,
"h": 1200,
"nm": "square",
"ddd": 0,
"assets": [],
"layers": [
{
"ddd": 0,
"ind": 15,
"ty": 4,
"nm": "Fond Silhouettes",
"sr": 1,
"ks": {
"o": {
"a": 0,
"k": 100,
"ix": 11
},
"r": {
"a": 0,
"k": 0,
"ix": 10
},
"p": {
"a": 0,
"k": [
600,
600,
0
],
"ix": 2,
"l": 2
},
"a": {
"a": 0,
"k": [
600,
600,
0
],
"ix": 1,
"l": 2
},
"s": {
"a": 0,
"k": [
100,
100,
100
],
"ix": 6,
"l": 2
}
},
"ao": 0,
"shapes": [
{
"ty": "gr",
"it": [
{
"ind": 0,
"ty": "sh",
"ix": 1,
"ks": {
"a": 0,
"k": {
"i": [
[
0,
0
],
[
0,
0
],
[
0,
0
],
[
0,
0
]
],
"o": [
[
0,
0
],
[
0,
0
],
[
0,
0
],
[
0,
0
]
],
"v": [
[
-600,
600
],
[
600,
600
],
[
600,
-600
],
[
-600,
-600
]
],
"c": true
},
"ix": 2
},
"nm": "Tracé 1",
"mn": "ADBE Vector Shape - Group",
"hd": false
},
{
"ty": "fl",
"c": {
"a": 0,
"k": [
0.561497886508,
0.699996708889,
0.56712066052,
1
],
"ix": 4
},
"o": {
"a": 0,
"k": 100,
"ix": 5
},
"r": 1,
"bm": 0,
"nm": "Fond 1",
"mn": "ADBE Vector Graphic - Fill",
"hd": false
},
{
"ty": "tr",
"p": {
"a": 0,
"k": [
600,
600
],
"ix": 2
},
"a": {
"a": 0,
"k": [
0,
0
],
"ix": 1
},
"s": {
"a": 0,
"k": [
100,
100
],
"ix": 3
},
"r": {
"a": 0,
"k": 0,
"ix": 6
},
"o": {
"a": 0,
"k": 100,
"ix": 7
},
"sk": {
"a": 0,
"k": 0,
"ix": 4
},
"sa": {
"a": 0,
"k": 0,
"ix": 5
},
"nm": "Transformer "
}
],
"nm": "Groupe 1",
"np": 2,
"cix": 2,
"bm": 0,
"ix": 1,
"mn": "ADBE Vector Group",
"hd": false
}
],
"ip": 0,
"op": 76,
"st": 0,
"bm": 0
}
],
"markers": []
}

File diff suppressed because one or more lines are too long

View File

@ -5,10 +5,10 @@ packages:
dependency: transitive
description:
name: archive
sha256: "7b875fd4a20b165a3084bd2d210439b22ebc653f21cea4842729c0c30c82596b"
sha256: "22600aa1e926be775fa5fe7e6894e7fb3df9efda8891c73f70fb3262399a432d"
url: "https://pub.dev"
source: hosted
version: "3.4.9"
version: "3.4.10"
async:
dependency: transitive
description:
@ -161,7 +161,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.0.0-alpha.4"
version: "3.0.0"
matcher:
dependency: transitive
description:
@ -198,18 +198,18 @@ packages:
dependency: "direct main"
description:
name: path_provider
sha256: a1aa8aaa2542a6bc57e381f132af822420216c80d4781f7aa085ca3229208aaa
sha256: b27217933eeeba8ff24845c34003b003b2b22151de3c908d0e679e8fe1aa078b
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.1.2"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
sha256: e595b98692943b4881b219f0a9e3945118d3c16bd7e2813f98ec6e532d905f72
sha256: "477184d672607c0a3bf68fbbf601805f92ef79c82b64b4d6eb318cbca4c48668"
url: "https://pub.dev"
source: hosted
version: "2.2.1"
version: "2.2.2"
path_provider_foundation:
dependency: transitive
description:
@ -230,10 +230,10 @@ packages:
dependency: transitive
description:
name: path_provider_platform_interface
sha256: "94b1e0dd80970c1ce43d5d4e050a9918fce4f4a775e6142424c30a29a363265c"
sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.1.2"
path_provider_windows:
dependency: transitive
description:
@ -246,18 +246,18 @@ packages:
dependency: transitive
description:
name: platform
sha256: "0a279f0707af40c890e80b1e9df8bb761694c074ba7e1d4ab1bc4b728e200b59"
sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
url: "https://pub.dev"
source: hosted
version: "3.1.3"
version: "3.1.4"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
sha256: f4f88d4a900933e7267e2b353594774fc0d07fb072b47eedcd5b54e1ea3269f8
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
url: "https://pub.dev"
source: hosted
version: "2.1.7"
version: "2.1.8"
pointycastle:
dependency: transitive
description:
@ -347,18 +347,18 @@ packages:
dependency: transitive
description:
name: win32
sha256: b0f37db61ba2f2e9b7a78a1caece0052564d1bc70668156cf3a29d676fe4e574
sha256: "464f5674532865248444b4c3daca12bd9bf2d7c47f759ce2617986e7229494a8"
url: "https://pub.dev"
source: hosted
version: "5.1.1"
version: "5.2.0"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
sha256: "589ada45ba9e39405c198fe34eb0f607cddb2108527e658136120892beac46d2"
sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d
url: "https://pub.dev"
source: hosted
version: "1.0.3"
version: "1.0.4"
sdks:
dart: ">=3.2.0 <4.0.0"
flutter: ">=3.16.0"

View File

@ -14,7 +14,6 @@ import '../../model/layer/base_layer.dart';
import '../../utils.dart';
import '../../utils/dash_path.dart';
import '../../utils/misc.dart';
import '../../utils/path_factory.dart';
import '../../utils/utils.dart';
import '../../value/drop_shadow.dart';
import '../../value/lottie_value_callback.dart';
@ -29,8 +28,8 @@ import 'trim_path_content.dart';
abstract class BaseStrokeContent
implements KeyPathElementContent, DrawingContent {
final Path _path = PathFactory.create();
final Path _trimPathPath = PathFactory.create();
final Path _path = Path();
final Path _trimPathPath = Path();
final LottieDrawable lottieDrawable;
final BaseLayer layer;
final List<_PathGroup> _pathGroups = <_PathGroup>[];

View File

@ -8,7 +8,6 @@ import '../../model/key_path.dart';
import '../../model/key_path_element.dart';
import '../../model/layer/base_layer.dart';
import '../../utils.dart';
import '../../utils/path_factory.dart';
import '../../value/lottie_value_callback.dart';
import '../keyframe/transform_keyframe_animation.dart';
import 'content.dart';
@ -42,7 +41,7 @@ class ContentGroup implements DrawingContent, PathContent, KeyPathElement {
}
final Matrix4 _matrix = Matrix4.identity();
final Path _path = PathFactory.create();
final Path _path = Path();
@override
final String? name;

View File

@ -7,7 +7,6 @@ import '../../model/key_path.dart';
import '../../model/layer/base_layer.dart';
import '../../utils.dart';
import '../../utils/misc.dart';
import '../../utils/path_factory.dart';
import '../../value/lottie_value_callback.dart';
import '../keyframe/base_keyframe_animation.dart';
import 'compound_trim_path_content.dart';
@ -19,7 +18,7 @@ import 'trim_path_content.dart';
class EllipseContent implements PathContent, KeyPathElementContent {
static const _ellipseControlPointPercentage = 0.55228;
final Path _path = PathFactory.create();
final Path _path = Path();
@override
final String? name;

View File

@ -9,7 +9,6 @@ import '../../model/key_path.dart';
import '../../model/layer/base_layer.dart';
import '../../utils.dart';
import '../../utils/misc.dart';
import '../../utils/path_factory.dart';
import '../../value/drop_shadow.dart';
import '../../value/lottie_value_callback.dart';
import '../keyframe/base_keyframe_animation.dart';
@ -21,7 +20,7 @@ import 'key_path_element_content.dart';
import 'path_content.dart';
class FillContent implements DrawingContent, KeyPathElementContent {
final Path _path = PathFactory.create();
final Path _path = Path();
final BaseLayer layer;
@override
final String? name;

View File

@ -11,7 +11,6 @@ import '../../model/key_path.dart';
import '../../model/layer/base_layer.dart';
import '../../utils.dart';
import '../../utils/misc.dart';
import '../../utils/path_factory.dart';
import '../../value/drop_shadow.dart';
import '../../value/lottie_value_callback.dart';
import '../keyframe/base_keyframe_animation.dart';
@ -29,7 +28,7 @@ class GradientFillContent implements DrawingContent, KeyPathElementContent {
final GradientFill _fill;
final _linearGradientCache = <int, Gradient>{};
final _radialGradientCache = <int, Gradient>{};
final _path = PathFactory.create();
final _path = Path();
final _paint = Paint();
final _paths = <PathContent>[];
final BaseKeyframeAnimation<GradientColor, GradientColor> _colorAnimation;

View File

@ -1,16 +1,15 @@
import 'dart:ui';
import '../../model/content/merge_paths.dart';
import '../../utils.dart';
import '../../utils/path_factory.dart';
import 'content.dart';
import 'content_group.dart';
import 'greedy_content.dart';
import 'path_content.dart';
class MergePathsContent implements PathContent, GreedyContent {
final Path _firstPath = PathFactory.create();
final Path _remainderPath = PathFactory.create();
final Path _path = PathFactory.create();
final Path _firstPath = Path();
final Path _remainderPath = Path();
final Path _path = Path();
final List<PathContent> _pathContents = <PathContent>[];
final MergePaths _mergePaths;

View File

@ -8,7 +8,6 @@ import '../../model/content/shape_trim_path.dart';
import '../../model/key_path.dart';
import '../../model/layer/base_layer.dart';
import '../../utils/misc.dart';
import '../../utils/path_factory.dart';
import '../../value/lottie_value_callback.dart';
import '../keyframe/base_keyframe_animation.dart';
import 'compound_trim_path_content.dart';
@ -24,7 +23,7 @@ class PolystarContent implements PathContent, KeyPathElementContent {
/// work otherwise.
static const _polystarMagicNumber = .47829;
static const _polygonMagicNumber = .25;
final _path = PathFactory.create();
final _path = Path();
final LottieDrawable lottieDrawable;
final PolystarShape _polystarShape;

View File

@ -8,7 +8,6 @@ import '../../model/content/shape_trim_path.dart';
import '../../model/key_path.dart';
import '../../model/layer/base_layer.dart';
import '../../utils/misc.dart';
import '../../utils/path_factory.dart';
import '../../value/lottie_value_callback.dart';
import '../keyframe/base_keyframe_animation.dart';
import 'compound_trim_path_content.dart';
@ -19,7 +18,7 @@ import 'rounded_corners_content.dart';
import 'trim_path_content.dart';
class RectangleContent implements KeyPathElementContent, PathContent {
final _path = PathFactory.create();
final _path = Path();
@override
final String? name;

View File

@ -7,7 +7,6 @@ import '../../model/key_path.dart';
import '../../model/layer/base_layer.dart';
import '../../utils.dart';
import '../../utils/misc.dart';
import '../../utils/path_factory.dart';
import '../../value/lottie_value_callback.dart';
import '../keyframe/base_keyframe_animation.dart';
import '../keyframe/transform_keyframe_animation.dart';
@ -25,7 +24,7 @@ class RepeaterContent
GreedyContent,
KeyPathElementContent {
final Matrix4 _matrix = Matrix4.identity();
final _path = PathFactory.create();
final _path = Path();
final LottieDrawable lottieDrawable;
final BaseLayer layer;

View File

@ -4,7 +4,6 @@ import '../../model/content/shape_path.dart';
import '../../model/content/shape_trim_path.dart';
import '../../model/layer/base_layer.dart';
import '../../utils.dart';
import '../../utils/path_factory.dart';
import '../keyframe/shape_keyframe_animation.dart';
import 'compound_trim_path_content.dart';
import 'content.dart';
@ -13,7 +12,7 @@ import 'shape_modifier_content.dart';
import 'trim_path_content.dart';
class ShapeContent implements PathContent {
final _path = PathFactory.create();
final _path = Path();
final ShapePath _shape;

View File

@ -1,14 +1,13 @@
import 'dart:ui';
import '../../model/content/shape_data.dart';
import '../../utils/misc.dart';
import '../../utils/path_factory.dart';
import '../../value/keyframe.dart';
import '../content/shape_modifier_content.dart';
import 'base_keyframe_animation.dart';
class ShapeKeyframeAnimation extends BaseKeyframeAnimation<ShapeData, Path> {
final ShapeData _tempShapeData = ShapeData.empty();
final Path _tempPath = PathFactory.create();
final Path _tempPath = Path();
List<ShapeModifierContent>? _shapeModifiers;
ShapeKeyframeAnimation(super.keyframes);
@ -16,7 +15,7 @@ class ShapeKeyframeAnimation extends BaseKeyframeAnimation<ShapeData, Path> {
@override
Path getValue(Keyframe<ShapeData> keyframe, double keyframeProgress) {
var startShapeData = keyframe.startValue!;
var endShapeData = keyframe.endValue!;
var endShapeData = keyframe.endValue ?? startShapeData;
_tempShapeData.interpolateBetween(
startShapeData, endShapeData, keyframeProgress);

View File

@ -1,16 +1,32 @@
import 'dart:ui';
import '../../utils.dart';
import '../../utils/collection.dart';
import '../../utils/gamma_evaluator.dart';
// ignore_for_file: avoid_equals_and_hash_code_on_mutable_classes
class GradientColor {
final List<double> positions;
final List<Color> colors;
GradientColor(this.positions, this.colors);
const GradientColor(this.positions, this.colors);
int get size => colors.length;
void lerp(GradientColor gc1, GradientColor gc2, double progress) {
// Fast return in case start and end is the same
// or if progress is at start/end or out of [0,1] bounds
if (gc1 == gc2) {
_copyFrom(gc1);
return;
} else if (progress <= 0) {
_copyFrom(gc1);
return;
} else if (progress >= 1) {
_copyFrom(gc2);
return;
}
if (gc1.colors.length != gc2.colors.length) {
throw Exception('Cannot interpolate between gradients. '
'Lengths vary (${gc1.colors.length} vs ${gc2.colors.length})');
@ -59,4 +75,30 @@ class GradientColor {
var fraction = (position - startPosition) / (endPosition - startPosition);
return GammaEvaluator.evaluate(fraction, startColor, endColor);
}
@override
bool operator ==(Object other) {
if (identical(this, other)) {
return true;
}
if (other is! GradientColor) {
return false;
}
return const ListEquality<double>().equals(positions, other.positions) &&
const ListEquality<Color>().equals(colors, other.colors);
}
@override
int get hashCode {
var result = Object.hashAll(positions);
result = 31 * result + Object.hashAll(colors);
return result;
}
void _copyFrom(GradientColor other) {
for (var i = 0; i < other.colors.length; i++) {
positions[i] = other.positions[i];
colors[i] = other.colors[i];
}
}
}

View File

@ -5,14 +5,13 @@ import '../../animation/keyframe/value_callback_keyframe_animation.dart';
import '../../lottie_drawable.dart';
import '../../lottie_property.dart';
import '../../utils.dart';
import '../../utils/path_factory.dart';
import '../../value/lottie_value_callback.dart';
import 'base_layer.dart';
import 'layer.dart';
class SolidLayer extends BaseLayer {
final Paint paint = Paint()..style = PaintingStyle.fill;
final Path path = PathFactory.create();
final Path path = Path();
BaseKeyframeAnimation<ColorFilter, ColorFilter?>? _colorFilterAnimation;
BaseKeyframeAnimation<Color, Color?>? _colorAnimation;
@ -29,6 +28,8 @@ class SolidLayer extends BaseLayer {
return;
}
paint.color = _colorAnimation?.value ?? layerModel.solidColor;
var opacity = transform.opacity?.value ?? 100;
var alpha = (parentAlpha /
255.0 *
@ -36,9 +37,7 @@ class SolidLayer extends BaseLayer {
255.0)
.round();
paint.setAlpha(alpha);
if (_colorAnimation?.value case var color?) {
paint.color = color;
}
if (_colorFilterAnimation != null) {
paint.colorFilter = _colorFilterAnimation!.value;
}

View File

@ -1,6 +1,5 @@
import 'dart:math';
import 'dart:ui';
import 'path_factory.dart';
Path dashPath(
Path source, {
@ -10,7 +9,7 @@ Path dashPath(
assert(intervals.length >= 2);
phase ??= 0;
var dest = PathFactory.create();
var dest = Path();
for (final metric in source.computeMetrics()) {
for (var dash in _dashes(metric.length, intervals, phase)) {
dest.addPath(metric.extractPath(dash.left, dash.right), Offset.zero);

View File

@ -26,9 +26,16 @@ class GammaEvaluator {
}
static Color evaluate(double fraction, Color startColor, Color endColor) {
// Fast return in case start and end is the same
// or if fraction is at start/end or out of [0,1] bounds
if (startColor == endColor) {
return startColor;
} else if (fraction <= 0) {
return startColor;
} else if (fraction >= 1) {
return endColor;
}
var startA = startColor.alpha / 255.0;
var startR = startColor.red / 255.0;
var startG = startColor.green / 255.0;

View File

@ -1,164 +0,0 @@
import 'dart:typed_data';
import 'dart:ui';
class PathFactory {
static Path create() {
return Path();
}
}
class FakePath implements Path {
@override
PathFillType fillType = PathFillType.nonZero;
@override
void addArc(Rect oval, double startAngle, double sweepAngle) {
// TODO: implement addArc
}
@override
void addOval(Rect oval) {
// TODO: implement addOval
}
@override
void addPath(Path path, Offset offset, {Float64List? matrix4}) {
// TODO: implement addPath
}
@override
void addPolygon(List<Offset> points, bool close) {
// TODO: implement addPolygon
}
@override
void addRRect(RRect rrect) {
// TODO: implement addRRect
}
@override
void addRect(Rect rect) {
// TODO: implement addRect
}
@override
void arcTo(
Rect rect, double startAngle, double sweepAngle, bool forceMoveTo) {
// TODO: implement arcTo
}
@override
void arcToPoint(Offset arcEnd,
{Radius radius = Radius.zero,
double rotation = 0.0,
bool largeArc = false,
bool clockwise = true}) {
// TODO: implement arcToPoint
}
@override
void close() {
// TODO: implement close
}
@override
PathMetrics computeMetrics({bool forceClosed = false}) {
// TODO: implement computeMetrics
throw UnimplementedError();
}
@override
void conicTo(double x1, double y1, double x2, double y2, double w) {
// TODO: implement conicTo
}
@override
bool contains(Offset point) {
// TODO: implement contains
throw UnimplementedError();
}
@override
void cubicTo(
double x1, double y1, double x2, double y2, double x3, double y3) {
// TODO: implement cubicTo
}
@override
void extendWithPath(Path path, Offset offset, {Float64List? matrix4}) {
// TODO: implement extendWithPath
}
@override
Rect getBounds() {
// TODO: implement getBounds
throw UnimplementedError();
}
@override
void lineTo(double x, double y) {
// TODO: implement lineTo
}
@override
void moveTo(double x, double y) {
// TODO: implement moveTo
}
@override
void quadraticBezierTo(double x1, double y1, double x2, double y2) {
// TODO: implement quadraticBezierTo
}
@override
void relativeArcToPoint(Offset arcEndDelta,
{Radius radius = Radius.zero,
double rotation = 0.0,
bool largeArc = false,
bool clockwise = true}) {
// TODO: implement relativeArcToPoint
}
@override
void relativeConicTo(double x1, double y1, double x2, double y2, double w) {
// TODO: implement relativeConicTo
}
@override
void relativeCubicTo(
double x1, double y1, double x2, double y2, double x3, double y3) {
// TODO: implement relativeCubicTo
}
@override
void relativeLineTo(double dx, double dy) {
// TODO: implement relativeLineTo
}
@override
void relativeMoveTo(double dx, double dy) {
// TODO: implement relativeMoveTo
}
@override
void relativeQuadraticBezierTo(double x1, double y1, double x2, double y2) {
// TODO: implement relativeQuadraticBezierTo
}
@override
void reset() {
// TODO: implement reset
}
@override
Path shift(Offset offset) {
// TODO: implement shift
throw UnimplementedError();
}
@override
Path transform(Float64List matrix4) {
// TODO: implement transform
throw UnimplementedError();
}
}

View File

@ -1,5 +1,5 @@
import 'dart:ui';
import 'package:flutter/animation.dart';
import 'path_factory.dart';
// ignore: must_be_immutable
class PathInterpolator extends Curve {
@ -24,7 +24,7 @@ class PathInterpolator extends Curve {
}
void _initialize() {
final path = PathFactory.create();
final path = Path();
path.moveTo(0.0, 0.0);
path.cubicTo(controlX1, controlY1, controlX2, controlY2, 1.0, 1.0);

View File

@ -4,12 +4,11 @@ import '../animation/content/trim_path_content.dart';
import '../l.dart';
import '../utils.dart';
import 'misc.dart';
import 'path_factory.dart';
class Utils {
static Path createPath(
Offset startPoint, Offset endPoint, Offset? cp1, Offset? cp2) {
var path = PathFactory.create();
var path = Path();
path.moveTo(startPoint.dx, startPoint.dy);
if (cp1 != null &&

View File

@ -21,10 +21,10 @@ packages:
dependency: "direct main"
description:
name: archive
sha256: "7b875fd4a20b165a3084bd2d210439b22ebc653f21cea4842729c0c30c82596b"
sha256: "22600aa1e926be775fa5fe7e6894e7fb3df9efda8891c73f70fb3262399a432d"
url: "https://pub.dev"
source: hosted
version: "3.4.9"
version: "3.4.10"
args:
dependency: transitive
description:

View File

@ -1,8 +1,11 @@
name: lottie
description: Render After Effects animations natively on Flutter. This package is a pure Dart implementation of a Lottie player.
version: 3.0.0-alpha.4
version: 3.0.0
repository: https://github.com/xvrh/lottie-flutter
funding:
- https://www.buymeacoffee.com/xvrh
environment:
sdk: '^3.2.0'
flutter: '>=3.16.0'

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB