描述
设置此路径渐变画笔的变换矩阵.
C++ Syntax
Status SetTransform( [in] const Matrix *matrix ); |
FreeBASIC 语法
FUNCTION SetTransform ( _ BYVAL pMatrix AS CGpMatrix PTR _ ) AS GpStatus |
参数
pMatrix
[in]指向Matrix对象,指定使用变换矩阵.
返回值
如果该方法成功,则返回Ok,这是对Status枚举元素.
如果这个方法失败,它返回一个枚举的其他元素的Status.
备注
一个PathGradientBrush对象有一个GraphicsPath对象作为刷边界路径.当用路径渐变画笔绘制时,只有边界路径中的区域被填充.如果画笔的变换矩阵被设置为表示除标识以外的任何变换,则在绘制过程中根据该矩阵变换边界路径,并且仅在变换路径内填充区域.
转换只适用于渲染过程.由PathGradientBrush对象存储边界路径不是由PathGradientBrush.SetTransform方法改变.
引用文件
CGpBrush.inc (include CGdiPlus.inc)
示例
' ========================================================================================
' The following example creates a PathGradientBrush object based on a triangular path. The
' Graphics.FillRectangle method uses the path gradient brush to paint a rectangle that
' contains the triangular path. Next, the code creates a Matrix object that represents a
' composite transformation (rotate, then translate) and passes the address of that Matrix
' object to the PathGradientBrush.SetTransform method of the PathGradientBrush object. The
' code calls FillRectangle a second time to paint the same rectangle using the transformed
' path gradient 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 points(0 TO 2) AS GpPoint = {GDIP_POINT(0, 0), GDIP_POINT(100, 0), GDIP_POINT(100, 100)}
DIM pthGrBrush AS CGpPathGradientBrush = CGpPathGradientBrush(@points(0), 3)
DIM nCount AS LONG = 3
DIM colors(0 TO 2) AS ARGB = {GDIP_ARGB(255, 255, 0, 0), GDIP_ARGB(255, 0, 255, 0), GDIP_ARGB(255, 0, 0, 0)}
pthGrBrush.SetSurroundColors(@colors(0), @nCount)
graphics.FillRectangle(@pthGrBrush, 0, 0, 200, 200)
' // Set the transformation for the brush (rotate, then translate).
DIM matrix AS CGpMatrix = CGpMatrix(0.0, 1.0, -1.0, 0.0, 150.0, 60.0)
pthGrBrush.SetTransform(@matrix)
' // Fill the same area with the transformed path gradient brush.
graphics.FillRectangle(@pthGrBrush, 0, 0, 200, 200)
END SUB
' ========================================================================================