Merge remote-tracking branch 'origin/master' into gpeal/stroke-with-offset
diff --git a/lottie/src/main/java/com/airbnb/lottie/animation/content/BaseStrokeContent.java b/lottie/src/main/java/com/airbnb/lottie/animation/content/BaseStrokeContent.java
index f43cc04..e4b96cf 100644
--- a/lottie/src/main/java/com/airbnb/lottie/animation/content/BaseStrokeContent.java
+++ b/lottie/src/main/java/com/airbnb/lottie/animation/content/BaseStrokeContent.java
@@ -219,16 +219,24 @@
for (int j = pathGroup.paths.size() - 1; j >= 0; j--) {
path.addPath(pathGroup.paths.get(j).getPath(), parentMatrix);
}
+ float animStartValue = pathGroup.trimPath.getStart().getValue() / 100f;
+ float animEndValue = pathGroup.trimPath.getEnd().getValue() / 100f;
+ float animOffsetValue = pathGroup.trimPath.getOffset().getValue() / 360f;
+
+ // If the start-end is ~100, consider it to be the full path.
+ if (animStartValue < 0.01f && animEndValue > 0.99f) {
+ canvas.drawPath(path, paint);
+ return;
+ }
+
pm.setPath(path, false);
float totalLength = pm.getLength();
while (pm.nextContour()) {
totalLength += pm.getLength();
}
- float offsetLength = totalLength * pathGroup.trimPath.getOffset().getValue() / 360f;
- float startLength =
- totalLength * (pathGroup.trimPath.getStart().getValue() / 100f) + offsetLength;
- float endLength =
- totalLength * (pathGroup.trimPath.getEnd().getValue() / 100f) + offsetLength;
+ float offsetLength = totalLength * animOffsetValue;
+ float startLength = totalLength * animStartValue + offsetLength;
+ float endLength = Math.min(totalLength * animEndValue + offsetLength, startLength + totalLength - 1f);
float currentLength = 0;
for (int j = pathGroup.paths.size() - 1; j >= 0; j--) {
@@ -244,7 +252,7 @@
if (startLength > totalLength) {
startValue = (startLength - totalLength) / length;
} else {
- startValue = 0;
+ startValue = offsetLength / length;
}
float endValue = Math.min((endLength - totalLength) / length, 1);
Utils.applyTrimPathIfNeeded(trimPathPath, startValue, endValue, 0);
@@ -258,7 +266,7 @@
} else {
float startValue;
if (startLength < currentLength) {
- startValue = 0;
+ startValue = offsetLength / length;
} else {
startValue = (startLength - currentLength) / length;
}
diff --git a/lottie/src/main/java/com/airbnb/lottie/parser/DocumentDataParser.java b/lottie/src/main/java/com/airbnb/lottie/parser/DocumentDataParser.java
index 4d4f1cf..dfbffbd 100644
--- a/lottie/src/main/java/com/airbnb/lottie/parser/DocumentDataParser.java
+++ b/lottie/src/main/java/com/airbnb/lottie/parser/DocumentDataParser.java
@@ -10,17 +10,17 @@
public class DocumentDataParser implements ValueParser<DocumentData> {
public static final DocumentDataParser INSTANCE = new DocumentDataParser();
private static final JsonReader.Options NAMES = JsonReader.Options.of(
- "t",
- "f",
- "s",
- "j",
- "tr",
- "lh",
- "ls",
- "fc",
- "sc",
- "sw",
- "of"
+ "t", // 0
+ "f", // 1
+ "s", // 2
+ "j", // 3
+ "tr", // 4
+ "lh", // 5
+ "ls", // 6
+ "fc", // 7
+ "sc", // 8
+ "sw", // 9
+ "of" // 10
);
private DocumentDataParser() {