Search in sources :

Example 81 with Path

use of android.graphics.Path in project Signal-Android by WhisperSystems.

the class CanvasView method setup.

/**
   * Common initialization.
   *
   * @param context
   */
private void setup(Context context) {
    this.context = context;
    this.pathLists.add(new Path());
    this.paintLists.add(this.createPaint());
    this.historyPointer++;
    this.textPaint.setARGB(0, 255, 255, 255);
}
Also used : Path(android.graphics.Path)

Example 82 with Path

use of android.graphics.Path in project Signal-Android by WhisperSystems.

the class CanvasView method render.

public void render(Canvas canvas) {
    if (this.canvas == null)
        return;
    float scaleX = 1.0F * canvas.getWidth() / this.canvas.getWidth();
    float scaleY = 1.0F * canvas.getHeight() / this.canvas.getHeight();
    Matrix matrix = new Matrix();
    matrix.setScale(scaleX, scaleY);
    for (int i = 0; i < this.historyPointer; i++) {
        Path path = this.pathLists.get(i);
        Paint paint = this.paintLists.get(i);
        Path scaledPath = new Path();
        path.transform(matrix, scaledPath);
        Paint scaledPaint = new Paint(paint);
        scaledPaint.setStrokeWidth(scaledPaint.getStrokeWidth() * scaleX);
        canvas.drawPath(scaledPath, scaledPaint);
    }
}
Also used : Path(android.graphics.Path) Matrix(android.graphics.Matrix) Paint(android.graphics.Paint) Paint(android.graphics.Paint)

Example 83 with Path

use of android.graphics.Path in project Signal-Android by WhisperSystems.

the class CanvasView method clear.

/**
   * This method initializes canvas.
   *
   * @return
   */
public void clear() {
    Path path = new Path();
    path.moveTo(0F, 0F);
    path.addRect(0F, 0F, 1000F, 1000F, Path.Direction.CCW);
    path.close();
    Paint paint = new Paint();
    paint.setColor(Color.WHITE);
    paint.setStyle(Paint.Style.FILL);
    if (this.historyPointer == this.pathLists.size()) {
        this.pathLists.add(path);
        this.paintLists.add(paint);
        this.historyPointer++;
    } else {
        // On the way of Undo or Redo
        this.pathLists.set(this.historyPointer, path);
        this.paintLists.set(this.historyPointer, paint);
        this.historyPointer++;
        for (int i = this.historyPointer, size = this.paintLists.size(); i < size; i++) {
            this.pathLists.remove(this.historyPointer);
            this.paintLists.remove(this.historyPointer);
        }
    }
    this.text = "";
    // Clear
    this.invalidate();
}
Also used : Path(android.graphics.Path) Paint(android.graphics.Paint) Paint(android.graphics.Paint)

Example 84 with Path

use of android.graphics.Path in project XRecyclerView by jianghejie.

the class JellyView method init.

private void init() {
    if (isInEditMode()) {
        return;
    }
    path = new Path();
    paint = new Paint();
    paint.setColor(getContext().getResources().getColor(android.R.color.holo_blue_bright));
    paint.setAntiAlias(true);
}
Also used : Path(android.graphics.Path) Paint(android.graphics.Paint)

Example 85 with Path

use of android.graphics.Path in project LoadingView by ldoublem.

the class LVFunnyBar method onDraw.

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    //        canvas.translate(0,mHeight/2);
    canvas.save();
    float wspace = mWidth / 8f;
    float hspace = mHeight / 8f;
    Path p = new Path();
    float leftLong = 0.1f;
    float rightLong = 0.1f;
    for (int i = 0; i < 3; i++) {
        leftLong = mAnimatedValue * (1 + i / 4f);
        if (leftLong > 1f)
            leftLong = 1f;
        float wlong = mWidth / 2 * leftLong - wspace / 2;
        float hlong = mHeight / 2 * leftLong - hspace / 2;
        if (wlong < wspace / 8 / 8 / 2) {
            wlong = wspace / 8 / 8 / 2;
        }
        if (hlong < hspace / 8 / 8 / 2) {
            hlong = wspace / 8 / 8 / 2;
        }
        p.reset();
        p.moveTo((i + 0.5f) * wspace, mHeight / 2 + (i * hspace));
        p.lineTo((i + 1f) * wspace + wlong, mHeight / 2 - hspace / 2f + (i * hspace) - hlong);
        p.lineTo((i + 1.5f) * wspace + wlong, mHeight / 2 + (i * hspace) - hlong);
        p.lineTo((i + 1f) * wspace, mHeight / 2 + hspace / 2f + (i * hspace));
        p.close();
        canvas.drawPath(p, mPaintLeftTop);
        p.reset();
        p.moveTo((i + 0.5f) * wspace, mHeight / 2 + (i * hspace));
        p.lineTo((i + 1f) * wspace, mHeight / 2 + hspace / 2f + (i * hspace));
        p.lineTo((i + 1f) * wspace, mHeight / 2 + hspace / 2f + (i * hspace) + hspace);
        p.lineTo((i + 0.5f) * wspace, mHeight / 2 + (i * hspace) + hspace);
        p.close();
        canvas.drawPath(p, mPaintLeftLeft);
        p.reset();
        p.moveTo((i + 1.5f) * wspace + wlong, mHeight / 2 + (i * hspace) - hlong);
        p.lineTo((i + 1f) * wspace, mHeight / 2 + hspace / 2f + (i * hspace));
        p.lineTo((i + 1f) * wspace, mHeight / 2 + hspace / 2f + (i * hspace) + hspace);
        p.lineTo((i + 1.5f) * wspace + wlong, mHeight / 2 + (i * hspace) + hspace - hlong);
        p.close();
        canvas.drawPath(p, mPaintLeftRight);
        int rightPosition = i;
        p.reset();
        p.moveTo(mWidth - (rightPosition + 1.5f) * wspace - wlong, mHeight / 2 + (rightPosition * hspace) - hlong);
        p.lineTo(mWidth - (rightPosition + 1f) * wspace - wlong, mHeight / 2 - hspace / 2f + (rightPosition * hspace) - hlong);
        p.lineTo(mWidth - (rightPosition + 0.5f) * wspace, mHeight / 2 + (rightPosition * hspace));
        p.lineTo(mWidth - (rightPosition + 1f) * wspace, mHeight / 2 + hspace / 2f + (rightPosition * hspace));
        p.close();
        canvas.drawPath(p, mPaintRightTop);
        p.reset();
        p.moveTo(mWidth - (rightPosition + 1.5f) * wspace - wlong, mHeight / 2 + (rightPosition * hspace) - hlong);
        p.lineTo(mWidth - (rightPosition + 1f) * wspace, mHeight / 2 + hspace / 2f + (rightPosition * hspace));
        p.lineTo(mWidth - (rightPosition + 1f) * wspace, mHeight / 2 + hspace / 2f + (rightPosition * hspace) + hspace);
        p.lineTo(mWidth - (rightPosition + 1.5f) * wspace - wlong, mHeight / 2 + (rightPosition * hspace) + hspace - hlong);
        p.close();
        canvas.drawPath(p, mPaintRightLeft);
        p.reset();
        p.moveTo(mWidth - (rightPosition + 0.5f) * wspace, mHeight / 2 + (rightPosition * hspace));
        p.lineTo(mWidth - (rightPosition + 1f) * wspace, mHeight / 2 + hspace / 2f + (rightPosition * hspace));
        p.lineTo(mWidth - (rightPosition + 1f) * wspace, mHeight / 2 + hspace / 2f + (rightPosition * hspace) + hspace);
        p.lineTo(mWidth - (rightPosition + 0.5f) * wspace, mHeight / 2 + (rightPosition * hspace) + hspace);
        p.close();
        canvas.drawPath(p, mPaintRightRight);
    }
    canvas.restore();
}
Also used : Path(android.graphics.Path) Paint(android.graphics.Paint)

Aggregations

Path (android.graphics.Path)631 Paint (android.graphics.Paint)237 RectF (android.graphics.RectF)142 Rect (android.graphics.Rect)40 Canvas (android.graphics.Canvas)39 Matrix (android.graphics.Matrix)36 TextPaint (android.text.TextPaint)27 Bitmap (android.graphics.Bitmap)26 ObjectAnimator (android.animation.ObjectAnimator)18 LinearGradient (android.graphics.LinearGradient)18 PointF (android.graphics.PointF)18 Point (android.graphics.Point)16 View (android.view.View)16 RadialGradient (android.graphics.RadialGradient)15 Animator (android.animation.Animator)13 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)12 PathMeasure (android.graphics.PathMeasure)11 PropertyValuesHolder (android.animation.PropertyValuesHolder)10 InflateException (android.view.InflateException)10 ViewGroup (android.view.ViewGroup)10