Sets the blend factors and the blend positions of a linear gradient brush to create a custom blend
#include <GDIPlus.au3>
_GDIPlus_LineBrushSetBlend ( $hLineGradientBrush, $aBlends )
$hLineGradientBrush | Pointer to a LinearGradientBrush object |
$aBlends | Array of blend factors and blend positions: [0][0] - Number of blend factors and blend positions, must be at least 2 [1][0] - Factor 1 [1][1] - Position 1 [2][0] - Factor 2 [2][1] - Position 2 [n][0] - Factor n [n][1] - Position n |
Success: | True. |
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPIP_ERR* see GPIPlusConstants.au3). |
Each factor in the array specifies a percentage of the ending color and should be in the range 0.0 to 1.0.
Each position in the array indicates a percentage of the distance between the starting boundary and the ending boundary and is in the range 0.0 to 1.0, where 0.0 indicates the starting boundary of the gradient and 1.0 indicates the ending boundary.
Search GdipSetLineBlend in MSDN Library.
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
Example()
Func Example()
_GDIPlus_Startup() ;initialize GDI+
Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ;$iBgColor format RRGGBB
Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
GUISetState(@SW_SHOW)
Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
_GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
Local $hBrush = _GDIPlus_LineBrushCreate(0, 0, 280, 570, 0xFFFFFF00, 0xFF4020FF, 1) ;create linear gradient flipped brush
Local $aBlends[5][2]
$aBlends[0][0] = 4 ; Using 4 factors and position
$aBlends[1][0] = 0 ; Factor
$aBlends[1][1] = 0 ; Position
$aBlends[2][0] = 1 ; The percentage of the blending is 100% (red to green is gradually completed in just 20% from the left)
$aBlends[2][1] = 0.2 ; The distance percentage from the left boundary of the brush is 20%
$aBlends[3][0] = 0 ; The percentage of the blending is 0% (green to red is gradually completed from 20% to 70% from the left)
$aBlends[3][1] = 0.7 ; The distance percentage from the left boundary of the brush is 70%
$aBlends[4][0] = 1 ; The percentage of the blending is 100% (red to green is gradually completed from 70% to 100% from the left)
$aBlends[4][1] = 1 ; The distance percentage from the left boundary of the brush is 100%
_GDIPlus_LineBrushSetBlend($hBrush, $aBlends); set the linear gradient brush color positions and factors
_GDIPlus_GraphicsFillEllipse($hGraphics, 100, 50, 380, 500, $hBrush) ;draw the egg
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
;cleanup GDI+ resources
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown()
GUIDelete($hGUI)
EndFunc ;==>Example