Java 类android.graphics.Path 实例源码

项目:PresenterLite    文件:ShapedImageView.java   
private Bitmap rotatedOval(Bitmap bitmap) {
    Bitmap bmp;
    float width = bitmap.getWidth();
    float height = bitmap.getHeight();

    bmp = Bitmap.createBitmap((int) width, (int) height, Bitmap.Config.ARGB_8888);
    BitmapShader shader = new BitmapShader(bitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);

    Canvas canvas = new Canvas(bmp);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setShader(shader);

    Path oval = new Path();
    Matrix matrix = new Matrix();
    RectF ovalRect = new RectF(width / OVAL_FACTOR, 0, width - (width / OVAL_FACTOR), height);

    oval.addOval(ovalRect, Path.Direction.CW);
    matrix.postRotate(ROTATION, width / 2, height / 2);
    oval.transform(matrix, oval);
    canvas.drawPath(oval, paint);

    return bmp;
}
项目:android-dev-challenge    文件:TrailedShape.java   
TrailedShape(float multiplier) {
    this.mMultiplier = multiplier;

    // Setup trail variables
    this.mTrailPath = new Path();
    this.mTrailList = new LinkedList<>();

    // Setup paint and attributes
    this.mPaint = new Paint();
    this.mTrailPaint = new Paint();

    mPaint.setStyle(Paint.Style.FILL);
    mTrailPaint.setStyle(Paint.Style.STROKE);
    mTrailPaint.setStrokeWidth(5);
    mTrailPaint.setStrokeJoin(Paint.Join.ROUND);
    mTrailPaint.setStrokeCap(Paint.Cap.ROUND);
}
项目:Aurora    文件:WeatherView.java   
private void drawCloud(Canvas canvas) {
    mPath.reset();
    mPaint.setShader(mCloudLinearGradient);
    if (mCircleInfoBottomOne.isCanDraw())
        mPath.addCircle(mCircleInfoBottomOne.getX(),mCircleInfoBottomOne.getY(),mCircleInfoBottomOne.getRadius(), Path.Direction.CW);//左下1
    if (mCircleInfoBottomTwo.isCanDraw())
        mPath.addCircle(mCircleInfoBottomTwo.getX(),mCircleInfoBottomTwo.getY(),mCircleInfoBottomTwo.getRadius(), Path.Direction.CW);//底部2
    if (mCircleInfoBottomThree.isCanDraw())
        mPath.addCircle(mCircleInfoBottomThree.getX(),mCircleInfoBottomThree.getY(),mCircleInfoBottomThree.getRadius(), Path.Direction.CW);//底3
    if (mCircleInfoTopOne.isCanDraw())
        mPath.addCircle(mCircleInfoTopOne.getX(),mCircleInfoTopOne.getY(),mCircleInfoTopOne.getRadius(), Path.Direction.CW);//顶1
    if (mCircleInfoTopTwo.isCanDraw())
        mPath.addCircle(mCircleInfoTopTwo.getX(),mCircleInfoTopTwo.getY(),mCircleInfoTopTwo.getRadius(), Path.Direction.CW);//顶2
    canvas.save();
    canvas.clipRect(0,0,getMeasuredWidth(),getMeasuredHeight()/2+getMeasuredWidth()/7f);
    canvas.drawPath(mPath,mPaint);
    canvas.restore();
    mPaint.setShader(null);
}
项目:PropertyAnimatorDemo    文件:MyBezierView.java   
private void init(Context context) {
    mTextPaint = new Paint();
    mPaint = new Paint();
    mPath = new Path();
    startPoint = new Point(200, 200);
    endPoint = new Point(800, 800);
    assistPoint = new Point(800, 200);
    // 抗锯齿
    mPaint.setAntiAlias(true);
    // 防抖动
    mPaint.setDither(true);
    //坐标
    mTextPaint.setColor(Color.RED);
    mTextPaint.setTextSize(20);
    mTextPaint.setStrokeWidth(10);
    mTextPaint.setAntiAlias(true);
    mTextPaint.setDither(true);
}
项目:ColumnAnimViewProject    文件:RadarView.java   
/**
 * 绘制正多边形
 */
private void drawPolygon(Canvas canvas){
    Path path = new Path();
    float r = radius/(count-1);
    for(int i=1;i<count;i++){
        float curR = r*i;
        path.reset();
        for(int j=0;j<count;j++){
            if(j==0){
                path.moveTo(centerX+curR,centerY);
            }else{
                float x = (float) (centerX+curR*Math.cos(angle*j));
                float y = (float) (centerY+curR*Math.sin(angle*j));
                path.lineTo(x,y);
            }
        }
        path.close();
        canvas.drawPath(path, mainPaint);
    }
}
项目:xwallet    文件:CameraView.java   
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (canvas == null) return;

    mPath.reset();

    mPath.addCircle(canvas.getWidth() / 2, canvas.getHeight() / 2, 550, Path.Direction.CW);
    mPath.setFillType(Path.FillType.INVERSE_EVEN_ODD);

    canvas.drawCircle(canvas.getWidth() / 2, canvas.getHeight() / 2, 550, mTransparentPaint);

    canvas.drawPath(mPath, mSemiBlackPaint);
    canvas.clipPath(mPath);
    canvas.drawColor(Color.parseColor("#A6000000"));
}
项目:RTLMaterialSpinner    文件:RtlMaterialSpinner.java   
private void initPaintObjects() {

        int labelTextSize = getResources().getDimensionPixelSize(R.dimen.label_text_size);

        paint = new Paint(Paint.ANTI_ALIAS_FLAG);

        textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
        textPaint.setTextSize(labelTextSize);
        if (typeface != null) {
            textPaint.setTypeface(typeface);
        }
        textPaint.setColor(baseColor);
        baseAlpha = textPaint.getAlpha();

        selectorPath = new Path();
        selectorPath.setFillType(Path.FillType.EVEN_ODD);

        selectorPoints = new Point[3];
        for (int i = 0; i < 3; i++) {
            selectorPoints[i] = new Point();
        }
    }
项目:atlas    文件:ShapeFill.java   
static ShapeFill newInstance(JSONObject json, LottieComposition composition) {
  AnimatableColorValue color = null;
  boolean fillEnabled;
  AnimatableIntegerValue opacity = null;

  JSONObject jsonColor = json.optJSONObject("c");
  if (jsonColor != null) {
    color = AnimatableColorValue.Factory.newInstance(jsonColor, composition);
  }

  JSONObject jsonOpacity = json.optJSONObject("o");
  if (jsonOpacity != null) {
    opacity = AnimatableIntegerValue.Factory.newInstance(jsonOpacity, composition);
  }
  fillEnabled = json.optBoolean("fillEnabled");

  int fillTypeInt = json.optInt("r", 1);
  Path.FillType fillType = fillTypeInt == 1 ? Path.FillType.WINDING : Path.FillType.EVEN_ODD;

  return new ShapeFill(fillEnabled, fillType, color, opacity);
}
项目:Material-Motion    文件:BaseFragment.java   
protected Path createArcPath(View view, float endX, float endY, float radius){
    Path arcPath=new Path();
    float startX=view.getTranslationX();
    float startY=view.getTranslationY();
    float midX = startX + ((endX - startX) / 2);
    float midY = startY + ((endY - startY) / 2);
    float xDiff = midX - startX;
    float yDiff = midY - startY;

    double angle = (Math.atan2(yDiff, xDiff) * (180 / Math.PI)) - 90;
    double angleRadians = Math.toRadians(angle);

    float pointX = (float) (midX + radius * Math.cos(angleRadians));
    float pointY = (float) (midY + radius * Math.sin(angleRadians));

    arcPath.moveTo(startX, startY);
    arcPath.cubicTo(startX,startY,pointX,pointY, endX, endY);
    return arcPath;
}
项目:PopupCircleMenu    文件:PopupLayer.java   
/**
 * 用来给每一个button设置一个中心点
 *
 * @param orbit 一个特定角度的path
 */
private void setPos(Path orbit) {
    PathMeasure measure = new PathMeasure(orbit, false);
    TextLableView tv;
    for (int i = 0; i < mButtons.size(); i++) {
        PopupButton pp = mButtons.get(i);
        tv = kvs.get(pp);
        float[] coords = new float[]{0f, 0f};
        int length = (int) ((i) * measure.getLength() / mButtons.size());
        measure.getPosTan(length, coords, null);
        int px = (int) coords[0] - pp.getMeasuredWidth() / 2;
        int py = (int) coords[1] - pp.getMeasuredHeight() / 2;
        int tvx = (int) coords[0] - tv.getMeasuredWidth() / 2;
        tv.x = tvx;
        tv.y = py - 60;
        pp.x = px;
        pp.y = py;
    }
}
项目:boohee_v5.6    文件:AnimCheckBox.java   
public AnimCheckBox(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.TAG = "AnimCheckBox";
    this.mPaint = new Paint(1);
    this.mRectF = new RectF();
    this.mInnerRectF = new RectF();
    this.mPath = new Path();
    this.mSin27 = Math.sin(Math.toRadians(27.0d));
    this.mSin63 = Math.sin(Math.toRadians(63.0d));
    this.mChecked = true;
    this.mInnerCircleAlpha = 255;
    this.mStrokeWidth = 2;
    this.mDuration = 500;
    this.mStrokeColor = -16776961;
    this.mCircleColor = -1;
    this.defaultSize = 40;
    this.mClickable = true;
    init(attrs);
}
项目:open-rmbt    文件:SimpleGraph.java   
private SimpleGraph(final int color, final long maxNsecs, final float width, final float height, final float strokeWidth)
{
    this.maxNsecs = maxNsecs;
    // this.width = width;
    this.height = height;
    nsecWidth = width / maxNsecs;

    paintStroke = new Paint();
    paintStroke.setColor(color);
    paintStroke.setAlpha(204); // 80%
    paintStroke.setStyle(Style.STROKE);
    paintStroke.setStrokeWidth(strokeWidth);
    paintStroke.setStrokeCap(Cap.ROUND);
    paintStroke.setStrokeJoin(Join.ROUND);
    paintStroke.setAntiAlias(true);

    paintFill = new Paint();
    paintFill.setColor(color);
    paintFill.setAlpha(51); // 20%
    paintFill.setStyle(Style.FILL);
    paintFill.setAntiAlias(true);

    pathStroke = new Path();
    pathFill = new Path();
}
项目:RNLearn_Project1    文件:DrawView.java   
/**
 * Update the path with which we'll clip this view
 */
private void updateClipPath() {
  mPath = new Path();

  TMP_RECT.set(
      getLeft(),
      getTop(),
      getRight(),
      getBottom());

  // set the path
  mPath.addRoundRect(
      TMP_RECT,
      mClipRadius,
      mClipRadius,
      Path.Direction.CW);
}
项目:GitHub    文件:LineRadarRenderer.java   
/**
 * Draws the provided path in filled mode with the provided drawable.
 *
 * @param c
 * @param filledPath
 * @param drawable
 */
protected void drawFilledPath(Canvas c, Path filledPath, Drawable drawable) {

    if (clipPathSupported()) {

        int save = c.save();
        c.clipPath(filledPath);

        drawable.setBounds((int) mViewPortHandler.contentLeft(),
                (int) mViewPortHandler.contentTop(),
                (int) mViewPortHandler.contentRight(),
                (int) mViewPortHandler.contentBottom());
        drawable.draw(c);

        c.restoreToCount(save);
    } else {
        throw new RuntimeException("Fill-drawables not (yet) supported below API level 18, " +
                "this code was run on API level " + Utils.getSDKInt() + ".");
    }
}
项目:android-slidr    文件:Slidr.java   
private void drawBubblePath(Canvas canvas, float triangleCenterX, float height, float width) {
    final Path path = new Path();

    int padding = 3;
    final Rect rect = new Rect(padding, padding, (int) width - padding, (int) (height - dpToPx(BUBBLE_ARROW_HEIGHT)) - padding);

    final float roundRectHeight = (height - dpToPx(BUBBLE_ARROW_HEIGHT)) / 2;

    path.moveTo(rect.left + roundRectHeight, rect.top);
    path.lineTo(rect.right - roundRectHeight, rect.top);
    path.quadTo(rect.right, rect.top, rect.right, rect.top + roundRectHeight);
    path.lineTo(rect.right, rect.bottom - roundRectHeight);
    path.quadTo(rect.right, rect.bottom, rect.right - roundRectHeight, rect.bottom);

    path.lineTo(triangleCenterX + dpToPx(BUBBLE_ARROW_WIDTH) / 2f, height - dpToPx(BUBBLE_ARROW_HEIGHT) - padding);
    path.lineTo(triangleCenterX, height - padding);
    path.lineTo(triangleCenterX - dpToPx(BUBBLE_ARROW_WIDTH) / 2f, height - dpToPx(BUBBLE_ARROW_HEIGHT) - padding);

    path.lineTo(rect.left + roundRectHeight, rect.bottom);
    path.quadTo(rect.left, rect.bottom, rect.left, rect.bottom - roundRectHeight);
    path.lineTo(rect.left, rect.top + roundRectHeight);
    path.quadTo(rect.left, rect.top, rect.left + roundRectHeight, rect.top);
    path.close();

    canvas.drawPath(path, settings.paintBubble);
}
项目:MyRepository    文件:RoundImageView.java   
@Override
protected void onDraw(Canvas canvas) {
    Log.e("TAG", "onDraw");
    if (getDrawable() == null) {
        return;
    }
    setUpShader();

    if (type == TYPE_ROUND) {
        canvas.drawRoundRect(mRoundRect, mBorderRadius, mBorderRadius,
                mBitmapPaint);
    } else if (type == TYPE_LEFT_ROUND) {
        float[] radii = {mBorderRadius, mBorderRadius, 0f, 0f, 0f, 0f, mBorderRadius, mBorderRadius};
        Path path = new Path();
        path.addRoundRect(mRoundRect, radii, Path.Direction.CW);
        canvas.drawPath(path, mBitmapPaint);
    } else {
        canvas.drawCircle(mRadius, mRadius, mRadius, mBitmapPaint);
        // drawSomeThing(canvas);
    }
}
项目:EasyChart    文件:EasyGraphLine.java   
private void init(int selectedBgColor, float pointStrokeWidth, int pathColor, float pathWidth) {
    pointPaint = new Paint();
    pointPaint.setAntiAlias(true);
    pointPaint.setColor(pointColor);
    pointPaint.setStrokeWidth(pointStrokeWidth);
    pointPaint.setStyle(Paint.Style.STROKE);
    pathPaint = new Paint();
    pathPaint.setAntiAlias(true);
    pathPaint.setColor(pathColor);
    pathPaint.setStrokeWidth(pathWidth);
    pathPaint.setStyle(Paint.Style.STROKE);
    selectedBgPaint = new Paint();
    selectedBgPaint.setAntiAlias(true);
    selectedBgPaint.setColor(selectedBgColor);
    selectedBgPaint.setStrokeWidth(0);
    selectedBgPaint.setStyle(Paint.Style.FILL);
    selectedBgPaint.setAlpha(100);
    path = new Path();
    pathDst = new Path();
    pm = new PathMeasure();
    rectOval = new RectF();
    selectedIndex = -1;
}
项目:atlas    文件:MergePathsContent.java   
@TargetApi(Build.VERSION_CODES.KITKAT)
private void mergePaths() {

  switch (mergePaths.getMode()) {
    case Merge:
      supportMergePaths();
      break;
    case Add:
      opFirstPathWithRest(Path.Op.UNION);
      break;
    case Subtract:
      opFirstPathWithRest(Path.Op.REVERSE_DIFFERENCE);
      break;
    case Intersect:
      opFirstPathWithRest(Path.Op.INTERSECT);
      break;
    case ExcludeIntersections:
      opFirstPathWithRest(Path.Op.XOR);
      break;
  }
}
项目:open-rmbt    文件:StaticGraph.java   
private StaticGraph(final int color, final float width, final float height, final float strokeWidth)
{
    this.height = height;
    this.width = width;

    pathStroke = new Path();
    pathFill = new Path();
    paintStroke = new Paint();
    paintFill = new Paint();

    paintStroke.setColor(color);
    paintStroke.setAlpha(204); // 80%
    paintStroke.setStyle(Style.STROKE);
    paintStroke.setStrokeWidth(strokeWidth);
    paintStroke.setStrokeCap(Cap.ROUND);
    paintStroke.setStrokeJoin(Join.ROUND);
    paintStroke.setAntiAlias(true);

    paintFill.setColor(color);
    paintFill.setAlpha(51); // 20%
    paintFill.setStyle(Style.FILL);
    paintFill.setAntiAlias(true);
}
项目:android-dev-challenge    文件:TrailedShape.java   
TrailedShape(float multiplier) {
    this.mMultiplier = multiplier;

    // Setup trail variables
    this.mTrailPath = new Path();
    this.mTrailList = new LinkedList<>();

    // Setup paint and attributes
    this.mPaint = new Paint();
    this.mTrailPaint = new Paint();

    mPaint.setStyle(Paint.Style.FILL);
    mTrailPaint.setStyle(Paint.Style.STROKE);
    mTrailPaint.setStrokeWidth(5);
    mTrailPaint.setStrokeJoin(Paint.Join.ROUND);
    mTrailPaint.setStrokeCap(Paint.Cap.ROUND);
}
项目:NovelReader    文件:SimulationPageAnim.java   
public SimulationPageAnim(int w, int h, View view, OnPageChangeListener listener) {
    super(w, h, view, listener);
    mPath0 = new Path();
    mPath1 = new Path();
    mMaxLength = (float) Math.hypot(mScreenWidth, mScreenHeight);
    mPaint = new Paint();

    mPaint.setStyle(Paint.Style.FILL);

    createDrawable();

    ColorMatrix cm = new ColorMatrix();//设置颜色数组
    float array[] = { 1, 0, 0, 0, 0,
            0, 1, 0, 0, 0,
            0, 0,1, 0, 0,
            0, 0, 0, 1, 0 };
    cm.set(array);
    mColorMatrixFilter = new ColorMatrixColorFilter(cm);
    mMatrix = new Matrix();

    mTouchX = 0.01f; // 不让x,y为0,否则在点计算时会有问题
    mTouchY = 0.01f;
}
项目:PlayerBase    文件:CornerCutView.java   
private void drawRightTop(Canvas canvas) {

        // 初始化数据点和控制点的位置
        start.x = mWidth - mCornerRadius;
        start.y = 0;
        end.x = mWidth;
        end.y = mCornerRadius;
        control.x = mWidth;
        control.y = 0;

        Path rightTop = new Path();
        rightTop.moveTo(mWidth,0);
        rightTop.lineTo(mWidth - mCornerRadius,0);
        rightTop.quadTo(control.x,control.y,end.x,end.y);
        rightTop.lineTo(mWidth,0);
        canvas.drawPath(rightTop,mPaint);
    }
项目:Mire    文件:PathBitmapMesh.java   
public void matchVertsToPath(Path path, float bottomCoord, float extraOffset) {
    PathMeasure pm = new PathMeasure(path, false);

    for (int i = 0; i < staticVerts.length / 2; i++) {

        float yIndexValue = staticVerts[i * 2 + 1];
        float xIndexValue = staticVerts[i * 2];


        float percentOffsetX = (0.000001f + xIndexValue) / bitmap.getWidth();
        float percentOffsetX2 = (0.000001f + xIndexValue) / (bitmap.getWidth() + extraOffset);
        percentOffsetX2 += pathOffsetPercent;
        pm.getPosTan(pm.getLength() * (1f - percentOffsetX), coords, null);
        pm.getPosTan(pm.getLength() * (1f - percentOffsetX2), coords2, null);

        if (yIndexValue == 0) {
            setXY(drawingVerts, i, coords[0], coords2[1]);
        } else {
            float desiredYCoord = bottomCoord;
            setXY(drawingVerts, i, coords[0], desiredYCoord);

        }
    }
}
项目:boohee_v5.6    文件:ColumnChartRenderer.java   
public void drawTargetCaloryLine(Canvas drawCanvas) {
    if (this.targetCalory > 0) {
        float currentLeft = 0.0f;
        float currentRight = 0.0f;
        int target = this.targetCalory;
        Viewport currentViewport = this.computator.getCurrentViewport();
        if (currentViewport != null) {
            currentLeft = currentViewport.left;
            currentRight = currentViewport.right;
        }
        float rawX1 = this.computator.computeRawX(currentLeft);
        float rawX2 = this.computator.computeRawX(currentRight);
        float y = this.computator.computeRawY((float) target);
        Path path1 = new Path();
        path1.moveTo(rawX1, y);
        path1.lineTo(rawX2, y);
        drawCanvas.drawPath(path1, this.caloryLinePaint);
    }
}
项目:ColumnAnimViewProject    文件:RadarView.java   
/**
 * 绘制区域
 * @param canvas
 */
private void drawRegion(Canvas canvas){
    Path path = new Path();
    valuePaint.setAlpha(255);
    for(int i=0;i<count;i++){
        double percent = data[i]/maxValue;
        float x = (float) (centerX+radius*Math.cos(angle*i)*percent);
        float y = (float) (centerY+radius*Math.sin(angle*i)*percent);
        if(i==0){
            path.moveTo(x, centerY);
        }else{
            path.lineTo(x,y);
        }
        //绘制小圆点
        canvas.drawCircle(x,y,10,valuePaint);
    }
    valuePaint.setStyle(Paint.Style.STROKE);
    canvas.drawPath(path, valuePaint);
    valuePaint.setAlpha(127);
    //绘制填充区域
    valuePaint.setStyle(Paint.Style.FILL_AND_STROKE);
    canvas.drawPath(path, valuePaint);
}
项目:GitHub    文件:GhostsEyeLoadingRenderer.java   
private Path createLeftEyeCircle(RectF arcBounds, float offsetY) {
    Path path = new Path();

    //the center of the left eye
    float leftEyeCenterX = arcBounds.centerX() - mEyeInterval / 2.0f - mEyeCircleRadius;
    float leftEyeCenterY = arcBounds.centerY() + offsetY;
    //the bounds of left eye
    RectF leftEyeBounds = new RectF(leftEyeCenterX - mEyeCircleRadius, leftEyeCenterY - mEyeCircleRadius,
            leftEyeCenterX + mEyeCircleRadius, leftEyeCenterY + mEyeCircleRadius);
    path.addArc(leftEyeBounds, 0, DEGREE_180 + 15);
    //the above radian of of the eye
    path.quadTo(leftEyeBounds.left + mAboveRadianEyeOffsetX, leftEyeBounds.top + mEyeCircleRadius * 0.2f,
            leftEyeBounds.left + mAboveRadianEyeOffsetX / 4.0f, leftEyeBounds.top - mEyeCircleRadius * 0.15f);

    return path;
}
项目:SphereLayout    文件:ElectricView.java   
public ElectricView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mPath = new Path();
    mRandom = new Random();
    mPaint = new Paint();
    mPaint.setColor(0xffffff8e);
    mPaint.setStrokeWidth(3);
    mPaint.setStyle(Paint.Style.STROKE);
    mMaxOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            getContext().getResources().getDisplayMetrics());
    mStartMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2,
            getContext().getResources().getDisplayMetrics());

    TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ElectricView);
    mElectricCount = typedArray.getInt(R.styleable.ElectricView_electricCount, 1);
    mStartFromRight = typedArray.getInt(R.styleable.ElectricView_startFrom, 0) == 1;
    mDegree = typedArray.getInt(R.styleable.ElectricView_degree, 0);
    typedArray.recycle();
}
项目:OneWeather    文件:Windmill.java   
private void drawWind(Canvas canvas) {
    mWindPath = new Path();
    canvas.drawCircle(mCenterPoint.x,mCenterPoint.y,width/40,mWindmillPaint);
    mWindPath.moveTo(x1,y1);
    x2 = mCenterPoint.x + (float) (r1 * Math.cos(rad1 + angle));
    y2 = mCenterPoint.y + (float) (r1 * Math.sin(rad1 + angle));
    x3 = mCenterPoint.x + (float) (r2 * Math.cos(rad2 + angle));
    y3 = mCenterPoint.y + (float) (r2 * Math.sin(rad2 + angle));
    x4 = mCenterPoint.x + (float) (r3 * Math.cos(rad3 + angle));
    y4 = mCenterPoint.y + (float) (r3 * Math.sin(rad3 + angle));
    x5 = mCenterPoint.x + (float) (r4 * Math.cos(rad4 + angle));
    y5 = mCenterPoint.y + (float) (r4 * Math.sin(rad4 + angle));


    mWindPath.cubicTo(x2,y2,x3,y3,x4,y4);
    mWindPath.quadTo(x5,y5,x1,y1);
    mWindPath.close();
    canvas.drawPath(mWindPath,mWindmillPaint);
    canvas.rotate(120,mCenterPoint.x,mCenterPoint.y);
    canvas.drawPath(mWindPath,mWindmillPaint);
    canvas.rotate(120,mCenterPoint.x,mCenterPoint.y);
    canvas.drawPath(mWindPath,mWindmillPaint);
    canvas.rotate(120,mCenterPoint.x,mCenterPoint.y);
}
项目:AOSP-Kayboard-7.1.2    文件:SetupStartIndicatorView.java   
@Override
protected void onDraw(final Canvas canvas) {
    super.onDraw(canvas);
    final int layoutDirection = ViewCompat.getLayoutDirection(this);
    final int width = getWidth();
    final int height = getHeight();
    final float halfHeight = height / 2.0f;
    final Path path = mIndicatorPath;
    path.rewind();
    if (layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL) {
        // Left arrow
        path.moveTo(width, 0.0f);
        path.lineTo(0.0f, halfHeight);
        path.lineTo(width, height);
    } else { // LAYOUT_DIRECTION_LTR
        // Right arrow
        path.moveTo(0.0f, 0.0f);
        path.lineTo(width, halfHeight);
        path.lineTo(0.0f, height);
    }
    path.close();
    final int[] stateSet = getDrawableState();
    final int color = mIndicatorColor.getColorForState(stateSet, 0);
    mIndicatorPaint.setColor(color);
    canvas.drawPath(path, mIndicatorPaint);
}
项目:GitHub    文件:BGAMoocStyleRefreshView.java   
private void initCanvas() {
    mOriginalBitmapWidth = mOriginalBitmap.getWidth();
    mOriginalBitmapHeight = mOriginalBitmap.getHeight();

    // 初始状态值
    mWaveOriginalY = mOriginalBitmapHeight;
    mWaveY = 1.2f * mWaveOriginalY;
    mBezierControlOriginalY = 1.25f * mWaveOriginalY;
    mBezierControlY = mBezierControlOriginalY;

    mXfermode = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN);
    mBezierPath = new Path();

    mCanvas = new Canvas();
    mUltimateBitmap = Bitmap.createBitmap(mOriginalBitmapWidth, mOriginalBitmapHeight, Config.ARGB_8888);
    mCanvas.setBitmap(mUltimateBitmap);
}
项目:Android-Code-Demos    文件:SpiderNetView.java   
private void drawPointsAndFill(Canvas canvas) {
    Path path = new Path();

    path.moveTo(mUnitPointFs[0].x * mOffsets[0] / 100 * mNetLength,
            mUnitPointFs[0].y * mOffsets[0] / 100 * mNetLength);

    for (int i = 0; i < mUnitPointFs.length; i++) {
        /* draw point */
        canvas.drawPoint(mUnitPointFs[i].x * mOffsets[i] / 100 * mNetLength,
                mUnitPointFs[i].y * mOffsets[i] / 100 * mNetLength,
                mPointPaint);
        /* draw line */
        if (i + 1 != mUnitPointFs.length) {
            path.lineTo(mUnitPointFs[i + 1].x * mOffsets[i + 1] / 100 * mNetLength,
                    mUnitPointFs[i + 1].y * mOffsets[i + 1] / 100 * mNetLength);
        } else {
           path.lineTo(mUnitPointFs[0].x * mOffsets[0] / 100 * mNetLength,
                   mUnitPointFs[0].y * mOffsets[0] / 100 * mNetLength);
        }

    }
    path.close();
    canvas.drawPath(path, mFillPaint);
}
项目:miaosou    文件:BounceBallView.java   
private void initData() {

        defaultPadding = 2 * radius + dp2px(2);
        defaultPaddingBottom = 2 * radius + dp2px(15);
        defaultWidth = (int) (2 * defaultPadding + dp2px(200));
        defaultHeight = (int) (defaultPadding + defaultPaddingBottom + dp2px(80));

        paint = new Paint[ballCount];
        for (int i = 0; i < paint.length; i++) {
            paint[i] = new Paint(Paint.ANTI_ALIAS_FLAG);
            paint[i].setColor(ballColor);
            paint[i].setStyle(Paint.Style.FILL);
        }

        path = new Path();
        pathMeasure = new PathMeasure();
        randomBallColors = new int[ballCount];
        randomRadius = new float[ballCount];
        randomTransRatioX = new float[ballCount];
        randomTransRatioY = new float[ballCount];

        translateFraction = new float[ballCount];
        translateAnim = new ValueAnimator[ballCount];

    }
项目:Depth    文件:CircularSplashView.java   
public Bitmap GetBitmapClippedCircle(Bitmap bitmap) {

            final int width = bitmap.getWidth();
            final int height = bitmap.getHeight();
            final Bitmap outputBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

            final Path path = new Path();
            path.addCircle(
                    (float) (width / 2)
                    , (float) (height / 2)
                    , (float) Math.min(width, (height / 2))
                    , Path.Direction.CCW);

            final Canvas canvas = new Canvas(outputBitmap);
            canvas.clipPath(path);
            canvas.drawBitmap(bitmap, 0, 0, null);
            bitmap.recycle();
            return outputBitmap;
        }
项目:Musicoco    文件:MarkerDrawable.java   
private void computePath(Rect bounds) {
    final float currentScale = mCurrentScale;
    final Path path = mPath;
    final RectF rect = mRect;
    final Matrix matrix = mMatrix;

    path.reset();
    int totalSize = Math.min(bounds.width(), bounds.height());

    float initial = mClosedStateSize;
    float destination = totalSize;
    float currentSize = initial + (destination - initial) * currentScale;

    float halfSize = currentSize / 2f;
    float inverseScale = 1f - currentScale;
    float cornerSize = halfSize * inverseScale;
    float[] corners = new float[]{halfSize, halfSize, halfSize, halfSize, halfSize, halfSize, cornerSize, cornerSize};
    rect.set(bounds.left, bounds.top, bounds.left + currentSize, bounds.top + currentSize);
    path.addRoundRect(rect, corners, Path.Direction.CCW);
    matrix.reset();
    matrix.postRotate(-45, bounds.left + halfSize, bounds.top + halfSize);
    matrix.postTranslate((bounds.width() - currentSize) / 2, 0);
    float hDiff = (bounds.bottom - currentSize - mExternalOffset) * inverseScale;
    matrix.postTranslate(0, hDiff);
    path.transform(matrix);
}
项目:SmartRefresh    文件:MaterialHeader.java   
private void initView(Context context, AttributeSet attrs) {
    setMinimumHeight(DensityUtil.dp2px(100));

    mProgress = new MaterialProgressDrawable(context, this);
    mProgress.setBackgroundColor(CIRCLE_BG_LIGHT);
    mProgress.setAlpha(255);
    mProgress.setColorSchemeColors(0xff0099cc,0xffff4444,0xff669900,0xffaa66cc,0xffff8800);
    mCircleView = new CircleImageView(context,CIRCLE_BG_LIGHT);
    mCircleView.setImageDrawable(mProgress);
    mCircleView.setVisibility(View.GONE);
    addView(mCircleView);

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mCircleDiameter = (int) (CIRCLE_DIAMETER * metrics.density);

    mBezierPath = new Path();
    mBezierPaint = new Paint();
    mBezierPaint.setAntiAlias(true);
    mBezierPaint.setStyle(Paint.Style.FILL);

    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.MaterialHeader);
    mShowBezierWave = ta.getBoolean(R.styleable.MaterialHeader_mhShowBezierWave, mShowBezierWave);
    mBezierPaint.setColor(ta.getColor(R.styleable.MaterialHeader_mhPrimaryColor, 0xff11bbff));
    if (ta.hasValue(R.styleable.MaterialHeader_mhShadowRadius)) {
        int radius = ta.getDimensionPixelOffset(R.styleable.MaterialHeader_mhShadowRadius, 0);
        int color = ta.getColor(R.styleable.MaterialHeader_mhShadowColor, 0xff000000);
        mBezierPaint.setShadowLayer(radius, 0, 0, color);
        setLayerType(LAYER_TYPE_SOFTWARE, null);
    }
    ta.recycle();

}
项目:LaunchEnr    文件:IconNormalizer.java   
/**
 * Returns if the shape of the icon is same as the path.
 * For this method to work, the shape path bounds should be in [0,1]x[0,1] bounds.
 */
private boolean isShape(Path maskPath) {
    // Condition1:
    // If width and height of the path not close to a square, then the icon shape is
    // not same as the mask shape.
    float iconRatio = ((float) mBounds.width()) / mBounds.height();
    if (Math.abs(iconRatio - 1) > BOUND_RATIO_MARGIN) {
        return false;
    }

    // Condition 2:
    // Actual icon (white) and the fitted shape (e.g., circle)(red) XOR operation
    // should generate transparent image, if the actual icon is equivalent to the shape.
    mFileId = mRandom.nextInt();
    mBitmapARGB.eraseColor(Color.TRANSPARENT);
    mCanvasARGB.drawBitmap(mBitmap, 0, 0, mPaintIcon);

    // Fit the shape within the icon's bounding box
    mMatrix.reset();
    mMatrix.setScale(mBounds.width(), mBounds.height());
    mMatrix.postTranslate(mBounds.left, mBounds.top);
    maskPath.transform(mMatrix);

    // XOR operation
    mCanvasARGB.drawPath(maskPath, mPaintMaskShape);

    // DST_OUT operation around the mask path outline
    mCanvasARGB.drawPath(maskPath, mPaintMaskShapeOutline);

    boolean isTrans = isTransparentBitmap(mBitmapARGB);

    // Check if the result is almost transparent
    if (!isTrans) {
        return false;
    }
    return true;
}
项目:Sprog-App    文件:FastScrollPopup.java   
public void draw(Canvas canvas) {
    if (isVisible()) {
        // Draw the fast scroller popup
        int restoreCount = canvas.save(Canvas.MATRIX_SAVE_FLAG);
        canvas.translate(mBgBounds.left, mBgBounds.top);
        mTmpRect.set(mBgBounds);
        mTmpRect.offsetTo(0, 0);

        mBackgroundPath.reset();
        mBackgroundRect.set(mTmpRect);

        float[] radii;

        if (Utils.isRtl(mRes)) {
            radii = new float[]{mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius, 0, 0};
        } else {

            radii = new float[]{mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius, 0, 0, mCornerRadius, mCornerRadius};
        }

        mBackgroundPath.addRoundRect(mBackgroundRect, radii, Path.Direction.CW);

        mBackgroundPaint.setAlpha((int) (mAlpha * 255));
        mTextPaint.setAlpha((int) (mAlpha * 255));
        canvas.drawPath(mBackgroundPath, mBackgroundPaint);
        canvas.drawText(mSectionName, (mBgBounds.width() - mTextBounds.width()) / 2,
                mBgBounds.height() - (mBgBounds.height() - mTextBounds.height()) / 2,
                mTextPaint);
        canvas.restoreToCount(restoreCount);
    }
}
项目:MySelfDemo    文件:MyView2.java   
/**
 * 用 path 拼接的时候  moveTo 这个参数
 *
 * @param canvas
 */
private void drawPaht4(Canvas canvas) {
    Paint paint = new Paint();
    paint.setColor(Color.BLUE);
    paint.setStyle(Paint.Style.STROKE);
    paint.setAntiAlias(true);
    Path path = new Path();
    path.lineTo(100, 100);
    path.moveTo(200, 100);  //此为移动到某个点上去  用 moveTo可以移动起始点  =此过程不会绘制图形,不过会移动点
    path.lineTo(200, 0);   // lineTo 都是想对于上个点来说的
    canvas.drawPath(path, paint);
}
项目:Vorolay    文件:VoronoiRegion.java   
private void initPath() {
    path = new Path();

    for (int i = 0; i < points.size(); i++) {
        VoronoiPoint point = points.get(i);
        if (i == 0) {
            path.moveTo((float)point.x, (float)point.y);
            continue;
        }
        path.lineTo((float)point.x, (float)point.y);
    }

    path.close();
}
项目:https-github.com-hyb1996-NoRootScriptDroid    文件:GlobalActionAutomator.java   
private Path pointsToPath(int[][] points) {
    Path path = new Path();
    path.moveTo(scaleX(points[0][0]), scaleY(points[0][1]));
    for (int i = 1; i < points.length; i++) {
        int[] point = points[i];
        path.lineTo(scaleX(point[0]), scaleY(point[1]));
    }
    return path;
}