Hier die Funktion und ein Beispiel dazu.
Benötigt wird die GDIP.au3 (Anhang).
Ich hoffe, dass irgendjemand das gebrauchen kann. Ich enstschuldige mich schon mal im vorraus für die schlecht formulierte Beschreibung.
Funktion:
Spoiler anzeigen
; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_PathBrushCreatePie
; Beschreibung ..: Erstellt einen Farbverlauf in Form eines "Kuchens" (Teil eines Kreises) mit 2 Farben eine beginnend in der Mitte der Ellipse aus der der "Kuchen" erstellt wird und eine die auf dem Umkreis der Ellipse verläuft.
; Syntax.........: _GDIPlus_PathBrushCreatePie($iX, $iY, $iWidth, $iHeight, $iStartAngle, $iSweepAngle, $ARGB_Center, $ARGB_Surround, [$iWrapMode = 4])
; Parameter .....: $iX - X - Koordinate der linken oberen Ecke des Rechtecks aus dem die Ellipse des Kuchenstücks erstellt wird
; $iY - Y - Koordinate der linken oberen Ecke des Rechtecks aus dem die Ellipse des Kuchensstücks erstellt wird
; $iWidth - Breite der Ellipse
; $iHeight - Höhe der Ellipse
; $iStartAngle - Startwinkel des Kuchenstücks
; $iSweepAngle - Winkel der zum Startwinkel addiert wird und den Endwinkel bestimmt (Ein negativer Wert bedeutet eine "Rotation" nach links)
; $ARGB_Center - Farbe für den Mittelpunkt der Ellipse
; $ARGB_Surround - Farbe für den Umkreis der Ellipse
; $iWrapMode - Wrap mode der die Aufteilung und die Spiegelung des Brushes definiert (Standard 4):
; |0 - Teilen ohne spiegeln
; |1 - Teile werden horizontal gespiegelt wenn die Größe des Brush in X Richtung überschritten wird
; |2 - Teile werden vertikal gespiegelt wenn die Größe des Brush in Y Richtung überschritten wird
; |3 - Kombination aus 1 und 2
; |4 - Keine Teilung
; Rückgabewerte .: Success - Pointer zu einem neuen Brush Objekt
; Failure - -1 und setzt @error:
; |1 - $iSweepAngle ist = 0
; Bemerkungen ...: Um die Ressourcen für den Brush freizugeben, muss _GDIPlus_BrushDispose aufgerufen werden
; Autor .........: name22 @ http://www.autoit.de/
; ===============================================================================================================================
Func _GDIPlus_PathBrushCreatePie($iX, $iY, $iWidth, $iHeight, $iStartAngle, $iSweepAngle, $ARGB_Center, $ARGB_Surround, $iWrapMode = 4)
Local Const $Pi_Div_180 = ACos(-1) / 180
If $iStartAngle <= 0 Then $iStartAngle = 1
If $iSweepAngle = 0 Then Return SetError(1, 0, -1)
If $iSweepAngle < 0 Then
$iSweepAngle *= -1
$iStartAngle = 360 - $iSweepAngle + $iStartAngle
EndIf
Dim $aPoints_Path[$iSweepAngle + 2][2]
$aPoints_Path[0][0] = $iSweepAngle + 1
$iI = 1
For $i = $iStartAngle To $iStartAngle + $iSweepAngle - 1
$aPoints_Path[$iI][0] = $iX + $iWidth / 2 + Cos(($i - 90) * $Pi_Div_180) * $iWidth / 2
$aPoints_Path[$iI][1] = $iY + $iHeight / 2 + Sin(($i - 90) * $Pi_Div_180) * $iHeight / 2
$iI += 1
Next
$aPoints_Path[UBound($aPoints_Path) - 1][0] = $iX + $iWidth / 2
$aPoints_Path[UBound($aPoints_Path) - 1][1] = $iY + $iHeight / 2
Dim $aColors_Path[$iSweepAngle + 1]
$aColors_Path[0] = $iSweepAngle
$iI = 1
For $i = $iStartAngle To $iStartAngle + $iSweepAngle - 1
$aColors_Path[$iI] = $ARGB_Surround
$iI += 1
Next
$hBrush_Pie = _GDIPlus_PathBrushCreate($aPoints_Path, $iWrapMode)
_GDIPlus_PathBrushSetCenterPoint($hBrush_Pie, $iX + $iWidth / 2, $iY + $iHeight / 2)
_GDIPlus_PathBrushSetCenterColor($hBrush_Pie, $ARGB_Center)
_GDIPlus_PathBrushSetSurroundColorsWithCount($hBrush_Pie, $aColors_Path)
Return $hBrush_Pie
EndFunc ;==>_GDIPlus_PathBrushCreatePie
Beispiel:
Spoiler anzeigen
#include <GDIP.au3>
#include <GUIConstants.au3>
$hWnd = GUICreate("Example by name22", 200, 200)
GUISetState()
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
_GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2)
$hBrush = _GDIPlus_PathBrushCreatePie(0, 0, 100, 100, 180, -270, 0xFFFF0000, 0x00000000)
$hBrush2 = _GDIPlus_PathBrushCreatePie(0, 100, 100, 100, 90, 270, 0xFF0000FF, 0x00000000)
_GDIPlus_GraphicsFillRect($hGraphic, 0, 0, 100, 100, $hBrush)
_GDIPlus_GraphicsFillRect($hGraphic, 0, 100, 100, 100, $hBrush2)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_BrushDispose($hBrush2)
_GDIPlus_Shutdown()
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_PathBrushCreatePie
; Beschreibung ..: Erstellt einen Farbverlauf in Form eines "Kuchens" (Teil eines Kreises) mit 2 Farben eine beginnend in der Mitte der Ellipse aus der der "Kuchen" erstellt wird und eine die auf dem Umkreis der Ellipse verläuft.
; Syntax.........: _GDIPlus_PathBrushCreatePie($iX, $iY, $iWidth, $iHeight, $iStartAngle, $iSweepAngle, $ARGB_Center, $ARGB_Surround, [$iWrapMode = 4])
; Parameter .....: $iX - X - Koordinate der linken oberen Ecke des Rechtecks aus dem die Ellipse des Kuchenstücks erstellt wird
; $iY - Y - Koordinate der linken oberen Ecke des Rechtecks aus dem die Ellipse des Kuchensstücks erstellt wird
; $iWidth - Breite der Ellipse
; $iHeight - Höhe der Ellipse
; $iStartAngle - Startwinkel des Kuchenstücks
; $iSweepAngle - Winkel der zum Startwinkel addiert wird und den Endwinkel bestimmt (Ein negativer Wert bedeutet eine "Rotation" nach links)
; $ARGB_Center - Farbe für den Mittelpunkt der Ellipse
; $ARGB_Surround - Farbe für den Umkreis der Ellipse
; $iWrapMode - Wrap mode der die Aufteilung und die Spiegelung des Brushes definiert (Standard 4):
; |0 - Teilen ohne spiegeln
; |1 - Teile werden horizontal gespiegelt wenn die Größe des Brush in X Richtung überschritten wird
; |2 - Teile werden vertikal gespiegelt wenn die Größe des Brush in Y Richtung überschritten wird
; |3 - Kombination aus 1 und 2
; |4 - Keine Teilung
; Rückgabewerte .: Success - Pointer zu einem neuen Brush Objekt
; Failure - -1 und setzt @error:
; |1 - $iSweepAngle ist = 0
; Bemerkungen ...: Um die Ressourcen für den Brush freizugeben, muss _GDIPlus_BrushDispose aufgerufen werden
; Autor .........: name22 @ http://www.autoit.de/
; ===============================================================================================================================
Func _GDIPlus_PathBrushCreatePie($iX, $iY, $iWidth, $iHeight, $iStartAngle, $iSweepAngle, $ARGB_Center, $ARGB_Surround, $iWrapMode = 4)
Local Const $Pi_Div_180 = ACos(-1) / 180
If $iStartAngle <= 0 Then $iStartAngle = 1
If $iSweepAngle = 0 Then Return SetError(1, 0, -1)
If $iSweepAngle < 0 Then
$iSweepAngle *= -1
$iStartAngle = 360 - $iSweepAngle + $iStartAngle
EndIf
Dim $aPoints_Path[$iSweepAngle + 2][2]
$aPoints_Path[0][0] = $iSweepAngle + 1
$iI = 1
For $i = $iStartAngle To $iStartAngle + $iSweepAngle - 1
$aPoints_Path[$iI][0] = $iX + $iWidth / 2 + Cos(($i - 90) * $Pi_Div_180) * $iWidth / 2
$aPoints_Path[$iI][1] = $iY + $iHeight / 2 + Sin(($i - 90) * $Pi_Div_180) * $iHeight / 2
$iI += 1
Next
$aPoints_Path[UBound($aPoints_Path) - 1][0] = $iX + $iWidth / 2
$aPoints_Path[UBound($aPoints_Path) - 1][1] = $iY + $iHeight / 2
Dim $aColors_Path[$iSweepAngle + 1]
$aColors_Path[0] = $iSweepAngle
$iI = 1
For $i = $iStartAngle To $iStartAngle + $iSweepAngle - 1
$aColors_Path[$iI] = $ARGB_Surround
$iI += 1
Next
$hBrush_Pie = _GDIPlus_PathBrushCreate($aPoints_Path, $iWrapMode)
_GDIPlus_PathBrushSetCenterPoint($hBrush_Pie, $iX + $iWidth / 2, $iY + $iHeight / 2)
_GDIPlus_PathBrushSetCenterColor($hBrush_Pie, $ARGB_Center)
_GDIPlus_PathBrushSetSurroundColorsWithCount($hBrush_Pie, $aColors_Path)
Return $hBrush_Pie
EndFunc ;==>_GDIPlus_PathBrushCreatePie