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

SetBlendTriangularShape

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

描述

 

设置此路径渐变画笔的混合形状.

 

C++ Syntax

 

Status SetBlendTriangularShape(

[in]            REAL focus,

[in, optional]  REAL scale

);

 

FreeBASIC Syntax

 

FUNCTION SetBlendTriangularShape ( _

   BYVAL focus AS SINGLE, _

   BYVAL scale AS SINGLE = 1.0 _

) AS GpStatus

 

参数

 

rFocus

 

[in]单精度数指定中心的颜色会在其最高强度.这个数字必须在0到1的范围内.

 

vScale

 

[in]简单精度数指定颜色,得到中心混合边界的颜色强度最大.这个数字必须在0到1的范围内.默认值是1.

 

返回值

 

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

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

 

备注

 

默认情况下,当从起始边界到结束边界移动时,颜色从起始颜色(线性渐变画笔的起始边界颜色)到结束颜色(线性渐变画笔的结束边界颜色)逐渐改变.你可以定制的定位和开始和结束用LinearGradientBrush.SetBlendTriangularShape颜色混合的方法.

方法的LinearGradientBrush.SetBlendTriangularShape定制混合,它遵循一个与三角形的基地,在梯度的边界的极端的三角形.开始的颜色,在默认的共混物,是在一个线性梯度刷的起始边界,出现在开始和结束的线性梯度刷的边界时,三角形的共混物施加.结束颜色的位置,在默认的混合,是在结束边界,是介于边界之间,是由焦点的值决定的.换句话说,焦点指定三角形的峰的位置.例如,0.5的地方开始和结束的边界之间的峰值一半的焦点价值.结束颜色出现在这个峰值.

三角形混合的结束颜色是渐变的默认混合起始颜色和默认混合结束颜色之间的色域的百分比.例如,假设一个线性梯度刷构造与红色作为起始颜色和蓝色作为结束颜色.如果LinearGradientBrush.SetBlendTriangularShape叫做在三角形的混合0.3,结束颜色刻度值是一个色调,红色和蓝色的(70成红百分之30间,百分之30个蓝色的).一个1.0尺度值产生一结束颜色是蓝色100 %.

 

引用文件

 

CGpBrush.inc (include CGdiPlus.inc)

 

示例

 

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

' The following example creates a linear gradient brush, sets a triangular-shaped blend,

' and uses the brush to fill a rectangle. Twice more, the code sets a triangular-shaped

' blend with different values and, each time, uses the brush to fill a rectangle.

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

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)

 

  DIM pt1 AS GpPoint = GDIP_POINT(0, 0)

  DIM pt2 AS GpPoint = GDIP_POINT(500, 0)

 

  DIM linGrBrush AS CGpLinearGradientBrush = CGpLinearGradientBrush(@pt1, @pt2, _

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

 

  linGrBrush.SetBlendTriangularShape(0.5, 0.6)

  graphics.FillRectangle(@linGrBrush, 0, 0, 500, 50)

 

  linGrBrush.SetBlendTriangularShape(0.5, 0.8)

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

 

  linGrBrush.SetBlendTriangularShape(0.5, 1.0)

  graphics.FillRectangle(@linGrBrush, 0, 150, 500, 50)

 

END SUB

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