zoukankan      html  css  js  c++  java
  • 左右canvas.drawArc,canvas.drawOval 和RectF 关联

    1.paint.setStyle(Paint.Style.STROKE)

    //    radius="100dp"
    //    interRadius="40dp"
    //    linearWidth="10dp"
    //    stokenWidth="40dp"


            mPaint=new Paint();
            mPaint.setStyle(Paint.Style.STROKE);
            mPaint.setStrokeWidth(mStokenWidth);
            mPaint.setColor(Color.BLUE);
            mPaint.setAntiAlias(true);
    
            mPaint2=new Paint();
            mPaint2.setStyle(Paint.Style.STROKE);
            mPaint2.setColor(Color.BLACK);
    
            int left=mStokenWidth/2;
            int top=mStokenWidth/2;
            mRectF=new RectF();
            mRectF.left=left;
            mRectF.top=top;
            mRectF.right=(mRadius-left)*2;
            mRectF.bottom=(mRadius-top)*2;

    onDraw

        @Override
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            canvas.drawArc(mRectF, 0, 90, false, mPaint);
            mPaint.setColor(Color.RED);
            canvas.drawArc(mRectF, 90, 90, false, mPaint);
            mPaint.setColor(Color.YELLOW);
            canvas.drawArc(mRectF, 180, 90, false, mPaint);
            mPaint.setColor(Color.GRAY);
            canvas.drawArc(mRectF, 270, 90, false, mPaint);
            canvas.drawRect(mRectF,mPaint2);
        }


    如图:


    2.paint.setStyle(Paint.Style.FILL)

    效果例如以下


    RectF画的矩形刚好成为了扇形的外切矩形

    说明当style 为stoken 的时候。rectf画出的举行每条边刚好在描边的中间

    什么时候style至Fill什么时候,rect外整个图形长方形切割

    版权声明:本文博主原创文章,博客,未经同意不得转载。

  • 相关阅读:
    App测试总脚本1.30.py
    adb安装中的platform-tools文件的生成问题
    App测试总脚本1.20
    App测试总脚本1.10(使用了列表推导式)
    APP网络测试要点和弱网模拟
    算法1—冒泡排序
    三次握手和四次挥手
    测试基础总结
    四道题设计用例
    使用复杂条件下的if选择结构
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/4869890.html
Copyright © 2011-2022 走看看