Flutter:在画布上旋转图像并指定枢轴点

我是个初学者。此代码旋转画布上的图像,但枢轴点位于中心。如何指定旋转的枢轴点?谢谢。

Size imageSize = new Size(image.width.toDouble(),image.height.toDouble());
Size targetSize = imageSize * scale;

final double thewidth = image.width.toDouble();

final double theheight = image.height.toDouble();
final double r = (sqrt(thewidth * thewidth + theheight * theheight) / 2) * scale;

final alpha = atan(theheight / thewidth);
final beta = alpha + angle;
final shiftX = (r * cos(beta));
final shiftY = (r * sin(beta));

canvas.save();

canvas.translate(offset.dx - shiftX,offset.dy - shiftY);

canvas.rotate(angle);

paintImage(canvas: canvas,rect: Offset(0,0) & targetSize,image: image,fit: BoxFit.fill,filterQuality: FilterQuality.high);

canvas.restore();
linzichao 回答:Flutter:在画布上旋转图像并指定枢轴点

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3102707.html

大家都在问