描述
设置此路径渐变画笔的混合形状.
C++ Syntax
Status SetBlendTriangularShape( [in] REAL focus, [in, optional] REAL scale ); |
FreeBASIC 语法
FUNCTION SetBlendTriangularShape ( _ BYVAL focus AS SINGLE, _ BYVAL scale AS SINGLE = 1.0 _ ) AS GpStatus |
参数
focus
[in]单精度数指定中心的颜色会在其最高强度.这个数字必须在0到1的范围内.
scale
[in]简单精度数指定颜色,得到中心混合边界的颜色强度最大.这个数字必须在0到1的范围内.默认值是1.
返回值
如果该方法成功,则返回Ok,这是对Status枚举元素.
如果这个方法失败,它返回一个枚举的其他元素的Status.
备注
默认情况下,当你从路径渐变的边界移动到中心点时,颜色会逐渐从边界颜色变为中心颜色.您可以自定义定位和混合的边界和中心的颜色通过调用PathGradientBrush.SetBlendTriangularShape method.
引用文件
CGpBrush.inc (include CGdiPlus.inc)
示例
' ========================================================================================
' The following example creates a PathGradientBrush object based on an ellipse. The code
' calls the PathGradientBrush.SetBlendTriangularShape method of the PathGradientBrush object,
' passing a focus of 0.2 and a scale of 0.7. Then the code uses the path gradient brush to
' paint a rectangle that contains the ellipse.
' ========================================================================================
SUB Example_SetBlendTriangularShape (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)
' // Create a path that consists of a single ellipse.
DIM path AS CGpGraphicsPath
path.AddEllipse(0, 0, 200, 100)
' // Use the path to construct a brush.
DIM pthGrBrush AS CGpPathGradientBrush = @path
' // Set the color at the center of the path to blue.
pthGrBrush.SetCenterColor(GDIP_ARGB(255, 0, 0, 255))
' // Set the color along the entire boundary of the path to aqua.
DIM colors(0) AS ARGB = {GDIP_ARGB(255, 0, 255, 255)}
DIM count AS LONG = 1
pthGrBrush.SetSurroundColors(@colors(0), @count)
pthGrBrush.SetBlendTriangularShape(0.2, 0.7)
' // The color is blue on the boundary and at the center.
' // At points that are 20 percent of the way from the boundary to the
' // center, the color is 70 percent red and 30 percent blue.
graphics.FillRectangle(@pthGrBrush, 0, 0, 300, 300)
END SUB
' ========================================================================================