
#include <GDIP.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('GUIOnEventMode', 1)

Global $iWidth = @DesktopWidth
Global $iHeight = @DesktopHeight

_GDIPlus_Startup()

Global $hGui = GUICreate("Test", $iWidth, $iHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")
GUISetState(@SW_SHOW)

Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)

GUIRegisterMsg($WM_PAINT, "WM_PAINT")
GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")

Global $hPath = _Path("ABCDEFGHI" & @LF & "JKLMNOPQR" & @LF & "STUVWXYZ",150,"Arial")

_GDIPlus_GraphicsClear($hGfxBuffer,0xFF1F1F1F)
While 1
	_Draw($hPath,$iWidth/2, $iHeight*0.8, 0xFFFFFFFF, 0x04000000)
WEnd


Func _Draw($hPath, $iBaseX, $iBaseY, $nColor, $nColorBK)
	Local $hBmpLine=_GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
	Local $hGfxLine=_GDIPlus_ImageGetGraphicsContext($hBmpLine)
	If Not $iBaseX Then $iBaseX=@DesktopWidth/2
	If Not $iBaseY Then $iBaseY=@DesktopHeight/2
	Local $aPoints=_GDIPlus_PathGetData($hPath)

	Local $hPenDel=_GDIPlus_PenCreate($nColorBK,5)
	Local $hPenDraw=_GDIPlus_PenCreate($nColor,4)
	Local $aPenLine[11]
	For $i=1 To 10
		$aPenLine[$i]=_GDIPlus_PenCreate(BitOR(BitShift(0xFF*((10-$i)/10), -24),BitXOR(0xFF000000,$nColor)),1)
	Next

	Local $iStart=1, $iCnt, $aTemp
	Local $hPathDraw, $aPointDraw=$aPoints

	For $i=1 To $aPoints[0][0]
		If $aPoints[$i][2] = 0 Then
			$iStart=$i
			ContinueLoop
		EndIf
		_GDIPlus_PathDispose($hPathDraw)
		$iCnt=0
		For $j=$iStart To $i
			$iCnt+=1
			$aPointDraw[$iCnt][0]=$aPoints[$j][0]
			$aPointDraw[$iCnt][1]=$aPoints[$j][1]
			$aPointDraw[$iCnt][2]=$aPoints[$j][2]
		Next
		$aPointDraw[0][0]=$iCnt
		$hPathDraw=_GDIPlus_PathCreate2($aPointDraw,0)
		$aTemp=_GDIPlus_PathGetData($hPathDraw)
		If Not IsArray($aTemp) Then ContinueLoop
		_GDIPlus_GraphicsDrawPath($hGfxBuffer, $hPath, $hPenDel)
		_GDIPlus_GraphicsDrawPath($hGfxBuffer, $hPathDraw, $hPenDraw)
		_GDIPlus_GraphicsDrawImage($hGfxLine, $hBmpBuffer,0,0)
		For $j=1 To 9
			If $i-$j>1 Then _GDIPlus_GraphicsDrawLine($hGfxLine,$iBaseX, $iBaseY, $aPoints[$i-$j][0], $aPoints[$i-$j][1], $aPenLine[$j])
		Next
		_GDIPlus_GraphicsDrawLine($hGfxLine,$iBaseX, $iBaseY, $aPoints[$i][0], $aPoints[$i][1], $aPenLine[10])
		_GDIPlus_GraphicsDrawImage($hGraphics, $hBmpLine,0,0)
	Next
	_GDIPlus_PathDispose($hPathDraw)
	For $i=1 To 10
		_GDIPlus_PenDispose($aPenLine[$i])
	Next
	_GDIPlus_PenDispose($hPenDel)
	_GDIPlus_PenDispose($hPenDraw)
	_GDIPlus_GraphicsDispose($hGfxLine)
	_GDIPlus_BitmapDispose($hBmpLine)
EndFunc


Func _Path($sText, $nS=20, $sFont="Arial")
	Local $hFamily = _GDIPlus_FontFamilyCreate($sFont)
	Local $hFormat = _GDIPlus_StringFormatCreate()
	Local $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)
	Local $hPath=_GDIPlus_PathCreate($FillModeWinding)
	_GDIPlus_PathAddString($hPath, $sText, $tLayout, $hFamily, 0, $nS, $hFormat)
	_GDIPlus_FontFamilyDispose($hFamily)
	_GDIPlus_StringFormatDispose($hFormat)
	Return $hPath
EndFunc

Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
	_GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer,0,0)
	Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_PAINT

Func WM_ERASEBKGND($hWnd, $uMsgm, $wParam, $lParam)
	_GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer,0,0)
	Return True
EndFunc   ;==>WM_ERASEBKGND


Func _Exit()
	_GDIPlus_GraphicsDispose($hGfxBuffer)
	_GDIPlus_BitmapDispose($hBmpBuffer)
	_GDIPlus_GraphicsDispose($hGraphics)
	_GDIPlus_Shutdown()
	GUIDelete($hGui)
	Exit
EndFunc   ;==>_Exit