Skip to content

Commit

Permalink
Initial precomp support
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Peal committed Feb 17, 2017
1 parent a0925b0 commit ee7e638
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 9 deletions.
Binary file added LottieSample/screenshots/Tests_Laugh4 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 added LottieSample/screenshots/Tests_Laugh4 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 added LottieSample/screenshots/Tests_Laugh4 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 added LottieSample/screenshots/Tests_Laugh4 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 added LottieSample/screenshots/Tests_Laugh4 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 added LottieSample/screenshots/Tests_Laugh4 50.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 @@ -35,6 +35,7 @@ public void testAll() {
TestRobot.testAnimation(getActivity(), "Tests/EllipseTrimPath.json");
TestRobot.testAnimation(getActivity(), "Tests/SplitDimensions.json");
TestRobot.testAnimation(getActivity(), "Tests/TrimPathsFull.json");
TestRobot.testAnimation(getActivity(), "Tests/Laugh4.json");
TestRobot.testStatic(getActivity(), "Tests/TrimPathFill.json");
}
}
1 change: 1 addition & 0 deletions LottieSample/src/main/assets/Precomps_14.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"assets":[{"id":"comp_20","layers":[{"ddd":0,"ind":0,"ty":4,"nm":"Shape Layer 1","ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":0,"s":[142,250,0],"e":[356,250,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":26,"s":[356,250,0],"e":[142,250,0],"to":[0,0,0],"ti":[0,0,0]},{"t":59}]},"a":{"k":[0,0,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"k":[210.141,210.141]},"p":{"k":[0,0]},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse"},{"ty":"st","c":{"k":[0,0,0,1]},"o":{"k":100},"w":{"k":20},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke"},{"ty":"fl","c":{"k":[1,0,0,1]},"o":{"k":100},"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"k":[-2,-4],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"mn":"ADBE Vector Group"}],"ip":0,"op":60,"st":0,"bm":0,"sr":1}]}],"layers":[{"ddd":0,"ind":0,"ty":0,"nm":"circleprecomp 2","refId":"comp_20","ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[250,397,0]},"a":{"k":[250,250,0]},"s":{"k":[100,100,100]}},"ao":0,"w":500,"h":500,"ip":10,"op":70,"st":10,"bm":0,"sr":1},{"ddd":0,"ind":1,"ty":0,"nm":"circleprecomp 2","refId":"comp_20","ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[250,266,0]},"a":{"k":[250,250,0]},"s":{"k":[100,100,100]}},"ao":0,"w":500,"h":500,"ip":5,"op":65,"st":5,"bm":0,"sr":1},{"ddd":0,"ind":2,"ty":0,"nm":"circleprecomp 2","refId":"comp_20","ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[250,123,0]},"a":{"k":[250,250,0]},"s":{"k":[100,100,100]}},"ao":0,"w":500,"h":500,"ip":0,"op":60,"st":0,"bm":0,"sr":1}],"v":"4.5.4","ddd":0,"ip":0,"op":60,"fr":30,"w":500,"h":500}
1 change: 1 addition & 0 deletions LottieSample/src/main/assets/Tests/Laugh4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"assets":[{"id":"comp_9","layers":[{"ddd":0,"ind":0,"ty":0,"nm":"Laugh_02","refId":"comp_10","ks":{"o":{"k":100},"r":{"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":0,"s":[0],"e":[360]},{"t":73}]},"p":{"k":[100,100,0]},"a":{"k":[100,100,0]},"s":{"k":[100,100,100]}},"ao":0,"w":200,"h":200,"ip":0,"op":74,"st":0,"bm":0,"sr":1}]},{"id":"comp_10","layers":[{"ddd":0,"ind":0,"ty":0,"nm":"Laugh_01","refId":"comp_11","ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"n":"0p667_1_0p333_0","t":0,"s":[142,127,0],"e":[142,69,0],"to":[0,-9.66666698455811,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"n":"0p667_1_0p333_0","t":32,"s":[142,69,0],"e":[142,127,0],"to":[0,0,0],"ti":[0,-9.66666698455811,0]},{"t":73}]},"a":{"k":[10,10,0]},"s":{"k":[139,139,100]}},"ao":0,"w":20,"h":20,"ip":0,"op":74,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":1,"ty":0,"nm":"Laugh_01","refId":"comp_11","ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"n":"0p667_1_0p333_0","t":0,"s":[61,127,0],"e":[61,69,0],"to":[0,-9.66666698455811,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"n":"0p667_1_0p333_0","t":32,"s":[61,69,0],"e":[61,127,0],"to":[0,0,0],"ti":[0,-9.66666698455811,0]},{"t":73}]},"a":{"k":[10,10,0]},"s":{"k":[139,139,100]}},"ao":0,"w":20,"h":20,"ip":0,"op":74,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":2,"ty":0,"nm":"Laugh_01","refId":"comp_11","ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"n":"0p667_1_0p333_0","t":0,"s":[100,127,0],"e":[100,69,0],"to":[0,-9.66666698455811,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"n":"0p667_1_0p333_0","t":32,"s":[100,69,0],"e":[100,127,0],"to":[0,0,0],"ti":[0,-9.66666698455811,0]},{"t":73}]},"a":{"k":[10,10,0]},"s":{"k":[139,139,100]}},"ao":0,"w":20,"h":20,"ip":0,"op":74,"st":0,"bm":0,"sr":1}]},{"id":"comp_11","layers":[{"ddd":0,"ind":0,"ty":4,"nm":"Left Eye Closed","parent":10,"ks":{"o":{"k":[{"t":0,"s":[0],"h":1},{"t":11,"s":[100],"h":1},{"t":15,"s":[0],"h":1}]},"r":{"k":0},"p":{"k":[60.625,62.5,0]},"a":{"k":[0,0,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[10.725,-11.55],[18.975,-11.55]],"c":false}},"nm":"Path 1","mn":"ADBE Vector Shape - Group"},{"ty":"st","fillEnabled":true,"c":{"k":[0.34,0.35,0.36,1]},"o":{"k":100},"w":{"k":4},"lc":2,"lj":2,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke"},{"ty":"tr","p":{"k":[0,0],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1","np":2,"mn":"ADBE Vector Group"}],"ip":0,"op":23,"st":-7,"bm":0,"sr":1},{"ddd":0,"ind":1,"ty":4,"nm":"Right Eye Closed","parent":10,"ks":{"o":{"k":[{"t":0,"s":[0],"h":1},{"t":11,"s":[100],"h":1},{"t":15,"s":[0],"h":1}]},"r":{"k":0},"p":{"k":[60.625,62.5,0]},"a":{"k":[0,0,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-20.275,-11.375],[-12.025,-11.375]],"c":false}},"nm":"Path 1","mn":"ADBE Vector Shape - Group"},{"ty":"st","fillEnabled":true,"c":{"k":[0.34,0.35,0.36,1]},"o":{"k":100},"w":{"k":4},"lc":2,"lj":2,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke"},{"ty":"tr","p":{"k":[0,0],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1","np":2,"mn":"ADBE Vector Group"}],"ip":0,"op":23,"st":-7,"bm":0,"sr":1},{"ddd":0,"ind":2,"ty":4,"nm":"Left Eye","parent":10,"ks":{"o":{"k":[{"t":0,"s":[100],"h":1},{"t":11,"s":[0],"h":1},{"t":15,"s":[100],"h":1}]},"r":{"k":0},"p":{"k":[58.375,57.5,0]},"a":{"k":[44,42,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[-2.857,0],[0,2.812],[2.857,0],[0,-2.812]],"o":[[2.857,0],[0,-2.812],[-2.857,0],[0,2.812]],"v":[[134.14,553.727],[139.312,548.636],[134.14,543.545],[128.968,548.636]],"c":true}},"nm":"Path 1","mn":"ADBE Vector Shape - Group"},{"ty":"fl","fillEnabled":true,"c":{"k":[0.34,0.35,0.36,1]},"o":{"k":100},"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"k":[-73,-513],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 2","np":2,"mn":"ADBE Vector Group"}],"ip":0,"op":23,"st":-7,"bm":0,"sr":1},{"ddd":0,"ind":3,"ty":4,"nm":"Right Eye","parent":10,"ks":{"o":{"k":[{"t":0,"s":[100],"h":1},{"t":11,"s":[0],"h":1},{"t":15,"s":[100],"h":1}]},"r":{"k":0},"p":{"k":[58.375,57.5,0]},"a":{"k":[44,42,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[-2.857,0],[0,2.812],[2.857,0],[0,-2.812]],"o":[[2.857,0],[0,-2.812],[-2.857,0],[0,2.812]],"v":[[103.107,553.727],[108.279,548.636],[103.107,543.545],[97.935,548.636]],"c":true}},"nm":"Path 1","mn":"ADBE Vector Shape - Group"},{"ty":"fl","fillEnabled":true,"c":{"k":[0.34,0.35,0.36,1]},"o":{"k":100},"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"k":[-73,-513],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 3","np":2,"mn":"ADBE Vector Group"}],"ip":0,"op":23,"st":-7,"bm":0,"sr":1},{"ddd":0,"ind":4,"ty":4,"nm":"Left Eye Closed","parent":10,"ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[61.625,62.5,0]},"a":{"k":[43,42,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0]],"v":[[3.879,-5.091],[-3.879,0.129],[3.879,5.091]],"c":false}},"nm":"Path 1","mn":"ADBE Vector Shape - Group"},{"ty":"st","fillEnabled":true,"c":{"k":[0.34,0.35,0.36,1]},"o":{"k":100},"w":{"k":3},"lc":2,"lj":2,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke"},{"ty":"tr","p":{"k":[55.601,30.545],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"mn":"ADBE Vector Group"}],"ip":23,"op":143,"st":23,"bm":0,"sr":1},{"ddd":0,"ind":5,"ty":4,"nm":"Right Eye Closed","parent":10,"ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[59.625,62.5,0]},"a":{"k":[43,42,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0]],"v":[[-3.879,-5.091],[3.879,0.129],[-3.879,5.091]],"c":false}},"nm":"Path 1","mn":"ADBE Vector Shape - Group"},{"ty":"st","fillEnabled":true,"c":{"k":[0.34,0.35,0.36,1]},"o":{"k":100},"w":{"k":3},"lc":2,"lj":2,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke"},{"ty":"tr","p":{"k":[29.74,30.545],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 2","np":2,"mn":"ADBE Vector Group"}],"ip":23,"op":143,"st":23,"bm":0,"sr":1},{"ddd":0,"ind":6,"ty":4,"nm":"MouthMatte","parent":10,"td":1,"ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[60.625,62.5,0]},"a":{"k":[43,42,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[0,0],[0.559,-2.467],[10.659,0],[2.23,9.83],[-2.568,0]],"o":[[2.567,0],[-2.231,9.83],[-10.659,0],[-0.56,-2.467],[0,0]],"v":[[191.52,205.036],[195.416,209.852],[173.611,227.028],[151.805,209.852],[155.701,205.036]],"c":true}},"nm":"Path 4","mn":"ADBE Vector Shape - Group"},{"ty":"fl","fillEnabled":true,"c":{"k":[0.34,0.35,0.36,1]},"o":{"k":100},"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"k":[-131,-161],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 4","np":2,"mn":"ADBE Vector Group"}],"ip":0,"op":143,"st":-7,"bm":0,"sr":1},{"ddd":0,"ind":7,"ty":4,"nm":"Tongue","parent":8,"tt":1,"ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[60.625,62.5,0]},"a":{"k":[43,42,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[0,-11.195],[11.374,0],[0,11.195],[-11.374,0]],"o":[[0,11.195],[-11.374,0],[0,-11.195],[11.374,0]],"v":[[194.205,236.082],[173.611,256.353],[153.017,236.082],[173.611,215.812]],"c":true}},"nm":"Path 4","mn":"ADBE Vector Shape - Group"},{"ty":"fl","fillEnabled":true,"c":{"k":[1,0.96,0.9,1]},"o":{"k":100},"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"k":[-131,-161],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 3","np":2,"mn":"ADBE Vector Group"}],"ip":0,"op":143,"st":-7,"bm":0,"sr":1},{"ddd":0,"ind":8,"ty":3,"nm":"TONGUE_C","parent":12,"ks":{"o":{"k":0},"r":{"k":0},"p":{"k":[{"i":{"x":0.61,"y":1},"o":{"x":1,"y":0},"n":"0p61_1_1_0","t":18,"s":[49.375,47.5,0],"e":[49.375,35.7,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.61,"y":1},"o":{"x":0.39,"y":0},"n":"0p61_1_0p39_0","t":22,"s":[49.375,35.7,0],"e":[49.375,50.5,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.61,"y":1},"o":{"x":0.39,"y":0},"n":"0p61_1_0p39_0","t":28,"s":[49.375,50.5,0],"e":[49.375,35.7,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.61,"y":1},"o":{"x":0.39,"y":0},"n":"0p61_1_0p39_0","t":33,"s":[49.375,35.7,0],"e":[49.375,50.5,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.61,"y":1},"o":{"x":0.39,"y":0},"n":"0p61_1_0p39_0","t":38,"s":[49.375,50.5,0],"e":[49.375,35.7,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.61,"y":1},"o":{"x":0.39,"y":0},"n":"0p61_1_0p39_0","t":44,"s":[49.375,35.7,0],"e":[49.375,49.7,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0,"y":1},"o":{"x":0.39,"y":0},"n":"0_1_0p39_0","t":56,"s":[49.375,49.7,0],"e":[49.375,47.5,0],"to":[0,0,0],"ti":[0,0,0]},{"t":75}]},"a":{"k":[60,60,0]},"s":{"k":[100,100,100]}},"ao":0,"ip":0,"op":143,"st":-10,"bm":0,"sr":1},{"ddd":0,"ind":9,"ty":4,"nm":"Mouth","parent":10,"ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[60.625,62.5,0]},"a":{"k":[43,42,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[0,0],[0.559,-2.467],[10.659,0],[2.23,9.83],[-2.568,0]],"o":[[2.567,0],[-2.231,9.83],[-10.659,0],[-0.56,-2.467],[0,0]],"v":[[191.52,205.036],[195.416,209.852],[173.611,227.028],[151.805,209.852],[155.701,205.036]],"c":true}},"nm":"Path 4","mn":"ADBE Vector Shape - Group"},{"ty":"fl","fillEnabled":true,"c":{"k":[0.34,0.35,0.36,1]},"o":{"k":100},"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"k":[-131,-161],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 4","np":2,"mn":"ADBE Vector Group"}],"ip":0,"op":143,"st":-7,"bm":0,"sr":1},{"ddd":0,"ind":10,"ty":3,"nm":"FACE_C","parent":12,"ks":{"o":{"k":0},"r":{"k":0},"p":{"k":[{"i":{"x":0.61,"y":1},"o":{"x":1,"y":0},"n":"0p61_1_1_0","t":17,"s":[49.375,47.5,0],"e":[49.375,34.5,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.61,"y":1},"o":{"x":0.39,"y":0},"n":"0p61_1_0p39_0","t":22,"s":[49.375,34.5,0],"e":[49.375,50.5,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.61,"y":1},"o":{"x":0.39,"y":0},"n":"0p61_1_0p39_0","t":27,"s":[49.375,50.5,0],"e":[49.375,34.5,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.61,"y":1},"o":{"x":0.39,"y":0},"n":"0p61_1_0p39_0","t":32,"s":[49.375,34.5,0],"e":[49.375,50.5,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.61,"y":1},"o":{"x":0.39,"y":0},"n":"0p61_1_0p39_0","t":38,"s":[49.375,50.5,0],"e":[49.375,34.5,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.61,"y":1},"o":{"x":0.39,"y":0},"n":"0p61_1_0p39_0","t":43,"s":[49.375,34.5,0],"e":[49.375,50.5,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0,"y":1},"o":{"x":0.39,"y":0},"n":"0_1_0p39_0","t":54,"s":[49.375,50.5,0],"e":[49.375,47.5,0],"to":[0,0,0],"ti":[0,0,0]},{"t":72}]},"a":{"k":[60,60,0]},"s":{"k":[100,100,100]}},"ao":0,"ip":0,"op":143,"st":-10,"bm":0,"sr":1},{"ddd":0,"ind":11,"ty":4,"nm":"Head","parent":12,"ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[{"i":{"x":0.61,"y":1},"o":{"x":1,"y":0},"n":"0p61_1_1_0","t":16,"s":[50,50,0],"e":[50,43,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.61,"y":1},"o":{"x":0.39,"y":0},"n":"0p61_1_0p39_0","t":21,"s":[50,43,0],"e":[50,52,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.61,"y":1},"o":{"x":0.39,"y":0},"n":"0p61_1_0p39_0","t":26,"s":[50,52,0],"e":[50,43,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.61,"y":1},"o":{"x":0.39,"y":0},"n":"0p61_1_0p39_0","t":31,"s":[50,43,0],"e":[50,52,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.61,"y":1},"o":{"x":0.39,"y":0},"n":"0p61_1_0p39_0","t":37,"s":[50,52,0],"e":[50,43,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.61,"y":1},"o":{"x":0.39,"y":0},"n":"0p61_1_0p39_0","t":42,"s":[50,43,0],"e":[50,52,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0,"y":1},"o":{"x":0.39,"y":0},"n":"0_1_0p39_0","t":53,"s":[50,52,0],"e":[50,50,0],"to":[0,0,0],"ti":[0,0,0]},{"t":71}]},"a":{"k":[43,42,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[-23.566,0],[0,23.196],[23.566,0],[0,-23.196]],"o":[[23.566,0],[0,-23.196],[-23.566,0],[0,23.196]],"v":[[173.67,245],[216.341,203],[173.67,161],[131,203]],"c":true}},"nm":"Path 1","mn":"ADBE Vector Shape - Group"},{"ty":"fl","fillEnabled":true,"c":{"k":[1,0.82,0.42,1]},"o":{"k":100},"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"k":[-131,-161],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 5","np":2,"mn":"ADBE Vector Group"}],"ip":0,"op":143,"st":-12,"bm":0,"sr":1},{"ddd":0,"ind":12,"ty":1,"nm":"White Solid 1","ks":{"o":{"k":0},"r":{"k":0},"p":{"k":[10,10,0]},"a":{"k":[50,50,0]},"s":{"k":[20,20,100]}},"ao":0,"sw":100,"sh":100,"sc":"#ffffff","ip":0,"op":143,"st":0,"bm":0,"sr":1}]}],"layers":[{"ddd":0,"ind":0,"ty":0,"nm":"Laugh_03","refId":"comp_9","ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[100,100,0]},"a":{"k":[100,100,0]},"s":{"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,0.667]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0.333]},"n":["0p667_1_0p333_0","0p667_1_0p333_0","0p667_0p667_0p333_0p333"],"t":0,"s":[100,100,100],"e":[165,165,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,0.667]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0.333]},"n":["0p667_1_0p333_0","0p667_1_0p333_0","0p667_0p667_0p333_0p333"],"t":35,"s":[165,165,100],"e":[100,100,100]},{"t":73}]}},"ao":0,"w":200,"h":200,"ip":0,"op":74,"st":0,"bm":0,"sr":1}],"v":"4.5.0","ddd":0,"ip":0,"op":74,"fr":30,"w":200,"h":200}
15 changes: 13 additions & 2 deletions lottie/src/main/java/com/airbnb/lottie/Layer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.graphics.Color;
import android.graphics.Rect;
import android.support.annotation.Nullable;
import android.util.Log;

import org.json.JSONArray;
Expand Down Expand Up @@ -35,6 +36,9 @@ static Layer fromJson(JSONObject json, LottieComposition composition) throws JSO
Layer layer = new Layer(composition);
layer.layerName = json.getString("nm");
layer.layerId = json.getLong("ind");
if (json.has("refId")) {
layer.precompId = json.getString("refId");
}

int layerType = json.getInt("ty");
if (layerType <= LottieLayerType.Shape.ordinal()) {
Expand Down Expand Up @@ -89,7 +93,8 @@ static Layer fromJson(JSONObject json, LottieComposition composition) throws JSO
// Do nothing.
}
if (position != null) {
layer.position = AnimatablePathValue.createAnimatablePathOrSplitDimensionPath(position, composition);
layer.position =
AnimatablePathValue.createAnimatablePathOrSplitDimensionPath(position, composition);
}

JSONObject anchor = null;
Expand Down Expand Up @@ -182,6 +187,7 @@ static Layer fromJson(JSONObject json, LottieComposition composition) throws JSO
private long layerId;
private LottieLayerType layerType;
private long parentId = -1;
@Nullable private String precompId;

private final List<Mask> masks = new ArrayList<>();

Expand Down Expand Up @@ -228,6 +234,10 @@ String getName() {
return layerName;
}

@Nullable String getPrecompId() {
return precompId;
}

List<Mask> getMasks() {
return masks;
}
Expand Down Expand Up @@ -305,7 +315,8 @@ String toString(String prefix) {
sb.append(prefix).append("\tMasks: ").append(getMasks().size()).append("\n");
}
if (getSolidWidth() != 0 && getSolidHeight() != 0) {
sb.append(prefix).append("\tBackground: ").append(String.format(Locale.US, "%dx%d %X\n", getSolidWidth(), getSolidHeight(), getSolidColor()));
sb.append(prefix).append("\tBackground: ").append(String
.format(Locale.US, "%dx%d %X\n", getSolidWidth(), getSolidHeight(), getSolidColor()));
}
if (!shapes.isEmpty()) {
sb.append(prefix).append("\tShapes:\n");
Expand Down
27 changes: 27 additions & 0 deletions lottie/src/main/java/com/airbnb/lottie/LayerView.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.support.annotation.FloatRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.util.LongSparseArray;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -56,6 +57,32 @@ class LayerView extends AnimatableLayer {
}
}

List<Layer> precomps = composition.getPrecomps(layerModel.getPrecompId());
LongSparseArray<LayerView> precompMap = new LongSparseArray<>();
if (precomps != null) {
for (int i = precomps.size() - 1; i >= 0; i--) {
LayerView precompLayerView = new LayerView(
precomps.get(i), composition, callback, mainBitmap, maskBitmap, matteBitmap);
addLayer(precompLayerView);
precompMap.put(precompLayerView.getId(), precompLayerView);
}
}

for (AnimatableLayer layer : layers) {
if (!(layer instanceof LayerView)) {
continue;
}
long parentId = ((LayerView) layer).getLayerModel().getParentId();
if (parentId == -1) {
continue;
}
LayerView parentLayer = precompMap.get(parentId);
if (parentLayer == null) {
continue;
}
((LayerView) layer).setParentLayer(parentLayer);
}

setupForModel();
}

Expand Down
Loading

0 comments on commit ee7e638

Please sign in to comment.