导航:  GdiPlus Classes > GdiPlus Classes > CGpBrush Class > CGpLinearGradientBrush Class > LinearGradientBrush Object >

SetLinearColors

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

描述

 

设置此线性渐变画笔的起始颜色和结束颜色.

 

C++ Syntax

 

Status SetLinearColors(

[in]  const Color& color1,

[in]  const Color& color2

);

 

FreeBASIC 语法

 

FUNCTION SetLinearColors ( _

   BYVAL color1 AS ARGB, _

   BYVAL color2 AS ARGB _

) AS GpStatus

 

参数

 

color1

 

[in]在这个线性渐变画笔的起始边界线的coolor.

 

color2

 

[in]颜色指定颜色的最后边界线这一线性渐变画笔.

 

返回值

 

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

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

 

引用文件

 

CGpBrush.inc (include CGdiPlus.inc)

 

示例

 

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

' The following example creates a linear gradient brush and uses it to fill a rectangle.

' Next, the code changes the linear colors and uses the modified brush to fill another rectangle.

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

SUB Example_SetLinearColors (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 linear gradient brush.

  DIM rc AS GpRect = GDIP_RECT(0, 0, 100, 50)

  DIM linGrBrush AS CGpLinearGradientBrush = CGpLinearGradientBrush(@rc, _

     GDIP_ARGB(255, 0, 0, 0), GDIP_ARGB(255, 0, 0, 255), LinearGradientModeHorizontal)

 

  linGrBrush.SetLinearColors(GDIP_ARGB(255, 0, 0, 255), GDIP_ARGB(255, 0, 255, 0))

  graphics.FillRectangle(@linGrBrush, 0, 75, 100, 50)

 

END SUB

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