List of usage examples for android.graphics Path moveTo
public void moveTo(float x, float y)
From source file:andoridhost.imczy.com.activitymaterial.custom.ReturnChangePosition.java
public ReturnChangePosition() { setPathMotion(new PathMotion() { @Override/*from w ww . ja v a 2 s . com*/ public Path getPath(float startX, float startY, float endX, float endY) { Path path = new Path(); path.moveTo(startX, startY); Log.d(TAG, "getPath() called with: " + "startX = [" + startX + "], startY = [" + startY + "], endX = [" + endX + "], endY = [" + endY + "]"); float controlPointX = (startX + endX) / 3; float controlPointY = (startY + endY) / 2; path.quadTo(controlPointX, controlPointY, endX, endY); return path; } }); }
From source file:android.support.graphics.drawable.PathInterpolatorCompat.java
private void initQuad(float controlX, float controlY) { Path path = new Path(); path.moveTo(0, 0); path.quadTo(controlX, controlY, 1f, 1f); initPath(path);//from ww w . ja va 2 s . c o m }
From source file:android.support.graphics.drawable.PathInterpolatorCompat.java
private void initCubic(float x1, float y1, float x2, float y2) { Path path = new Path(); path.moveTo(0, 0); path.cubicTo(x1, y1, x2, y2, 1f, 1f); initPath(path);/*from www . j a va 2s . c om*/ }
From source file:andoridhost.imczy.com.activitymaterial.custom.ChangePosition.java
public ChangePosition() { setPathMotion(new PathMotion() { @Override//www . ja v a2 s . c om public Path getPath(float startX, float startY, float endX, float endY) { Path path = new Path(); path.moveTo(startX, startY); Log.d(TAG, "getPath() called with: " + "startX = [" + startX + "], startY = [" + startY + "], endX = [" + endX + "], endY = [" + endY + "]"); float controlPointX = (startX + endX) / 3; float controlPointY = (startY + endY) / 2; path.quadTo(controlPointX, controlPointY, endX, endY); return path; } }); }
From source file:android.support.wear.widget.util.ArcSwipe.java
private float[][] interpolate(float[] start, float[] end, int steps, boolean isClockwise) { float startAngle = getAngle(start[0], start[1]); float endAngle = getAngle(end[0], end[1]); Path path = new Path(); PathMeasure pathMeasure = new PathMeasure(); path.moveTo(start[0], start[1]); path.arcTo(mBounds, startAngle, getSweepAngle(startAngle, endAngle, isClockwise)); pathMeasure.setPath(path, false);/*from w w w .ja va2 s .c o m*/ float pathLength = pathMeasure.getLength(); float[][] res = new float[steps][2]; float[] mPathTangent = new float[2]; for (int i = 1; i < steps + 1; i++) { pathMeasure.getPosTan((pathLength * i) / (steps + 2f), res[i - 1], mPathTangent); } return res; }
From source file:com.github.czy1121.view.CornerLabelView.java
private Path calcPath() { Path path = new Path(); path.moveTo(-mHeight, 0); path.lineTo(mHeight, 0);/*w w w. jav a2 s . com*/ int factor = mIsTop ? -1 : 1; if (mIsTriangle) { path.lineTo(0, factor * mHeight); } else { int lineHeight = factor * (int) (mPaddingCenter + mPaddingBottom + mText1.height); path.lineTo(mHeight + lineHeight, lineHeight); path.lineTo(-mHeight + lineHeight, lineHeight); } path.close(); return path; }
From source file:com.journeyapps.barcodescanner.WXViewfinderView.java
@SuppressLint("DrawAllocation") @Override/*from w ww . j av a 2 s . c o m*/ public void onDraw(Canvas canvas) { refreshSizes(); if (framingRect == null || previewFramingRect == null) { return; } Rect frame = framingRect; Rect previewFrame = previewFramingRect; int width = canvas.getWidth(); int height = canvas.getHeight(); maskPaint.setColor(maskColor); canvas.drawRect(0, 0, width, frame.top, maskPaint); canvas.drawRect(0, frame.top, frame.left, frame.bottom + 1, maskPaint); canvas.drawRect(frame.right + 1, frame.top, width, frame.bottom + 1, maskPaint); canvas.drawRect(0, frame.bottom + 1, width, height, maskPaint); //drawable the border canvas.drawRect(frame.left + 1, frame.top + 1, frame.right, frame.bottom, borderPaint); int halfWidth = (int) (cornerWidth / 2); //draw four corner Path corner1 = new Path(); corner1.moveTo(frame.left, frame.top + cornerLength); corner1.lineTo(frame.left, frame.top); corner1.lineTo(frame.left + cornerLength, frame.top); Matrix translate1 = new Matrix(); translate1.setTranslate(halfWidth, halfWidth); corner1.transform(translate1); canvas.drawPath(corner1, cornerPaint); Path corner2 = new Path(); corner2.moveTo(frame.right + 1 - cornerLength, frame.top); corner2.lineTo(frame.right + 1, frame.top); corner2.lineTo(frame.right + 1, frame.top + cornerLength); Matrix translate2 = new Matrix(); translate2.setTranslate(-halfWidth, halfWidth); corner2.transform(translate2); canvas.drawPath(corner2, cornerPaint); Path corner3 = new Path(); corner3.moveTo(frame.left, frame.bottom + 1 - cornerLength); corner3.lineTo(frame.left, frame.bottom + 1); corner3.lineTo(frame.left + cornerLength, frame.bottom + 1); Matrix translate3 = new Matrix(); translate3.setTranslate(halfWidth, -halfWidth); corner3.transform(translate3); canvas.drawPath(corner3, cornerPaint); Path corner4 = new Path(); corner4.moveTo(frame.right + 1 - cornerLength, frame.bottom + 1); corner4.lineTo(frame.right + 1, frame.bottom + 1); corner4.lineTo(frame.right + 1, frame.bottom + 1 - cornerLength); Matrix translate4 = new Matrix(); translate4.setTranslate(-halfWidth, -halfWidth); corner4.transform(translate4); canvas.drawPath(corner4, cornerPaint); offset += speed; if (offset >= frame.bottom - frame.top) { offset = 0; } Rect rect = new Rect(); rect.left = frame.left + 1 + laserPadding; rect.top = frame.top + 1 + offset; rect.right = frame.right - laserPadding; rect.bottom = frame.top + 1 + offset + 3; Bitmap laserBitmap = ((BitmapDrawable) ResourcesCompat.getDrawable(getResources(), R.drawable.scan_laser, null)).getBitmap(); canvas.drawBitmap(laserBitmap, null, rect, linePaint); textPaint.setTextAlign(Paint.Align.CENTER); canvas.drawText(statusText, (frame.right + frame.left) / 2, frame.bottom + statusTextPadding + statusTextSize, textPaint); postInvalidateDelayed(animationDelay, frame.left, frame.top, frame.right, frame.bottom); }
From source file:com.rks.musicx.misc.widgets.DiagonalLayout.java
private Path createClipPath(float perpendicularHeight) { Path path = new Path(); if (settings.isBottom()) { if (settings.isGravityLeft()) { path.moveTo(width - getPaddingRight() + EPSILON, height - perpendicularHeight - getPaddingBottom() + EPSILON); path.lineTo(width - getPaddingRight() + EPSILON, height - getPaddingBottom() + EPSILON); path.lineTo(getPaddingLeft() - EPSILON, height - getPaddingBottom() + EPSILON); path.close();//from www . j av a 2 s . c o m } else { path.moveTo(width - getPaddingRight() + EPSILON, height - getPaddingBottom() + EPSILON); path.lineTo(getPaddingLeft() - EPSILON, height - getPaddingBottom() + EPSILON); path.lineTo(getPaddingLeft() - EPSILON, height - perpendicularHeight - getPaddingBottom() + EPSILON); path.close(); } } else { if (settings.isGravityLeft()) { path.moveTo(width - getPaddingRight() + EPSILON, getPaddingTop() + perpendicularHeight - EPSILON); path.lineTo(getPaddingLeft() - EPSILON, getPaddingTop() - EPSILON); path.lineTo(width - getPaddingRight() + EPSILON, getPaddingTop() - EPSILON); path.close(); } else { path.moveTo(width - getPaddingRight() + EPSILON, getPaddingTop() - EPSILON); path.lineTo(getPaddingLeft() - EPSILON, getPaddingTop() + perpendicularHeight - EPSILON); path.lineTo(getPaddingLeft() - EPSILON, getPaddingTop() - EPSILON); path.close(); } } return path; }
From source file:com.rks.musicx.misc.widgets.DiagonalLayout.java
private Path createOutlinePath(float perpendicularHeight) { Path path = new Path(); if (settings.isBottom()) { if (settings.isGravityLeft()) { path.moveTo(getPaddingLeft(), getPaddingRight()); path.lineTo(width - getPaddingRight(), getPaddingTop()); path.lineTo(width - getPaddingRight(), height - perpendicularHeight - getPaddingBottom()); path.lineTo(getPaddingLeft(), height - getPaddingBottom()); path.close();//from www . j ava2 s .c om } else { path.moveTo(width - getPaddingRight(), height - getPaddingBottom()); path.lineTo(getPaddingLeft(), height - perpendicularHeight - getPaddingBottom()); path.lineTo(getPaddingLeft(), getPaddingTop()); path.lineTo(width - getPaddingRight(), getPaddingTop()); path.close(); } } else { if (settings.isGravityLeft()) { path.moveTo(width - getPaddingRight(), height - getPaddingBottom()); path.lineTo(width - getPaddingRight(), getPaddingTop() + perpendicularHeight); path.lineTo(getPaddingLeft(), getPaddingTop()); path.lineTo(getPaddingLeft(), height - getPaddingBottom()); path.close(); } else { path.moveTo(width - getPaddingRight(), height - getPaddingBottom()); path.lineTo(width - getPaddingRight(), getPaddingTop()); path.lineTo(getPaddingLeft(), getPaddingTop() + perpendicularHeight); path.lineTo(getPaddingLeft(), height - getPaddingBottom()); path.close(); } } return path; }
From source file:android.example.com.visualizerpreferences.AudioVisuals.VisualizerView.java
public VisualizerView(Context context, AttributeSet attrs) { super(context, attrs); mBytes = null;/*from w ww. ja v a2s. co m*/ TrailedShape.setMinSize(MIN_SIZE_DEFAULT); // Create each of the shapes and define how they are drawn on screen // Make bass circle mBassCircle = new TrailedShape(BASS_MULTIPLIER) { @Override protected void drawThisShape(float shapeCenterX, float shapeCenterY, float currentSize, Canvas canvas, Paint paint) { canvas.drawCircle(shapeCenterX, shapeCenterY, currentSize, paint); } }; // Make midrange square mMidSquare = new TrailedShape(MID_MULTIPLIER) { @Override protected void drawThisShape(float shapeCenterX, float shapeCenterY, float currentSize, Canvas canvas, Paint paint) { canvas.drawRect(shapeCenterX - currentSize, shapeCenterY - currentSize, shapeCenterX + currentSize, shapeCenterY + currentSize, paint); } }; // Make treble triangle mTrebleTriangle = new TrailedShape(TREBLE_MULTIPLIER) { @Override protected void drawThisShape(float shapeCenterX, float shapeCenterY, float currentSize, Canvas canvas, Paint paint) { Path trianglePath = new Path(); trianglePath.moveTo(shapeCenterX, shapeCenterY - currentSize); trianglePath.lineTo(shapeCenterX + currentSize, shapeCenterY + currentSize / 2); trianglePath.lineTo(shapeCenterX - currentSize, shapeCenterY + currentSize / 2); trianglePath.lineTo(shapeCenterX, shapeCenterY - currentSize); canvas.drawPath(trianglePath, paint); } }; }