导航:  GdiPlus Classes > GdiPlus Classes > CGpBrush Class > CGpPathGradientBrush Class > PathGradientBrush Object >

SetSurroundColors

上一页返回章节概述下一页

描述

 

设置此路径渐变画笔的环绕颜色.环绕颜色是画笔边界路径上的离散点指定的颜色.

 

C++ Syntax

 

Status SetSurroundColors(

[in]       const Color *colors,

[in, out]  INT *count

);

 

FreeBASIC 语法

 

FUNCTION SetSurroundColors ( _

   BYVAL colors AS ARGB PTR, _

   BYVAL count AS INT_ PTR _

) AS GpStatus

 

参数

 

colors

 

[in]数组指针颜色指定颜色的环绕.

 

count

 

[in, out]指针指向一个整数,输入,指定颜色的颜色数组的数量.如果方法成功,此参数在输出时接收环绕色集的数目.如果方法失败,此参数不接收值.

 

返回值

 

如果该方法成功,则返回Ok,这是对Status枚举元素.

如果这个方法失败,它返回一个枚举的其他元素的Status.

 

备注

 

路径渐变刷具有边界路径和中心点.中心点设置为单一颜色,但可以在边界上的几个点指定不同的颜色.例如,假设为中心颜色指定红色,并在边界上的不同点指定蓝色、绿色和黄色.当你沿着边界移动时,颜色会逐渐从蓝变绿再变黄再回到蓝色.当你沿着一条直线从边界上的任何点移动到中心点时,颜色就会从边界点的颜色变为红色.

 

引用文件

 

CGpBrush.inc (include CGdiPlus.inc)

 

示例

 

' ========================================================================================

' The following example creates a PathGradientBrush object based on an array of three points

' that defines a triangular path. The code also initializes an array of three Color objects.

' The call to the PathGradientBrush::SetSurroundColors method associates each color in the

' color array with the corresponding (same index) point in the point array. After the surround

' colors of the path gradient brush have been set, the Graphics.FillRectangle method uses

' the path gradient brush to paint a rectangle that includes the triangular path.

' One edge of the rendered triangle changes gradually from red to green. The next edge

' changes gradually from green to black, and the third edge changes gradually from black

' to red. The code does not set the center color, so the center color has the default value

' of black. As you move along a straight line from any point on the boundary path (triangle)

' to the center point, the color changes gradually from that boundary point's color to black.

' ========================================================================================

SUB Example_SetSurroundColors (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(20, 20), GDIP_POINT(100, 20), 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, 0, 255), GDIP_ARGB(255, 0, 255, 255)}

  pthGrBrush.SetSurroundColors(@colors(0), @nCount)

 

  graphics.FillRectangle(@pthGrBrush, 0, 0, 200, 200)

 

END SUB

' ========================================================================================