-
Notifications
You must be signed in to change notification settings - Fork 2
/
Practice11StrokeMiterView.java
59 lines (45 loc) · 1.43 KB
/
Practice11StrokeMiterView.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package com.geekholt.practiceui.view.lesson2;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.view.View;
import androidx.annotation.Nullable;
public class Practice11StrokeMiterView extends View {
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
Path path = new Path();
public Practice11StrokeMiterView(Context context) {
super(context);
}
public Practice11StrokeMiterView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public Practice11StrokeMiterView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
{
paint.setStrokeWidth(40);
paint.setStyle(Paint.Style.STROKE);
path.rLineTo(200, 0);
path.rLineTo(-160, 120);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.save();
canvas.translate(100, 100);
// MITER 值:1
paint.setStrokeMiter(1);
canvas.drawPath(path, paint);
canvas.translate(300, 0);
// MITER 值:2
paint.setStrokeMiter(2);
canvas.drawPath(path, paint);
canvas.translate(300, 0);
// MITER 值:5
paint.setStrokeMiter(5);
canvas.drawPath(path, paint);
canvas.restore();
}
}