标签:自己实现 枚举类型 parse str 风格 文字 direct type dir
根据 Hencoder 提供的知识点,进行学习和总结。
* canvas.drawColor(Color.RED);
* canvas.drawColor(Color.parseColor("#00ff00"));
* canvas.drawColor(Color.parseColor("#8800ff00"));
* canvas.drawRGB(255, 0, 0);
* canvas.drawARGB(100, 255, 0, 0);
1. 实心圆:
mPaint = new Paint();
canvas.drawCircle(100, 100, 50, mPaint);
2. 空心圆
mPaint.setStyle(Style.STROKE);
canvas.drawCircle(200, 200, 50, mPaint);
3. 蓝色实心圆
mPaint.setStyle(Style.FILL);
mPaint.setColor(Color.BLUE);
canvas.drawCircle(200, 400, 50, mPaint);
4. 线宽为20的空心圆
mPaint.setStyle(Style.STROKE);
mPaint.setStrokeWidth(20);
canvas.drawCircle(400, 200, 50, mPaint);
canvas.drawOval(300, 100, 700, 300, mPaint);
canvas.drawRect(250, 500, 700, 800, mPaint);
//
Rect tem1 = new Rect(250, 500, 700, 800);
canvas.drawRect(tem1, mPaint);
//
RectF tem2 = new RectF(250, 500, 700, 800);
canvas.drawRect(tem2, mPaint);
RectF t = new RectF(150, 200, 500, 350);
canvas.drawRoundRect(t, 50, 50, mPaint);
//
canvas.drawRoundRect(150, 200, 500, 350, 50, 50, mPaint);
drawArc(float left, float top, float right, float bottom, float startAngle,float sweepAngle, boolean useCenter, Paint paint)
* left,top,right,bottom:弧形所在的椭圆
* startAngle:弧形的起始角度(x 轴的正向,即正右的方向,0度的位置。顺时针为正角度,逆时针为负角度)
* sweepAngle:弧形划过的角度
* useCenter:表示十分连接圆心,连接圆心是扇形
,不连接圆心是弧形
绘制弧形
canvas.drawArc(200, 600, 800, 1000, 0, 47, false, mPaint);
绘制扇形
canvas.drawArc(200, 600, 800, 1000, 0, 135, true, mPaint);
示例:
mPaint.setAntiAlias(true);
mPaint.setStyle(Style.FILL);
canvas.drawArc(200, 100, 800, 500, -110, 100, true, mPaint); // 绘制扇形
canvas.drawArc(200, 100, 800, 500, 20, 140, false, mPaint); // 绘制弧形
mPaint.setStyle(Paint.Style.STROKE); // 画线模式
canvas.drawArc(200, 100, 800, 500, 180, 60, false, mPaint); // 绘制不封口的弧形
paint:
标签:自己实现 枚举类型 parse str 风格 文字 direct type dir
原文地址:https://www.cnblogs.com/liyiran/p/8783150.html