GDI+ 绘制倾斜对象的方法!

//绘制倾斜文字

 

方法1:

System.Drawing.Graphics  
   
  public   Void   DrawString(  
                  String   s,  
                  Font   font,                               //   FontStyle.Italic   就是斜体字  
                  Brush   brush,  
                  PointF   point)

方法2:

private   void   Form1_Paint(object   sender,   System.Windows.Forms.PaintEventArgs   e)  
  {  
  //   声明并初始化Graphics对象g  
  Graphics   g   =   e.Graphics;  
  g.SmoothingMode   =   SmoothingMode.AntiAlias;  
  string   tempStr   =   "Hello,C#";//取得要显示的文字  
  for(int   i=0;i<361;i+=10){  
  //将指定的平移添加到g的变换矩阵前  
  g.TranslateTransform(150,150);  
  //   将指定的旋转用于g的变换矩阵  
  g.RotateTransform(i);  
  //   定义自己的画刷  
  Brush   myBrush   =   Brushes.Blue;  
  //显示旋转文字  
  g.DrawString(tempStr,this.Font,myBrush,60,0);  
  //   将g的全局变换矩阵重置为单位矩阵  
  g.ResetTransform();  
  }  

 

 

//绘制倾斜矩形

方法1:

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Rectangle rect = new Rectangle(100, 10, 100, 60);
e.Graphics.RotateTransform(45, System.Drawing.Drawing2D.MatrixOrder.Append);
e.Graphics.DrawRectangle(SystemPens.ControlDark, rect);

 

方法2:

 using System.Drawing.Drawing2D;

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawRectangle(
Pens.Blue,
200, 100, 100, 60);

Matrix matrix = new Matrix();
matrix.RotateAt(45,new PointF(200,100),MatrixOrder.Append);
e.Graphics.Transform = matrix;
e.Graphics.DrawRectangle(Pens.Red,
200, 100, 100, 60);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值