当前位置: 首页>>代码示例>>C#>>正文


C# Matrix.Reset方法代码示例

本文整理汇总了C#中System.Drawing.Drawing2D.Matrix.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix.Reset方法的具体用法?C# Matrix.Reset怎么用?C# Matrix.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Drawing2D.Matrix的用法示例。


在下文中一共展示了Matrix.Reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ResetExample

public void ResetExample(PaintEventArgs e)
{
    Pen myPen = new Pen(Color.Blue, 1);
    Pen myPen2 = new Pen(Color.Red, 1);
             
    // Create a matrix that scales by 5 in the x direction and
    // by 3 in the y direction.
    Matrix myMatrix = new Matrix(
        5.0f, 0.0f, 0.0f, 3.0f, 0.0f, 0.0f); 
             
    // List the matrix elements to the screen.
    ListMatrixElements(e, myMatrix, "Beginning Matrix", 6, 20);
             
    // Reset the matrix to identity.
    myMatrix.Reset();
             
    // Again list the matrix elements to the screen.
    ListMatrixElements2(e, myMatrix, "Matrix After Reset", 6, 40);
             
    // Translate the matrix by 50 points in the x-axis and 40 points
    // in the y-axis.
    myMatrix.Translate(50.0f, 40.0f); 
  
    // List the matrix elements to the screen.
    ListMatrixElements1(e, myMatrix, "Matrix After Translation", 6, 60);
             
    // Draw a rectangle to the screen.
    e.Graphics.DrawRectangle(myPen, 0, 0, 100, 100);
             
    // Apply the matrix transform to the Graphics.
    e.Graphics.Transform = myMatrix;
             
    // Draw another rectangle to the screen that has the transform
    // applied.
    e.Graphics.DrawRectangle(myPen2, 0, 0, 100, 100);
}
             
//-------------------------------------------------------
// This function is a helper function to
// list the contents of a matrix.
//-------------------------------------------------------
public void ListMatrixElements2(
    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;
    }
}
开发者ID:.NET开发者,项目名称:System.Drawing.Drawing2D,代码行数:76,代码来源:Matrix.Reset


注:本文中的System.Drawing.Drawing2D.Matrix.Reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。