PathGradientBrush.MultiplyTransform 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將代表這個 PathGradientBrush 局部幾何轉換的 Matrix 乘以指定的 Matrix 前面加上指定的 Matrix。
多載
MultiplyTransform(Matrix, MatrixOrder) |
使用筆刷轉換矩陣乘以另一個矩陣的轉換矩陣乘積來更新筆刷的轉換矩陣。 |
MultiplyTransform(Matrix) |
使用筆刷轉換矩陣乘以另一個矩陣的乘積,更新筆刷的轉換矩陣。 |
MultiplyTransform(Matrix, MatrixOrder)
使用筆刷轉換矩陣乘以另一個矩陣的轉換矩陣乘積來更新筆刷的轉換矩陣。
public:
void MultiplyTransform(System::Drawing::Drawing2D::Matrix ^ matrix, System::Drawing::Drawing2D::MatrixOrder order);
public void MultiplyTransform (System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Drawing2D.MatrixOrder order);
member this.MultiplyTransform : System.Drawing.Drawing2D.Matrix * System.Drawing.Drawing2D.MatrixOrder -> unit
Public Sub MultiplyTransform (matrix As Matrix, order As MatrixOrder)
參數
- order
- MatrixOrder
MatrixOrder,指定要乘以兩個矩陣的順序。
範例
下列程式代碼範例的設計目的是要與 Windows Forms 搭配使用,而且需要 PaintEventArgse
OnPaint 事件物件。 程式代碼會執行下列動作:
建立圖形路徑,並將矩形加入其中。
從路徑點建立 PathGradientBrush(在此範例中,這些點會形成矩形,但可能是大部分的圖形)。
將中央色彩設定為紅色,並將周圍色彩設定為藍色。
在套用乘數轉換之前,先將 PathGradientBrush 繪製到畫面。
建立矩陣,將筆刷旋轉 90 度,並在兩個軸中以 100 轉譯。
使用 MultiplyTransform 方法,將此矩陣套用至筆刷。
將筆刷繪製到螢幕。
public:
void MultiplyTransformExample( PaintEventArgs^ e )
{
// Create a graphics path and add an rectangle.
GraphicsPath^ myPath = gcnew GraphicsPath;
Rectangle rect = Rectangle(20,20,100,50);
myPath->AddRectangle( rect );
// Get the path's array of points.
array<PointF>^myPathPointArray = myPath->PathPoints;
// Create a path gradient brush.
PathGradientBrush^ myPGBrush = gcnew PathGradientBrush( myPathPointArray );
// Set the color span.
myPGBrush->CenterColor = Color::Red;
array<Color>^ mySurroundColor = {Color::Blue};
myPGBrush->SurroundColors = mySurroundColor;
// Draw the brush to the screen prior to transformation.
e->Graphics->FillRectangle( myPGBrush, 10, 10, 200, 200 );
// Create a new matrix that rotates by 90 degrees, and
// translates by 100 in each direction.
Matrix^ myMatrix = gcnew Matrix( 0,1,-1,0,100,100 );
// Apply the transform to the brush.
myPGBrush->MultiplyTransform( myMatrix, MatrixOrder::Append );
// Draw the brush to the screen again after applying the
// transform.
e->Graphics->FillRectangle( myPGBrush, 10, 10, 200, 300 );
}
public void MultiplyTransformExample(PaintEventArgs e)
{
// Create a graphics path and add an rectangle.
GraphicsPath myPath = new GraphicsPath();
Rectangle rect = new Rectangle(20, 20, 100, 50);
myPath.AddRectangle(rect);
// Get the path's array of points.
PointF[] myPathPointArray = myPath.PathPoints;
// Create a path gradient brush.
PathGradientBrush myPGBrush = new
PathGradientBrush(myPathPointArray);
// Set the color span.
myPGBrush.CenterColor = Color.Red;
Color[] mySurroundColor = {Color.Blue};
myPGBrush.SurroundColors = mySurroundColor;
// Draw the brush to the screen prior to transformation.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200);
// Create a new matrix that rotates by 90 degrees, and
// translates by 100 in each direction.
Matrix myMatrix = new Matrix(0, 1, -1, 0, 100, 100);
// Apply the transform to the brush.
myPGBrush.MultiplyTransform(myMatrix, MatrixOrder.Append);
// Draw the brush to the screen again after applying the
// transform.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 300);
}
Public Sub MultiplyTransformExample(ByVal e As PaintEventArgs)
' Create a graphics path and add a rectangle.
Dim myPath As New GraphicsPath
Dim rect As New Rectangle(20, 20, 100, 50)
myPath.AddRectangle(rect)
' Get the path's array of points.
Dim myPathPointArray As PointF() = myPath.PathPoints
' Create a path gradient brush.
Dim myPGBrush As New PathGradientBrush(myPathPointArray)
' Set the color span.
myPGBrush.CenterColor = Color.Red
Dim mySurroundColor As Color() = {Color.Blue}
myPGBrush.SurroundColors = mySurroundColor
' Draw the brush to the screen prior to transformation.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200)
' Create a new matrix that rotates by 90 degrees, and
' translates by 100 in each direction.
Dim myMatrix As New Matrix(0, 1, -1, 0, 100, 100)
' Apply the transform to the brush.
myPGBrush.MultiplyTransform(myMatrix, MatrixOrder.Append)
' Draw the brush to the screen again after applying the
' transform.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 300)
End Sub
適用於
MultiplyTransform(Matrix)
使用筆刷轉換矩陣乘以另一個矩陣的乘積,更新筆刷的轉換矩陣。
public:
void MultiplyTransform(System::Drawing::Drawing2D::Matrix ^ matrix);
public void MultiplyTransform (System.Drawing.Drawing2D.Matrix matrix);
member this.MultiplyTransform : System.Drawing.Drawing2D.Matrix -> unit
Public Sub MultiplyTransform (matrix As Matrix)
參數
範例
如需範例,請參閱 MultiplyTransform。