在Arc中心绘制位图? [英] Draw a Bitmap in Arc center?

查看:99
本文介绍了在Arc中心绘制位图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在自定义视图"中,我绘制了多个填充的Arc,如下所示:

In my Custom View, I draw multiple filled Arcs like this:

canvas.drawArc(oval, startAngle, sweepAngle, true, sectorPaint);

现在,我想在弧的中心绘制一个图标.我从这里开始:

Now, I want to draw an icon on the center of the Arc. I started with this:

Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.my_icon);
canvas.drawBitmap(bitmap, pointX, pointY, null); //pointX & pointY ??

但是,我不知道应该为pointXpointY设置什么.这是我的数据:

However, I don't know what should I set for pointX and pointY. Here is the data I have:

  • 椭圆中心坐标和半径.
  • startAngle和sweepAngle(因此可以派生endAngle)

是否有办法知道给出这些输入的值pointXpointY?

Is there a way to know the values pointX and pointY giving those inputs?

插图草图:

推荐答案

此答案经过一些调整后对我有很大帮助:

This answer helped me a lot after some adjustments:

double radius = width/2;
double x = radius + (radius)*Math.cos(-angle);
double y = radius + (radius)*Math.sin(-angle);

这篇关于在Arc中心绘制位图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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