在canvas.scale()之后计算边界框

时间:2013-06-14 13:48:11

标签: android scale bounds bounding-box

我的Android Applikation可以像这样绘制多个圈子: enter image description here

用户还可以拖动圆圈并缩放它们。谈到缩放我用过:

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());

该框也可能被翻译为antoher点。 有任何想法吗?如果需要,我还可以发布更多源代码。

0 个答案:

没有答案
相关问题