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

SetFocusScales

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

描述

 

Sets the focus scales of this path gradient brush.

 

C++ Syntax

 

Status SetFocusScales(

[in]  REAL xScale,

[in]  REAL yScale

);

 

FreeBASIC 语法

 

FUNCTION SetFocusScales ( _

   BYVAL xScale AS SINGLE, _

   BYVAL yScale AS SINGLE _

) AS GpStatus

 

参数

 

xScale

 

[in] Simple precision number that specifies the x focus scale.

 

yScale

 

[in] Simple precision number that specifies the y focus scale.

 

返回值

 

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

 

If the method fails, it returns one of the other elements of the Status enumeration.

 

备注

 

By default, the center color of a path gradient is at the center point. By calling PathGradientBrush.SetFocusScales, you can specify that the center color should appear along a path that surrounds the center point. That path is the boundary path scaled by a factor of xScale in the x direction and by a factor of yScale in the y direction. The area inside the scaled path is filled with the center color.

 

Include File

 

CGpBrush.inc (include CGdiPlus.inc)

 

示例

 

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

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

' code calls the PathGradientBrush::SetFocusScales method of the PathGradientBrush object

' to set the brush's focus scales to (0.2, 0.2). Then the code uses the path gradient brush

' to paint a rectangle that includes the triangular path.

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

SUB Example_SetFocusScales (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)}

 

  ' // No GraphicsPath object is created. The PathGradientBrush

  ' // object is constructed directly from the array of points.

  DIM pthGrBrush AS CGpPathGradientBrush = CGpPathGradientBrush(@points(0), 3)

 

  DIM colors(0 TO 1) AS ARGB = {GDIP_ARGB(255, 255, 0, 0), GDIP_ARGB(255, 0, 0, 255)}

 

  ' // red at the boundary of the outer triangle

  ' // blue at the boundary of the inner triangle

  DIM relativePositions(0 TO 1) AS SINGLE = {0.0, 1.0}

  pthGrBrush.SetInterpolationColors(@colors(0), @relativePositions(0), 2)

 

  ' // The inner triangle is formed by scaling the outer triangle

  ' // about its centroid. The scaling factor is 0.2 in both the x and y directions.

  pthGrBrush.SetFocusScales(0.2, 0.2)

 

  ' // Fill a rectangle that is larger than the triangle

  ' // specified in the Point array. The portion of the

  ' // rectangle outside the triangle will not be painted.

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

 

END SUB

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