GraphicsPath.Transform(Matrix) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将变换矩阵应用到此 GraphicsPath。
public:
void Transform(System::Drawing::Drawing2D::Matrix ^ matrix);
public void Transform (System.Drawing.Drawing2D.Matrix matrix);
member this.Transform : System.Drawing.Drawing2D.Matrix -> unit
Public Sub Transform (matrix As Matrix)
参数
示例
下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse
事件OnPaint对象。 此代码执行以下操作:
创建一个路径,并向该路径添加一个椭圆。
绘制屏幕的路径。
创建一个转换矩阵,以在 x 轴方向平移路径 100 个单位。
绘制到屏幕的转换路径。
请注意,原始椭圆以黑色绘制,转换后的椭圆以红色绘制。
private:
void TransformExample( PaintEventArgs^ e )
{
// Create a path and add and ellipse.
GraphicsPath^ myPath = gcnew GraphicsPath;
myPath->AddEllipse( 0, 0, 100, 200 );
// Draw the starting position to screen.
e->Graphics->DrawPath( Pens::Black, myPath );
// Move the ellipse 100 points to the right.
Matrix^ translateMatrix = gcnew Matrix;
translateMatrix->Translate( 100, 0 );
myPath->Transform(translateMatrix);
// Draw the transformed ellipse to the screen.
e->Graphics->DrawPath( gcnew Pen( Color::Red,2.0f ), myPath );
}
private void TransformExample(PaintEventArgs e)
{
// Create a path and add and ellipse.
GraphicsPath myPath = new GraphicsPath();
myPath.AddEllipse(0, 0, 100, 200);
// Draw the starting position to screen.
e.Graphics.DrawPath(Pens.Black, myPath);
// Move the ellipse 100 points to the right.
Matrix translateMatrix = new Matrix();
translateMatrix.Translate(100, 0);
myPath.Transform(translateMatrix);
// Draw the transformed ellipse to the screen.
e.Graphics.DrawPath(new Pen(Color.Red, 2), myPath);
}
Public Sub TransformExample(ByVal e As PaintEventArgs)
' Create a path and add and ellipse.
Dim myPath As New GraphicsPath
myPath.AddEllipse(0, 0, 100, 200)
' Draw the starting position to screen.
e.Graphics.DrawPath(Pens.Black, myPath)
' Move the ellipse 100 points to the right.
Dim translateMatrix As New Matrix
translateMatrix.Translate(100, 0)
myPath.Transform(translateMatrix)
' Draw the transformed ellipse to the screen.
e.Graphics.DrawPath(New Pen(Color.Red, 2), myPath)
End Sub
注解
转换可以缩放、平移、旋转或倾斜 GraphicsPath。
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈