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

GetInterpolationColorCount

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

描述

 

获取当前为该路径渐变画笔指定的预设颜色数.

 

C++ Syntax

 

INT GetInterpolationColorCount() const;

 

FreeBASIC 语法

 

FUNCTION GetInterpolationColorCount () AS INT_

 

参数

 

该方法没有参数.

 

返回值

 

此方法返回当前为该路径渐变画笔指定的预设颜色数.

 

备注

 

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

你可以得到插值颜色插值位置目前设定为PathGradientBrush对象通过调用对象的方法,PathGradientBrush PathGradientBrush.GetInterpolationColors.在你打电话的PathGradientBrush.GetInterpolationColors方法,你必须分配缓冲:一个拥有插值颜色数组和一个持有插值位置的数组.你可以调用该对象的PathGradientBrush.GetInterpolationColorCount PathGradientBrush方法来确定所需的缓冲区大小.的颜色缓冲区的大小是GetInterpolationColorCount乘以4的返回值.位置的缓冲区的大小是PathGradientBrush.GetInterpolationColorCount数值乘以4(一个简单的精度数的大??

 

引用文件

 

CGpBrush.inc (include CGdiPlus.inc)

 

示例

 

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

' The following example creates a PathGradientBrush object from a triangular path. The code

' sets the preset colors to red, blue, and aqua and sets the blend positions to 0, 0.6, and 1.

' The code calls the PathGradientBrush.GetInterpolationColorCount method of the PathGradientBrush

' object to obtain the number of preset colors currently set for the brush. Next, the code

' allocates two buffers: one to hold the array of preset colors, and one to hold the array

' of blend positions. The call to the PathGradientBrush.GetInterpolationColors method of

' the PathGradientBrush object fills the buffers with the preset colors and the blend positions.

' Finally the code fills a small square with each of the preset colors.

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

SUB Example_GetInterpolationColors (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.6, 1.0}

 

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

 

  ' // Obtain information about the path gradient brush.

  DIM colorCount AS LONG = pthGrBrush.GetInterpolationColorCount

  DIM rgColors(colorCount - 1) AS ARGB

  DIM rgPositions(colorCount - 1) AS SINGLE

  pthGrBrush.GetInterpolationColors(@rgColors(0), @rgPositions(0), colorCount)

 

  ' // Fill a small square with each of the interpolation colors.

  DIM solidBrush AS CGpSolidBrush = GDIP_ARGB(255, 255, 255, 255)

 

  FOR j AS LONG = 0 TO colorCount - 1

     solidBrush.SetColor(rgColors(j))

     graphics.FillRectangle(@solidBrush, 15 * j, 0, 10, 10)

  NEXT

 

END SUB

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