use of android.graphics.Path in project AndroidRubberIndicator by LyndonChin.
the class RubberIndicator method init.
private void init(AttributeSet attrs, int defStyle) {
/** Get XML attributes */
final TypedArray styledAttributes = getContext().obtainStyledAttributes(attrs, R.styleable.RubberIndicator, defStyle, 0);
mSmallCircleColor = styledAttributes.getColor(R.styleable.RubberIndicator_smallCircleColor, DEFAULT_SMALL_CIRCLE_COLOR);
mLargeCircleColor = styledAttributes.getColor(R.styleable.RubberIndicator_largeCircleColor, DEFAULT_LARGE_CIRCLE_COLOR);
mOuterCircleColor = styledAttributes.getColor(R.styleable.RubberIndicator_outerCircleColor, DEFAULT_OUTER_CIRCLE_COLOR);
styledAttributes.recycle();
/** Initialize views */
View rootView = inflate(getContext(), R.layout.rubber_indicator, this);
mContainer = (LinearLayout) rootView.findViewById(R.id.container);
mOuterCircle = (CircleView) rootView.findViewById(R.id.outer_circle);
// Apply outer color to outerCircle and background shape
View containerWrapper = rootView.findViewById(R.id.container_wrapper);
mOuterCircle.setColor(mOuterCircleColor);
GradientDrawable shape = (GradientDrawable) containerWrapper.getBackground();
shape.setColor(mOuterCircleColor);
/** values */
mSmallCircleRadius = dp2px(SMALL_CIRCLE_RADIUS);
mLargeCircleRadius = dp2px(LARGE_CIRCLE_RADIUS);
mOuterCircleRadius = dp2px(OUTER_CIRCLE_RADIUS);
/** animators */
mPvhScaleX = PropertyValuesHolder.ofFloat("scaleX", 1, 0.8f, 1);
mPvhScaleY = PropertyValuesHolder.ofFloat("scaleY", 1, 0.8f, 1);
mPvhScale = PropertyValuesHolder.ofFloat("scaleY", 1, 0.5f, 1);
mPvhRotation = PropertyValuesHolder.ofFloat("rotation", 0);
mSmallCirclePath = new Path();
mPendingAnimations = new LinkedList<>();
/** circle view list */
mCircleViews = new ArrayList<>();
}
use of android.graphics.Path in project lottie-android by airbnb.
the class BaseLayer method applyMasks.
private void applyMasks(Canvas canvas, Matrix matrix) {
canvas.saveLayer(rect, maskPaint, SAVE_FLAGS);
canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), clearPaint);
//noinspection ConstantConditions
int size = mask.getMasks().size();
for (int i = 0; i < size; i++) {
Mask mask = this.mask.getMasks().get(i);
BaseKeyframeAnimation<?, Path> maskAnimation = this.mask.getMaskAnimations().get(i);
Path maskPath = maskAnimation.getValue();
path.set(maskPath);
path.transform(matrix);
switch(mask.getMaskMode()) {
case MaskModeSubtract:
maskPath.setFillType(Path.FillType.INVERSE_WINDING);
break;
case MaskModeAdd:
default:
maskPath.setFillType(Path.FillType.WINDING);
}
canvas.drawPath(path, contentPaint);
}
canvas.restore();
}
use of android.graphics.Path in project lottie-android by airbnb.
the class MergePathsContent method opFirstPathWithRest.
@TargetApi(Build.VERSION_CODES.KITKAT)
private void opFirstPathWithRest(Path.Op op) {
remainderPath.reset();
firstPath.reset();
for (int i = pathContents.size() - 1; i >= 1; i--) {
PathContent content = pathContents.get(i);
if (content instanceof ContentGroup) {
List<PathContent> pathList = ((ContentGroup) content).getPathList();
for (int j = pathList.size() - 1; j >= 0; j--) {
Path path = pathList.get(j).getPath();
path.transform(((ContentGroup) content).getTransformationMatrix());
this.remainderPath.addPath(path);
}
} else {
remainderPath.addPath(content.getPath());
}
}
PathContent lastContent = pathContents.get(0);
if (lastContent instanceof ContentGroup) {
List<PathContent> pathList = ((ContentGroup) lastContent).getPathList();
for (int j = 0; j < pathList.size(); j++) {
Path path = pathList.get(j).getPath();
path.transform(((ContentGroup) lastContent).getTransformationMatrix());
this.firstPath.addPath(path);
}
} else {
firstPath.set(lastContent.getPath());
}
path.op(firstPath, remainderPath, op);
}
use of android.graphics.Path in project lottie-android by airbnb.
the class Utils method createPath.
static Path createPath(PointF startPoint, PointF endPoint, PointF cp1, PointF cp2) {
Path path = new Path();
path.moveTo(startPoint.x, startPoint.y);
if (cp1 != null && cp1.length() != 0 && cp2 != null && cp2.length() != 0) {
path.cubicTo(startPoint.x + cp1.x, startPoint.y + cp1.y, endPoint.x + cp2.x, endPoint.y + cp2.y, endPoint.x, endPoint.y);
} else {
path.lineTo(endPoint.x, endPoint.y);
}
return path;
}
use of android.graphics.Path in project Carbon by ZieIony.
the class CoordinatorLayout method initCorners.
private void initCorners() {
if (cornerRadius > 0) {
cornerRadius = Math.min(cornerRadius, Math.min(getWidth(), getHeight()) / 2.0f);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setClipToOutline(true);
setOutlineProvider(ShadowShape.viewOutlineProvider);
} else {
cornersMask = new Path();
cornersMask.addRoundRect(new RectF(0, 0, getWidth(), getHeight()), cornerRadius, cornerRadius, Path.Direction.CW);
cornersMask.setFillType(Path.FillType.INVERSE_WINDING);
}
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
setOutlineProvider(ViewOutlineProvider.BOUNDS);
}
}
Aggregations