Properly close paths (#83)
Fixes #43
diff --git a/LottieSample/screenshots/MotionCorpse-Jrcanest 0.png b/LottieSample/screenshots/MotionCorpse-Jrcanest 0.png
index 4c0adbc..cbc9826 100644
--- a/LottieSample/screenshots/MotionCorpse-Jrcanest 0.png
+++ b/LottieSample/screenshots/MotionCorpse-Jrcanest 0.png
Binary files differ
diff --git a/LottieSample/screenshots/MotionCorpse-Jrcanest 10.png b/LottieSample/screenshots/MotionCorpse-Jrcanest 10.png
index e107efa..1cf749e 100644
--- a/LottieSample/screenshots/MotionCorpse-Jrcanest 10.png
+++ b/LottieSample/screenshots/MotionCorpse-Jrcanest 10.png
Binary files differ
diff --git a/LottieSample/screenshots/MotionCorpse-Jrcanest 100.png b/LottieSample/screenshots/MotionCorpse-Jrcanest 100.png
index e04c6f9..6eb89c5 100644
--- a/LottieSample/screenshots/MotionCorpse-Jrcanest 100.png
+++ b/LottieSample/screenshots/MotionCorpse-Jrcanest 100.png
Binary files differ
diff --git a/LottieSample/screenshots/MotionCorpse-Jrcanest 20.png b/LottieSample/screenshots/MotionCorpse-Jrcanest 20.png
index 5b444e1..fff912a 100644
--- a/LottieSample/screenshots/MotionCorpse-Jrcanest 20.png
+++ b/LottieSample/screenshots/MotionCorpse-Jrcanest 20.png
Binary files differ
diff --git a/LottieSample/screenshots/MotionCorpse-Jrcanest 5.png b/LottieSample/screenshots/MotionCorpse-Jrcanest 5.png
index 36de359..10b7a76 100644
--- a/LottieSample/screenshots/MotionCorpse-Jrcanest 5.png
+++ b/LottieSample/screenshots/MotionCorpse-Jrcanest 5.png
Binary files differ
diff --git a/LottieSample/screenshots/MotionCorpse-Jrcanest 50.png b/LottieSample/screenshots/MotionCorpse-Jrcanest 50.png
index ac2f5c3..f2a7d34 100644
--- a/LottieSample/screenshots/MotionCorpse-Jrcanest 50.png
+++ b/LottieSample/screenshots/MotionCorpse-Jrcanest 50.png
Binary files differ
diff --git a/LottieSample/screenshots/Tests_Hosts 20.png b/LottieSample/screenshots/Tests_Hosts 20.png
index d0d0900..41d1d61 100644
--- a/LottieSample/screenshots/Tests_Hosts 20.png
+++ b/LottieSample/screenshots/Tests_Hosts 20.png
Binary files differ
diff --git a/lottie/src/main/java/com/airbnb/lottie/AnimatableShapeValue.java b/lottie/src/main/java/com/airbnb/lottie/AnimatableShapeValue.java
index 12fae44..4240032 100644
--- a/lottie/src/main/java/com/airbnb/lottie/AnimatableShapeValue.java
+++ b/lottie/src/main/java/com/airbnb/lottie/AnimatableShapeValue.java
@@ -106,6 +106,7 @@
}
shape.addCurve(new CubicCurveData(shapeCp1, shapeCp2, vertex));
+ shape.setClosed(true);
}
return shape;
diff --git a/lottie/src/main/java/com/airbnb/lottie/MiscUtils.java b/lottie/src/main/java/com/airbnb/lottie/MiscUtils.java
index 41c709c..3930c5a 100644
--- a/lottie/src/main/java/com/airbnb/lottie/MiscUtils.java
+++ b/lottie/src/main/java/com/airbnb/lottie/MiscUtils.java
@@ -19,6 +19,9 @@
curveData.getControlPoint2().x, curveData.getControlPoint2().y,
curveData.getVertex().x, curveData.getVertex().y);
}
+ if (shapeData.isClosed()) {
+ outPath.close();
+ }
}
static float lerp(float a, float b, @FloatRange(from = 0f, to = 1f) float percentage) {
diff --git a/lottie/src/main/java/com/airbnb/lottie/ShapeData.java b/lottie/src/main/java/com/airbnb/lottie/ShapeData.java
index 828c09b..e4c00c0 100644
--- a/lottie/src/main/java/com/airbnb/lottie/ShapeData.java
+++ b/lottie/src/main/java/com/airbnb/lottie/ShapeData.java
@@ -9,6 +9,7 @@
class ShapeData {
private final List<CubicCurveData> curves = new ArrayList<>();
private PointF initialPoint;
+ private boolean closed;
void setInitialPoint(PointF initialPoint) {
this.initialPoint = initialPoint;
@@ -29,6 +30,14 @@
curves.add(curve);
}
+ public boolean isClosed() {
+ return closed;
+ }
+
+ public void setClosed(boolean closed) {
+ this.closed = closed;
+ }
+
List<CubicCurveData> getCurves() {
return curves;
}
@@ -38,6 +47,8 @@
if (initialPoint == null) {
initialPoint = new PointF();
}
+ setClosed(shapeData1.isClosed() || shapeData2.isClosed());
+
if (!curves.isEmpty() && curves.size() != shapeData1.getCurves().size()
&& curves.size() != shapeData2.getCurves().size()) {
throw new IllegalStateException("Curves must have the same number of control points. This: "