Skip to content

Commit

Permalink
Properly close paths (#83)
Browse files Browse the repository at this point in the history
Fixes #43
  • Loading branch information
gpeal authored Feb 9, 2017
1 parent df28554 commit 3a4de71
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 0 deletions.
Binary file modified LottieSample/screenshots/MotionCorpse-Jrcanest 0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified LottieSample/screenshots/MotionCorpse-Jrcanest 10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified LottieSample/screenshots/MotionCorpse-Jrcanest 100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified LottieSample/screenshots/MotionCorpse-Jrcanest 20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified LottieSample/screenshots/MotionCorpse-Jrcanest 5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified LottieSample/screenshots/MotionCorpse-Jrcanest 50.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified LottieSample/screenshots/Tests_Hosts 20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class AnimatableShapeValue extends BaseAnimatableValue<ShapeData, Path> {
}

shape.addCurve(new CubicCurveData(shapeCp1, shapeCp2, vertex));
shape.setClosed(true);
}
return shape;

Expand Down
3 changes: 3 additions & 0 deletions lottie/src/main/java/com/airbnb/lottie/MiscUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ static void getPathFromData(ShapeData shapeData, Path outPath) {
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) {
Expand Down
11 changes: 11 additions & 0 deletions lottie/src/main/java/com/airbnb/lottie/ShapeData.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,6 +30,14 @@ void addCurve(CubicCurveData curve) {
curves.add(curve);
}

public boolean isClosed() {
return closed;
}

public void setClosed(boolean closed) {
this.closed = closed;
}

List<CubicCurveData> getCurves() {
return curves;
}
Expand All @@ -38,6 +47,8 @@ void interpolateBetween(ShapeData shapeData1, ShapeData shapeData2,
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: "
Expand Down

0 comments on commit 3a4de71

Please sign in to comment.