Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 计算canvas.scale()后的边界框_Android_Scale_Bounds_Bounding Box - Fatal编程技术网

Android 计算canvas.scale()后的边界框

Android 计算canvas.scale()后的边界框,android,scale,bounds,bounding-box,Android,Scale,Bounds,Bounding Box,我的Android应用程序可以绘制多个圆圈,如下所示: 用户还可以拖动圆并缩放它们。在缩放方面,我使用了: canvas.save(); canvas.scale(this.scaleFactor, this.scaleFactor, this.centerX, this.centerY); // draw main circle canvas.drawCircle(this.centerX, this.centerY, this.radius, this.outerCirc

我的Android应用程序可以绘制多个圆圈,如下所示:

用户还可以拖动圆并缩放它们。在缩放方面,我使用了:

canvas.save();
   canvas.scale(this.scaleFactor, this.scaleFactor, this.centerX, this.centerY);
   // draw main circle
   canvas.drawCircle(this.centerX, this.centerY, this.radius, this.outerCirclePaint);
   ...
一切都很好,除了圆圈周围每个文本的边界框。每个文本都应该是可触摸的,并且不在canvas.scale之后。因此,我还尝试用不同的方法和不同的结果缩放边界框。 当我只乘以框的左、上、右、下时,只有当圆心在0,0时,文本才可触摸。所以我不知道为什么它被翻译成0,0

txtBounds.set(txtBounds.left * this.scaleFactor, txtBounds.top * this.scaleFactor, txtBounds.right * this.scaleFactor, txtBounds.bottom * this.scaleFactor);
当我用一个矩阵来缩放盒子时,盒子看起来是正常的,但它不再是可触摸的了

matrixBounds.setScale(this.scaleFactor, this.scaleFactor, txtBounds.centerX(), txtBounds.centerY());
这个方框也可以翻译成她的观点。 有什么想法吗?如果需要,我还可以发布更多的源代码