本文整理汇总了C#中System.Drawing.Drawing2D.Matrix.Rotate方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix.Rotate方法的具体用法?C# Matrix.Rotate怎么用?C# Matrix.Rotate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Drawing2D.Matrix
的用法示例。
在下文中一共展示了Matrix.Rotate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RotateExample
public void RotateExample(PaintEventArgs e)
{
Pen myPen = new Pen(Color.Blue, 1);
Pen myPen2 = new Pen(Color.Red, 1);
// Draw the rectangle to the screen before applying the transform.
e.Graphics.DrawRectangle(myPen, 150, 50, 200, 100);
// Create a matrix and rotate it 45 degrees.
Matrix myMatrix = new Matrix();
myMatrix.Rotate(45, MatrixOrder.Append);
// Draw the rectangle to the screen again after applying the
// transform.
e.Graphics.Transform = myMatrix;
e.Graphics.DrawRectangle(myPen2, 150, 50, 200, 100);
}
示例2: Main
//引入命名空间
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Drawing2D;
public class Form1 : System.Windows.Forms.Form {
[STAThread]
static void Main() {
Application.Run(new Form1());
}
protected override void OnPaint(PaintEventArgs e) {
Graphics g = CreateGraphics();
string txt = "HELLO";
float alpha = 45.0f;
int fontSize = 24;
Point center = new Point(90, 20);
FontFamily ff = new FontFamily("Times New Roman");
Font f = new Font(ff, fontSize, FontStyle.Regular);
StringFormat sf = new StringFormat();
sf.FormatFlags = StringFormatFlags.DirectionVertical;
g.DrawString(txt, f, new SolidBrush(Color.Blue), center, sf);
g.TranslateTransform(center.X, center.Y);
g.DrawEllipse(Pens.Magenta, new Rectangle(0, 0, 1, 1));
GraphicsPath gp = new GraphicsPath();
gp.AddString(txt, ff, (int)FontStyle.Bold, fontSize + 4, new Point(0, 0), sf);
Matrix m = new Matrix();
m.Rotate(alpha);
gp.Transform(m);
g.DrawPath(Pens.Red, gp);
g.RotateTransform(-alpha);
g.DrawString(txt, f, new SolidBrush(Color.Black), 0, 0, sf);
gp.Dispose(); g.Dispose(); m.Dispose();
}
}