繁体   English   中英

如何在弧形顶部绘制位图图像

[英]How to draw bitmap image on top in arc

我想在每个画布弧中的顶部绘制图像

 private void drawImage(Canvas canvas, float tempAngle, Bitmap bitmap,String mValue) {
    //get every arc img width and angle
    int imgWidth = (radius / mWheelItems.size());
    //int imgWidth = (radius / 3);
    float angle = (float) ((tempAngle + 360 / mWheelItems.size() /2) * Math.PI / 180);
    //calculate x and y
    int x = (int) (center + radius / 2 / 2 * Math.cos(angle));
    int y = (int) (center + radius / 2 / 2 * Math.sin(angle));

    int top=y - imgWidth/2;
    int bottom=y +imgWidth/2;

    int left=x - imgWidth /2;
    int right=x + imgWidth / 2;

        Rect rect = new Rect(left, top, right, bottom);

                final Rect rect1 = new Rect(x - imgWidth /2 , y - imgWidth / 2  , bitmap.getWidth() , bitmap.getHeight());

   canvas.drawBitmap(bitmap, null, rect, null);
}

弧是根据物品的大小制成的

结果显示如下

在此处输入图片说明

但是我想要像rect一样在顶部显示图像位图。 红色也要大尺寸的图像或位图

在此处输入图片说明

通过特定的选项卡和大屏幕平板电脑解决

根据角度更改X和Y坐标

if(tempAngle==0) {
        x = x + 50;
    }

    if(tempAngle==60) {
        y = y + 50;
    }
    if(tempAngle==120) {

        imgWidth = imgWidth-12;
        y = y + 20;
        x = x - 40;
    }
    if(tempAngle==180) {
        imgWidth = imgWidth+12;
        x = x - 50;
    }
    if(tempAngle==240) {
        y = y - 50;
    }
    if(tempAngle==300) {
        y = y - 20;
        x = x + 40;
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM