use of android.graphics.DashPathEffect in project WoWoViewPager by Nightonke.
the class WoWoPathView method onDraw.
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
PathEffect pathEffect = new DashPathEffect(new float[] { mPathLength, mPathLength }, (mPathLength - mPathLength * mProgress));
mPaint.setPathEffect(pathEffect);
canvas.save();
canvas.translate(getPaddingLeft(), getPaddingTop());
canvas.drawPath(mPath, mPaint);
if (headImageId != 0) {
mPathMeasure.getPosTan(mPathLength * mProgress, mBitmapPosition, mBitmapTan);
mMatrix.reset();
float degrees = (float) (Math.atan2(mBitmapTan[1], mBitmapTan[0]) * 180.0 / Math.PI);
mMatrix.postRotate(degrees, mBitmapOffsetX, mBitmapOffsetY);
mMatrix.postTranslate(mBitmapPosition[0] - mBitmapOffsetX, mBitmapPosition[1] - mBitmapOffsetY);
canvas.drawBitmap(mBitmap, mMatrix, null);
}
canvas.restore();
}
use of android.graphics.DashPathEffect in project muzei by romannurik.
the class AnimatedMuzeiLogoView method onDraw.
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (mState == STATE_NOT_STARTED || mGlyphData == null) {
return;
}
long t = System.currentTimeMillis() - mStartTime;
// Draw outlines (starts as traced)
for (int i = 0; i < mGlyphData.length; i++) {
float phase = MathUtil.constrain(0, 1, (t - (TRACE_TIME - TRACE_TIME_PER_GLYPH) * i * 1f / mGlyphData.length) * 1f / TRACE_TIME_PER_GLYPH);
float distance = INTERPOLATOR.getInterpolation(phase) * mGlyphData[i].length;
mGlyphData[i].paint.setColor(TRACE_RESIDUE_COLOR);
mGlyphData[i].paint.setPathEffect(new DashPathEffect(new float[] { distance, mGlyphData[i].length }, 0));
canvas.drawPath(mGlyphData[i].path, mGlyphData[i].paint);
mGlyphData[i].paint.setColor(TRACE_COLOR);
mGlyphData[i].paint.setPathEffect(new DashPathEffect(new float[] { 0, distance, phase > 0 ? mMarkerLength : 0, mGlyphData[i].length }, 0));
canvas.drawPath(mGlyphData[i].path, mGlyphData[i].paint);
}
if (t > FILL_START) {
if (mState < STATE_FILL_STARTED) {
changeState(STATE_FILL_STARTED);
}
// If after fill start, draw fill
float phase = MathUtil.constrain(0, 1, (t - FILL_START) * 1f / FILL_TIME);
mFillPaint.setARGB((int) (phase * 255), 255, 255, 255);
for (GlyphData glyphData : mGlyphData) {
canvas.drawPath(glyphData.path, mFillPaint);
}
}
if (t < FILL_START + FILL_TIME) {
// draw next frame if animation isn't finished
postInvalidateOnAnimation();
} else {
changeState(STATE_FINISHED);
}
}
use of android.graphics.DashPathEffect in project lottie-android by airbnb.
the class StrokeContent method applyDashPatternIfNeeded.
private void applyDashPatternIfNeeded() {
if (dashPatternAnimations.isEmpty()) {
return;
}
float scale = lottieDrawable.getScale();
for (int i = 0; i < dashPatternAnimations.size(); i++) {
dashPatternValues[i] = dashPatternAnimations.get(i).getValue();
// and a minimum gap size of 0.01.
if (i % 2 == 0) {
if (dashPatternValues[i] < 1f) {
dashPatternValues[i] = 1f;
}
} else {
if (dashPatternValues[i] < 0.1f) {
dashPatternValues[i] = 0.1f;
}
}
dashPatternValues[i] *= scale;
}
float offset = dashPatternOffsetAnimation == null ? 0f : dashPatternOffsetAnimation.getValue();
paint.setPathEffect(new DashPathEffect(dashPatternValues, offset));
}
use of android.graphics.DashPathEffect in project MaterialLibrary by DeveloperPaul123.
the class CircularTextView method getCheckMarkPath.
/**
* Returns a path that draws a check mark.
* @return the check mark path.
*/
private Path getCheckMarkPath() {
Path path = new Path();
float radius = diameter / 2.00f;
float radiusOne = radius * 0.35f;
float radiusTwo = radius * 0.68f;
float lineOneX = (float) (cx + radiusOne * Math.cos(Math.toRadians(-135.0)));
float lineOneY = (float) (cy + radiusOne * Math.sin(Math.toRadians(-135.0)));
float lineTwoX = (float) (cx + radiusTwo * Math.cos(Math.toRadians(-45.0)));
float lineTwoY = (float) (cy + radiusTwo * Math.sin(Math.toRadians(-45.0)));
path.moveTo(lineOneX, lineOneY);
path.lineTo(cx, cy);
path.lineTo(lineTwoX, lineTwoY);
checkMarkPaint.setPathEffect(new DashPathEffect(new float[] { pathLength, pathLength }, 0.0f));
return path;
}
use of android.graphics.DashPathEffect in project XobotOS by xamarin.
the class GradientDrawable method setStroke.
public void setStroke(int width, int color, float dashWidth, float dashGap) {
mGradientState.setStroke(width, color, dashWidth, dashGap);
if (mStrokePaint == null) {
mStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mStrokePaint.setStyle(Paint.Style.STROKE);
}
mStrokePaint.setStrokeWidth(width);
mStrokePaint.setColor(color);
DashPathEffect e = null;
if (dashWidth > 0) {
e = new DashPathEffect(new float[] { dashWidth, dashGap }, 0);
}
mStrokePaint.setPathEffect(e);
invalidateSelf();
}
Aggregations