我是个初学者。此代码旋转画布上的图像,但枢轴点位于中心。如何指定旋转的枢轴点?谢谢。
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();