首页 > 学院 > 开发设计 > 正文

C# 矩阵变换Matrix

2019-11-08 01:12:27
字体:
来源:转载
供稿:网友
1、Matrix matrix = new Matrix();2、matrix.Translate( offsetX, offsetY ); //Where offset is the new location3、path.Transform( matrix ); //Transform the path

4、redraw the path via Invalidate()

数学家们将其统一为一个3*3矩阵,存储形式如下:

由于表示仿射变换的矩阵的第三列总是(0,0,1),在存储矩阵的时候,大多只存成一个2*3的数组。

System.Drawing.Graphics   //画布System.Drawing.Drawing2D.GraphicsPath   //画图路径,也就是在图上显示的线System.Drawing.Drawing2D.Matrix  //图像缩放对象

//g为Graphics对象 path为GraphicsPath对象path.AddLine(Point1, Point2);  //在两点间添加一条直线path.AddArc(x,y,width,height,startAngle,sweepAngle); //添加弧线path.AddPie(x,y,width,height,startAngle,sweepAngle); //添加扇形 g.DrawPath(new Pen(Color.Gray, 1), path); //将路径画到画布g.FillEllipse(brush,x,y,width,height); //在画布上画一个椭圆g.DrawLine(pen,point1,point2); //在画布上画一条直线path.Transform(matrix);  //将图像按比例缩放g.TranslateTransform(x, y, MatrixOrder.PRepend); //平移画布


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表