-
- All Implemented Interfaces:
-
com.airbnb.lottie.animation.content.Content,com.airbnb.lottie.animation.content.ShapeModifierContent,com.airbnb.lottie.animation.keyframe.BaseKeyframeAnimation.AnimationListener
public class RoundedCornersContent implements ShapeModifierContent, BaseKeyframeAnimation.AnimationListener
-
-
Field Summary
Fields Modifier and Type Field Description private final Stringnameprivate final BaseKeyframeAnimation<Float, Float>roundedCorners
-
Constructor Summary
Constructors Constructor Description RoundedCornersContent(LottieDrawable lottieDrawable, BaseLayer layer, RoundedCorners roundedCorners)
-
Method Summary
Modifier and Type Method Description StringgetName()BaseKeyframeAnimation<Float, Float>getRoundedCorners()voidonValueChanged()voidsetContents(List<Content> contentsBefore, List<Content> contentsAfter)voidaddUpdateListener(BaseKeyframeAnimation.AnimationListener listener)ShapeDatamodifyShape(ShapeData startingShapeData)Rounded corner algorithm:Iterate through each vertex.If a vertex is a sharp corner, it rounds it.If a vertex has control points, it is already rounded, so it does nothing. -
-
Constructor Detail
-
RoundedCornersContent
RoundedCornersContent(LottieDrawable lottieDrawable, BaseLayer layer, RoundedCorners roundedCorners)
-
-
Method Detail
-
getRoundedCorners
BaseKeyframeAnimation<Float, Float> getRoundedCorners()
-
onValueChanged
void onValueChanged()
-
setContents
void setContents(List<Content> contentsBefore, List<Content> contentsAfter)
-
addUpdateListener
void addUpdateListener(BaseKeyframeAnimation.AnimationListener listener)
-
modifyShape
ShapeData modifyShape(ShapeData startingShapeData)
Rounded corner algorithm:Iterate through each vertex.If a vertex is a sharp corner, it rounds it.If a vertex has control points, it is already rounded, so it does nothing.
To round a vertex:Split the vertex into two.Move vertex 1 directly towards the previous vertex.Set vertex 1's in control point to itself so it is not rounded on that side.Extend vertex 1's out control point towards the original vertex.
Repeat for vertex 2:Move vertex 2 directly towards the next vertex.Set vertex 2's out point to itself so it is not rounded on that side.Extend vertex 2's in control point towards the original vertex.
The distance that the vertices and control points are moved are relative to theshape's vertex distances and the roundedness set in the animation.
-
-
-
-