|
@@ -17,6 +17,8 @@ |
|
|
private ArrayList<Path> paths = new ArrayList<>(); |
|
|
private ArrayList<Integer> colors = new ArrayList<>(); |
|
|
private int currentColor = 0xFF000000; |
|
|
private ArrayList<Integer> widths = new ArrayList<>(); |
|
|
private int currentWidth = 6; |
|
|
|
|
|
public DrawingView(Context context) { |
|
|
super(context); |
|
@@ -38,6 +40,7 @@ public DrawingView(Context context, @Nullable AttributeSet attrs, int defStyleAt |
|
|
public void addPath(Path path) { |
|
|
paths.add(path); |
|
|
colors.add(currentColor); |
|
|
widths.add(currentWidth); |
|
|
} |
|
|
|
|
|
public Path getLastPath() { |
|
@@ -57,7 +60,7 @@ protected void onDraw(Canvas canvas) { |
|
|
Paint paint = new Paint(); |
|
|
paint.setColor(colors.get(i)); |
|
|
paint.setStyle(Paint.Style.STROKE); |
|
|
paint.setStrokeWidth(3f); |
|
|
paint.setStrokeWidth(widths.get(i)); |
|
|
canvas.drawPath(path, paint); |
|
|
i++; |
|
|
} |
|
@@ -66,4 +69,8 @@ protected void onDraw(Canvas canvas) { |
|
|
public void setCurrentColor(int color) { |
|
|
currentColor = color; |
|
|
} |
|
|
|
|
|
public void setCurrentWidth(int width) { |
|
|
currentWidth = (width + 1) * 2; |
|
|
} |
|
|
} |