private void Pen_Tranform_Click(object sender, System.EventArgs e)
{
Graphics graphics = this.CreateGraphics();
graphics.Clear(Color.White);
//让图像显示更精致
graphics.SmoothingMode = SmoothingMode.HighQuality;
//构造一支宽度为5的红色画笔
Pen pen = new Pen(Color.Red,3.5f);
//绘制原始画笔
graphics.DrawEllipse(pen,0,50,80,80);
graphics.TranslateTransform(100,0);
//将画笔从垂直方向扩充6倍,水平方向保持不变
pen.ScaleTransform(.5f,6f);
// pen.DashStyle = DashStyle.DashDotDot;
//使用未经旋转处理的画笔画圆
graphics.DrawEllipse(pen, 0, 50, 80, 80);
//60°旋转
graphics.TranslateTransform(100,0);
pen.RotateTransform(60,MatrixOrder.Append);
graphics.DrawEllipse(pen, 0, 50, 80, 80);
//120°旋转
graphics.TranslateTransform(100,0);
pen.RotateTransform(60, MatrixOrder.Append);
graphics.DrawEllipse(pen, 0, 50, 80, 80);
//180°旋转
graphics.TranslateTransform(100,0);
pen.RotateTransform(60, MatrixOrder.Append);
graphics.DrawEllipse(pen, 0, 50, 80, 80);
}
GDI+基础知识——画笔的变换(缩放及旋转)
最新推荐文章于 2024-06-15 12:37:31 发布