Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.8k views
in Technique[技术] by (71.8m points)

java - How to draw part of ring (arc) using canvas in android?

I am trying to find a way to make arc of the ring. There are the same question, but it was about full ring:

How to draw a ring using canvas in android?

But what do you think how can we make it more abstract?

Now I have something for r1 as outside radius and r2 as inside radius; x and y as the center of the arc; start and end angles as is.

int r1=100;
int r2=80;
int x=200;
int y=200;
int start=0;
int end=90;
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(r1-r2);
canvas.drawArc(new RectF(x-r1, y-r1, x+r1, y+r1), start, end, true, paint);

It makes figure with extra lines from the center, and I don't know how to remove it. I provided the result with indifferent background just to make you see the bounds of canvas and transparency inside the figure.

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...