LinearGradientBrush.TranslateTransform 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
根據指定的維度來轉換局部幾何變換。 這個方法預先規劃轉換的轉換。
多載
TranslateTransform(Single, Single, MatrixOrder) |
依照指定的順序,根據指定的維度來轉換局部幾何變換。 |
TranslateTransform(Single, Single) |
根據指定的維度來轉換局部幾何變換。 這個方法預先規劃轉換的轉換。 |
TranslateTransform(Single, Single, MatrixOrder)
依照指定的順序,根據指定的維度來轉換局部幾何變換。
public:
void TranslateTransform(float dx, float dy, System::Drawing::Drawing2D::MatrixOrder order);
public void TranslateTransform (float dx, float dy, System.Drawing.Drawing2D.MatrixOrder order);
member this.TranslateTransform : single * single * System.Drawing.Drawing2D.MatrixOrder -> unit
Public Sub TranslateTransform (dx As Single, dy As Single, order As MatrixOrder)
參數
- dx
- Single
x 中轉譯的值。
- dy
- Single
y 中轉譯的值。
- order
- MatrixOrder
用來套用轉譯的順序 (附加在前端或後端)。
範例
下列程式代碼範例是設計來搭配 Windows Forms 使用,而且需要 PaintEventArgse
事件OnPaint物件。 此程式碼會執行下列動作:
建立新的 LinearGradientBrush。
使用此筆刷將矩形繪製到具有色彩線性、由左至右轉換的螢幕。
旋轉 LinearGradientBrush 90 度並縮放漸層。
將旋轉和縮放漸層的矩形繪製到螢幕。
轉譯矩形,使其具有從上到下執行的線性漸層。
將轉譯的矩形繪製到畫面。
請注意,有三個矩形顯示上層,其中顯示由左至右的漸層、中間的矩形顯示旋轉和縮放的漸層,以及顯示最終轉譯漸層的底部。
private:
void TranslateTransformExample( PaintEventArgs^ e )
{
// Create a LinearGradientBrush.
Rectangle myRect = Rectangle(20,20,200,100);
LinearGradientBrush^ myLGBrush = gcnew LinearGradientBrush( myRect,Color::Blue,Color::Red,0.0f,true );
// Draw a rectangle to the screen using the LinearGradientBrush.
e->Graphics->FillRectangle( myLGBrush, myRect );
// Rotate the LinearGradientBrush.
myLGBrush->RotateTransform( 90.0f );
// Scale the gradient for the height of the rectangle.
myLGBrush->ScaleTransform( 0.5f, 1.0f );
// Draw to the screen, the rotated and scaled gradient.
e->Graphics->FillRectangle( myLGBrush, 20, 150, 200, 100 );
// Rejustify the brush to start at the top edge of the
// rectangle.
myLGBrush->TranslateTransform( -20.0f, 0.0f );
// Draw a third rectangle to the screen using the translated
// brush.
e->Graphics->FillRectangle( myLGBrush, 20, 300, 200, 100 );
}
private void TranslateTransformExample(PaintEventArgs e)
{
// Create a LinearGradientBrush.
Rectangle myRect = new Rectangle(20, 20, 200, 100);
LinearGradientBrush myLGBrush = new LinearGradientBrush(
myRect, Color.Blue, Color.Red, 0.0f, true);
// Draw a rectangle to the screen using the LinearGradientBrush.
e.Graphics.FillRectangle(myLGBrush, myRect);
// Rotate the LinearGradientBrush.
myLGBrush.RotateTransform(90.0f);
// Scale the gradient for the height of the rectangle.
myLGBrush.ScaleTransform(0.5f, 1.0f);
// Draw to the screen, the rotated and scaled gradient.
e.Graphics.FillRectangle(myLGBrush, 20, 150, 200, 100);
// Rejustify the brush to start at the top edge of the
// rectangle.
myLGBrush.TranslateTransform(-20.0f, 0.0f);
// Draw a third rectangle to the screen using the translated
// brush.
e.Graphics.FillRectangle(myLGBrush, 20, 300, 200, 100);
}
Public Sub TranslateTransformExample(ByVal e As PaintEventArgs)
' Create a LinearGradientBrush.
Dim myRect As New Rectangle(20, 20, 200, 100)
Dim myLGBrush As New LinearGradientBrush(myRect, Color.Blue, _
Color.Red, 0.0F, True)
' Draw a rectangle to the screen using the LinearGradientBrush.
e.Graphics.FillRectangle(myLGBrush, myRect)
' Rotate the LinearGradientBrush.
myLGBrush.RotateTransform(90.0F)
' Scale the gradient for the height of the rectangle.
myLGBrush.ScaleTransform(0.5F, 1.0F)
' Draw to the screen, the rotated and scaled gradient.
e.Graphics.FillRectangle(myLGBrush, 20, 150, 200, 100)
' Rejustify the brush to start at the top edge of the rectangle.
myLGBrush.TranslateTransform(-20.0F, 0.0F)
' Draw a third rectangle to the screen using the translated brush.
e.Graphics.FillRectangle(myLGBrush, 20, 300, 200, 100)
End Sub
適用於
TranslateTransform(Single, Single)
根據指定的維度來轉換局部幾何變換。 這個方法預先規劃轉換的轉換。
public:
void TranslateTransform(float dx, float dy);
public void TranslateTransform (float dx, float dy);
member this.TranslateTransform : single * single -> unit
Public Sub TranslateTransform (dx As Single, dy As Single)
參數
- dx
- Single
x 中轉譯的值。
- dy
- Single
y 中轉譯的值。
範例
如需範例,請參閱 TranslateTransform。
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應