我知道这是一个愚蠢的问题,但我正在阅读一个教程,我似乎不理解下面的代码行......已经理解了这背后的几何算法,但是......哦! !!这很简单,但我似乎不明白。请帮助....我是初学者...
private void drawPict(Canvas canvas, int x, int y, int w, int h,
float sx, float sy) {
canvas.save();
canvas.translate(x, y);
canvas.clipRect(0, 0, w, h);
canvas.scale(0.5f, 0.5f);
canvas.scale(sx, sy, w, h);
canvas.drawPicture(mPicture);
canvas.restore();
}
@SuppressWarnings("unused")
@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(mPicture.beginRecording(getWidth(), getHeight()));
mPicture.endRecording();
int x = getWidth()/2;
int y = getHeight()/2;
if (false) {
canvas.drawPicture(mPicture);
} else {
drawPict(canvas, 0, 0, x, y, 1, 1);
drawPict(canvas, x, 0, x, y, -1, 1);
drawPict(canvas, 0, y, x, y, 1, -1);
drawPict(canvas, x, y, x, y, -1, -1);
}
}
我再次对此进行了研究...并了解canvas.scale有4个参数,它们是我假设的点的坐标...但我仍然无法理解float sx,float sy ...
sx=-1 和 sy=1...它会扩展,同意...但是没有更好的方法吗?