本文整理汇总了C#中System.Drawing.Drawing2D.Matrix.TransformVectors方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix.TransformVectors方法的具体用法?C# Matrix.TransformVectors怎么用?C# Matrix.TransformVectors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Drawing2D.Matrix
的用法示例。
在下文中一共展示了Matrix.TransformVectors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransformVectorsExample
public void TransformVectorsExample(PaintEventArgs e)
{
Pen myPen = new Pen(Color.Blue, 1);
Pen myPen2 = new Pen(Color.Red, 1);
// Create an array of points.
Point[] myArray =
{
new Point(20, 20),
new Point(120, 20),
new Point(120, 120),
new Point(20, 120),
new Point(20,20)
};
// Draw the Points to the screen before applying the
// transform.
e.Graphics.DrawLines(myPen, myArray);
// Create a matrix, scale it, and translate it.
Matrix myMatrix = new Matrix();
myMatrix.Scale(3, 2, MatrixOrder.Append);
myMatrix.Translate(100, 100, MatrixOrder.Append);
// List the matrix elements to the screen.
ListMatrixElements(e,
myMatrix,
"Scaled and Translated Matrix",
6,
20);
// Apply the transform to the array.
myMatrix.TransformVectors(myArray);
// Draw the Points to the screen again after applying the
// transform.
e.Graphics.DrawLines(myPen2, myArray);
}
//-------------------------------------------------------
// This function is a helper function to
// list the contents of a matrix.
//-------------------------------------------------------
public void ListMatrixElements(
PaintEventArgs e,
Matrix matrix,
string matrixName,
int numElements,
int y)
{
// Set up variables for drawing the array
// of points to the screen.
int i;
float x = 20, X = 200;
Font myFont = new Font("Arial", 8);
SolidBrush myBrush = new SolidBrush(Color.Black);
// Draw the matrix name to the screen.
e.Graphics.DrawString(
matrixName + ": ",
myFont,
myBrush,
x,
y);
// Draw the set of path points and types to the screen.
for(i=0; i<numElements; i++)
{
e.Graphics.DrawString(
matrix.Elements[i].ToString() + ", ",
myFont,
myBrush,
X,
y);
X += 30;
}
}