GOA - System.Drawing.Matrix

Matrix Class


Represents an affine transformation by a 3 x 3 matrix. Pair (sx, sy) indicates the scale transformation, pair (rs0, rs1) indicates the rotation transformation, pair (tx, ty) indicates the translation transformation. The third column of this matrix is always (0, 0, 1). This class cannot be inherited.

Definition

public sealed class Matrix: Object

Members Table

MethodDescription
EqualsOverloaded. Compares two objects to determine if they are equal.
GetHashCodeOverriden. Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetTypeGets the Type of the current instance. (Inherited from Object)
InvertReplaces two translation elements of the Matrix by its inverse elements.
MatrixOverloaded. Initializes a new instance of Matrix.
MultiplyOverloaded. Returns a Matrix object that represents the multiplication of two matrices.
PostMultiplyUpdates the current Matrix by the multiplication of itself with a specified Matrix.
PreMultiplyUpdates the current Matrix by the multiplication of itself with a specified Matrix.
ReferenceEqualsDetermines whether the specified Object instances are the same instance. (Inherited from Object)
RotateReturns a Matrix object which is the result of the rotation of the current Matrix by a specified angle.
ScaleReturns a scaling matrix with the specified scale values.
ToStringOverriden. Returns a String that represents the current Object.
TranslateReturns a translation matrix with the specified translation values.
PropertyDescription
rs0Gets or sets the element of the Matrix that represents the rotation transformation.
rs1Gets or sets the element of the Matrix that represents the rotation transformation.
sxGets or sets the element of the Matrix that represents the horizontal scale transformation.
syGets or sets the element of the Matrix that represents the vertical scale transformation.
txGets or sets the element of the Matrix that represents the horizontal translation transformation.
tyGets or sets the element of the Matrix that represents the vertical translation transformation.
OperatorDescription
operator !=Determines whether two specified Matrix instances are different.
operator *Overloaded. Multiplies two specified Matrix instances.
operator ==Determines whether two specified Matrix instances are equivalent.

Inheritance Hierarchy

Object
Matrix

Examples

// This sample shows how to implement the Matrix class.

 

using System.Drawing;

using System.Windows.Forms;

 

public class MyControl : System.Windows.Forms.Control

{

     protected override void OnPaint( PaintEventArgs e )

     {

          Visual v= Visual;

 

          // Creates a new instance of the Matrix.

          Matrix myMatrix = new Matrix(/*sx*/180,/*rs0*/200,/*rs1*/100,/*sy*/0,/*tx*/190,/*ty*/140);

 

          // Initializes the Gradient object with 6 gradient color elements.

          Gradient gd= new Gradient(6);

          gd.SetColor( 0, Color.FromArgb(255,0,0) );

          gd.SetOffset( 0, 0 );

          gd.SetColor( 1, Color.FromArgb(0,255,0) );

          gd.SetOffset( 1, 50);

          gd.SetColor( 2, Color.FromArgb(0,0,255) );

          gd.SetOffset( 2, 100);

          gd.SetColor( 3, Color.FromArgb(255,0,0) );

          gd.SetOffset( 3, 150);

          gd.SetColor( 4, Color.FromArgb(0,255,0) );

          gd.SetOffset( 4, 200);

          gd.SetColor( 5, Color.FromArgb(100,100,100) );

          gd.SetOffset( 5, 250);

 

          // Draws two rectangles filled with the gradient color elements.

          v.BeginRadialGradientFill( gd, myMatrix);

          v.DrawRectangle(0,0,190,140);

          v.DrawRectangle(190,140,190,140);

          v.EndFill();

     }

 

}

 

public class Form1 : System.Windows.Forms.Form

{

     private MyControl control1= null;

     public Form1()

     {

          InitializeComponent();

     }

     private void InitializeComponent()

     {

          SuspendLayout();

          control1= new MyControl();

          control1.Location= new System.Drawing.Point(10,10);

          control1.Size= new Size(Application.Width-10,Application.Height-10);

          Controls.Add( control1);

          ResumeLayout(false);

     }

     static void Main()

     {

          Application.Run( new Form1() );

     }

}

Class Information

NamespaceSystem.Drawing
Flash LibrarySystem.Drawing.scl
Flash Library Version2.0.0.1291
Silverlight LibrarySystem.Windows.Forms.dll



© 2003-2007 NETiKA Technologies. All rights reserved.