绘制一个动态部分填充的圆 [英] Draw a circle partially filled dynamically

查看:182
本文介绍了绘制一个动态部分填充的圆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用画布。我可以绘制一些三角形并填充它部分绘制路径并绘制它。我使用了路径,点和线。记住三角学是一个很好的练习。现在我想用圆圈做同样的事情,如下所示。我想设置一个百分比并填充这个圆圈直到圆的高度*百分比。我怎么能用画布或者一些lib绘制一个圆圈?

I'm trying to play with canvas. I could draw some triangles and fill it partially drawing a path and paint it.I used Path, Points and Line. It was a great exercise to remember trigonometry. For now I would like to do the same with a circle, as you can see below. I want set a percentage and to fill this circle until the circle's height * percentage. How could me draw a circle like that with canvas or some lib?

推荐答案

您应该稍微考虑一下。我这样做的方法是绘制一个彩色矩形(高度是圆的预期高度的百分比),然后用圆圈裁剪。 这个答案解释了如何裁剪圆形图像(I我宁愿链接而不是在这里重新输入代码。)

You should think about it a little differently. The way I'd do it is to draw a coloured rectangle (where the height is a percentage of the circle's intended height) and then crop it with a circle. This answer explains how to crop an image in a circular shape (I'd rather link than retype the code here).

这篇关于绘制一个动态部分填充的圆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆