旋转变换如何工作?我可以改变它旋转的矩形上的点吗?
How does RotateTransform work? Can I change the point on the rectangle where it rotates?
我不明白 RenderTransform 偏移量的工作原理。我想围绕一个点旋转一个矩形。具体来说,我希望矩形围绕宽度的一半的点旋转。这是一个截图:
代码如下:
RotateTransform rotateTransform1 = new RotateTransform(angle, 0 , 0 );
myRectangle.RenderTransform = rotateTransform1;
我尝试了不同的值来替换 0(例如宽度 / 2)。这似乎改变了屏幕上旋转中心的位置。我需要改变的是它旋转的矩形的哪一部分。具体来说,我希望矩形围绕其宽度中间的点旋转。
是否可以调整旋转矩形的点?
RenderTransformOrigin has a somewhat nonstandard use of the Point structure value, in that the Point does not represent an absolute location in a coordinate system. Instead, values between 0 and 1 are interpreted as a factor for the range of the current element in each x,y axis. For example, (0.5,0.5) will cause the render transform to be centered on the element, or (1,1) would place the render transform at the bottom right corner of the element.
myRectangle.RenderTransformOrigin = new Point(0.5,0.5);
myRectangle.RenderTransform = rotateTransform1;
我不明白 RenderTransform 偏移量的工作原理。我想围绕一个点旋转一个矩形。具体来说,我希望矩形围绕宽度的一半的点旋转。这是一个截图:
代码如下:
RotateTransform rotateTransform1 = new RotateTransform(angle, 0 , 0 );
myRectangle.RenderTransform = rotateTransform1;
我尝试了不同的值来替换 0(例如宽度 / 2)。这似乎改变了屏幕上旋转中心的位置。我需要改变的是它旋转的矩形的哪一部分。具体来说,我希望矩形围绕其宽度中间的点旋转。
是否可以调整旋转矩形的点?
RenderTransformOrigin has a somewhat nonstandard use of the Point structure value, in that the Point does not represent an absolute location in a coordinate system. Instead, values between 0 and 1 are interpreted as a factor for the range of the current element in each x,y axis. For example, (0.5,0.5) will cause the render transform to be centered on the element, or (1,1) would place the render transform at the bottom right corner of the element.
myRectangle.RenderTransformOrigin = new Point(0.5,0.5);
myRectangle.RenderTransform = rotateTransform1;