描述
设置该线性梯度刷的变换矩阵.
C++ Syntax
Status SetTransform( [in] const Matrix *matrix ); |
FreeBASIC 语法
FUNCTION SetTransform ( _ BYVAL pMatrix AS CGpMatrix PTR _ ) AS GpStatus |
参数
pMatrix
[in]指向Matrix对象,指定使用变换矩阵.
返回值
如果该方法成功,则返回Ok,这是对Status枚举元素.
如果这个方法失败,它返回一个枚举的其他元素的Status.
备注
一个LinearGradientBrush对象有一个矩形指定开始和结束边界的梯度和一个模式或角度的影响方向.如果画笔的变换矩阵被设置为表示除标识以外的任何变换,则在绘制过程中,该边界和方向将根据该矩阵进行变换.
转换只适用于渲染过程.由LinearGradientBrush对象存储的界限不是由LinearGradientBrush.SetTransform方法改变.
引用文件
CGpBrush.inc (include CGdiPlus.inc)
示例
' ========================================================================================
' The following example creates a linear gradient brush and uses it to fill a rectangle.
' Next, the code modifies the brush's transformation matrix and fills a rectangle with the
' transformed brush.
' ========================================================================================
SUB Example_SetTransform (BYVAL hdc AS HDC)
' // Create a graphics object from the window device context
DIM graphics AS CGpGraphics = hdc
' // Get the DPI scaling ratio
DIM rxRatio AS SINGLE = graphics.GetDpiX / 96
DIM ryRatio AS SINGLE = graphics.GetDpiY / 96
' // Set the scale transform
graphics.ScaleTransform(rxRatio, ryRatio)
DIM rc AS GpRect = GDIP_RECT(0, 0, 80, 40)
DIM linGrBrush AS CGpLinearGradientBrush = CGpLinearGradientBrush(@rc, _
GDIP_ARGB(255, 255, 0, 0), GDIP_ARGB(255, 0, 0, 255), LinearGradientModeHorizontal)
DIM matrix AS CGpMatrix = CGpMatrix(2.0, 0, 0, 1, 0, 0) ' // horizontal doubling
' // Fill a large area with the gradient brush (no transformation).
graphics.FillRectangle(@linGrBrush, 0, 0, 800, 50)
linGrBrush.SetTransform(@matrix)
' // Fill a large area with the transformed linear gradient brush.
graphics.FillRectangle(@linGrBrush, 0, 75, 800, 50)
END SUB
' ========================================================================================