GDI+ 绘制倾斜对象的方法!
2010-01-25 16:33
429 查看
//绘制倾斜文字
方法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;
方法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); }
相关文章推荐
- C++ GDI+ DrawImage方法详解(绘制指定图像Image)
- C++ Builder 使用Canvas的方法来绘制图形对象
- GDI+绘制自定义行距的文本的三种方法。
- vb.net GDI+入门——使用Graphics对象绘制线图
- Delphi GDI+测量用指定的 Font 对象绘制的指定字符串
- 提高GDI+绘制效率的一些方法
- 用GDI+怎么实现绘制倾斜文字
- .net环境用GDI+绘制倾斜文字
- C++ GDI+ DrawImage方法详解(绘制指定图像Image)
- 两种动态创建对象的方法
- OSG绘制大量文本的解决方法:文本绘制的纹理活字印刷术
- 许多GDI+ 方法都是重载的
- Ajax XMLHttpRequest对象的三个属性以及open和send方法
- Mockito PowerMock 静态 方法 @Spy 对象方法 mock
- [解决]eclipse中JSP页面的内置对象 不能引出方法的问题
- JCL中由接口获得对象的方法
- Objective C 绘制透明窗口的方法
- hibernate中session中的update方法,改动了一下,让数据库中原有的属性不变,只更新传入对象中改动的属性
- list和array打印对象的方法
- javascript 对象属性的添加,删除,json对象和字符串转换方法等