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

SetInterpolationColors

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

描述

 

设置此路径渐变画笔的预置颜色和混合位置.

 

C++ Syntax

 

Status SetInterpolationColors(

[in]  const Color *presetColors,

[in]  REAL *blendPositions,

[in]  INT count

);

 

FreeBASIC 语法

 

FUNCTION SetInterpolationColors ( _

   BYVAL presetColors AS ARGB PTR, _

   BYVAL blendPositions AS SINGLE PTR, _

   BYVAL nCount AS INT_ _

) AS GpStatus

 

参数

 

presetColors

 

[in]数组指针的颜色,指定插值颜色梯度.一种颜色的一个给定的指标在presetColors阵列对应于同一指标在blendPositions阵列混合位置.

 

blendPositions

 

[in]指针指向一个数组,指定的混合位置.每个混合位置是一个数字从0到1,其中0表示梯度的边界和1表示中心点.0和1之间的混合位置指定的所有点是从边界到中心点的距离的一部分的所有点的集合.例如,对0.7混合位置指定所有点是从边界到中心点的方式,百分之70套.

 

nCount

 

[in]整数,指定在presetColors数组元素个数.这是因为在blendPositions数组的元素个数.

 

返回值

 

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

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

 

备注

 

一个简单的路径渐变刷有两种颜色:边界颜色和中心颜色.当你用这种画笔作画时,当你从边界路径移动到中心点时,颜色从边界颜色逐渐变为中心颜色.您可以通过指定预置颜色数组和混合位置数组来创建更复杂的渐变.

 

引用文件

 

CGpBrush.inc (include CGdiPlus.inc)

 

示例

 

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

' The following example creates a PathGradientBrush object based on a triangular path. The

' PathGradientBrush.SetInterpolationColors method sets the brush's preset colors to red,

' blue, and aqua and sets the blend positions to 0, 0, 4, and 1. The Graphics.FillRectangle

' method uses the path gradient brush to paint a rectangle that contains the triangular path.

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

SUB Example_SetInterpolationColors (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(100, 0), GDIP_POINT(200, 200), GDIP_POINT(0, 200)}

  DIM pthGrBrush AS CGpPathGradientBrush = CGpPathGradientBrush(@points(0), 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)}

  DIM positions(0 TO 2) AS SINGLE = {0.0, 0.4, 1.0}

 

  pthGrBrush.SetInterpolationColors(@colors(0), @positions(0), 3)

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

 

END SUB

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