本文整理汇总了C#中System.Drawing.Drawing2D.Matrix.Multiply方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix.Multiply方法的具体用法?C# Matrix.Multiply怎么用?C# Matrix.Multiply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Drawing2D.Matrix
的用法示例。
在下文中一共展示了Matrix.Multiply方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MultiplyExample
public void MultiplyExample(PaintEventArgs e)
{
Pen myPen = new Pen(Color.Blue, 1);
Pen myPen2 = new Pen(Color.Red, 1);
// Set up the matrices.
Matrix myMatrix1 = new Matrix(
2.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
Matrix myMatrix2 = new Matrix(
0.0f, 1.0f, -1.0f, 0.0f, 0.0f, 0.0f);
Matrix myMatrix3 = new Matrix(
1.0f, 0.0f, 0.0f, 1.0f, 250.0f, 50.0f);
// Display the elements of the starting matrix.
ListMatrixElements(e, myMatrix1, "Beginning Matrix", 6, 40);
// Multiply Matrix1 by Matrix 2.
myMatrix1.Multiply(myMatrix2, MatrixOrder.Append);
// Display the result of the multiplication of Matrix1 and
// Matrix2.
ListMatrixElements(e,
myMatrix1,
"Matrix After 1st Multiplication",
6,
60);
// Multiply the result from the pervious multiplication by
// Matrix3.
myMatrix1.Multiply(myMatrix3, MatrixOrder.Append);
// Display the result of the previous multiplication
// multiplied by Matrix3.
ListMatrixElements1(e,
myMatrix1,
"Matrix After 2nd Multiplication",
6,
80);
// Draw the rectangle prior to transformation.
e.Graphics.DrawRectangle(myPen, 0, 0, 100, 100);
// Make the transformation.
e.Graphics.Transform = myMatrix1;
// Draw the rectangle after transformation.
e.Graphics.DrawRectangle(myPen2, 0, 0, 100, 100);
}
//-------------------------------------------------------
// The following function is a helper function to
// list the contents of a matrix.
//-------------------------------------------------------
public void ListMatrixElements1(
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;
}
}