PathGradientBrush::TranslateTransform 方法 (gdipluspath.h)
PathGradientBrush::TranslateTransform 方法會以本身乘積和翻譯矩陣來更新此筆刷目前的轉換矩陣。
語法
Status TranslateTransform(
[in] REAL dx,
[in] REAL dy,
[in] MatrixOrder order
);
參數
[in] dx
類型: REAL
指定翻譯水準元件的實數。
[in] dy
類型: REAL
指定翻譯垂直元件的實數。
[in] order
類型: MatrixOrder
選擇性。 MatrixOrder 列舉的元素,指定乘法的順序。 MatrixOrderPrepend 指定轉譯矩陣位於左側, 而 MatrixOrderAppend 指定轉譯矩陣位於右側。 預設值為 MatrixOrderPrepend。
傳回值
類型: 狀態
如果方法成功,它會傳回 Ok,這是 Status 列舉的元素。
如果方法失敗,它會傳回 Status 列舉的其他其中一個專案。
備註
單一 3 ×3 矩陣可以儲存任何一連串的關聯轉換。 如果您有數個 3 個×3 矩陣,其中每一個矩陣都代表一個關聯轉換,則這些矩陣的乘積是單一 3 ×3 矩陣,代表整個轉換序列。 由該產品表示的轉換稱為複合轉換。 例如,假設矩陣 S 代表縮放比例,而矩陣 T 代表翻譯。 如果矩陣 M 是產品 ST,則矩陣 M 代表複合轉換:第一次縮放,然後再轉譯。
範例
下列範例會根據三角形路徑建立 PathGradientBrush 物件。 對 PathGradientBrush::ScaleTransform 和 PathGradientBrush::TranslateTransform 方法的 PathGradientBrush 物件呼叫會設定筆刷轉換矩陣的元素,使其代表複合轉換:先縮放,然後再轉譯。 此程式代碼會使用路徑漸層筆刷兩次繪製矩形:設定轉換之前和設定轉換之後一次。
VOID Example_TranslateTrans(HDC hdc)
{
Graphics graphics(hdc);
Point pts[] = {Point(0, 0), Point(50, 0), Point(50, 50)};
PathGradientBrush pthGrBrush(pts, 3);
// Fill an area with the path gradient brush (no transformation).
graphics.FillRectangle(&pthGrBrush, 0, 0, 500, 500);
pthGrBrush.ScaleTransform(3.0f, 1.0f);
pthGrBrush.TranslateTransform(100.0f, 50.0f, MatrixOrderAppend);
// Fill the same area with the transformed path gradient brush.
graphics.FillRectangle(&pthGrBrush, 0, 0, 500, 500);
}
規格需求
需求 | 值 |
---|---|
最低支援的用戶端 | Windows XP、Windows 2000 Professional [僅限桌面應用程式] |
最低支援的伺服器 | Windows 2000 Server [僅限桌面應用程式] |
目標平台 | Windows |
標頭 | gdipluspath.h (包含 Gdiplus.h) |
程式庫 | Gdiplus.lib |
Dll | Gdiplus.dll |
另請參閱
PathGradientBrush::GetTransform
PathGradientBrush::MultiplyTransform
PathGradientBrush::ResetTransform
PathGradientBrush::RotateTransform
PathGradientBrush::ScaleTransform