;coded by UEZ build 2014-04-28, idea taken from http://codepen.io/noahblon/pen/KwiFg
;AutoIt v3.3.9.21 or higher needed!
#include <Array.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
_GDIPlus_Startup()
Global Const $STM_SETIMAGE = 0x0172; $IMAGE_BITMAP = 0
Global $iW = 600, $iH = 300
Global Const $hGUI = GUICreate("Carousel", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()
Global $hHBmp_BG, $hB, $iPerc = 0, $iSleep = 10, $iPerc = 0
GUIRegisterMsg($WM_TIMER, "PlayAnim")
DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0)
Do
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
GUIRegisterMsg($WM_TIMER, "")
_WinAPI_DeleteObject($hHBmp_BG)
_GDIPlus_Shutdown()
GUIDelete()
Exit
EndSwitch
Until False
Func PlayAnim()
$hHBmp_BG = _GDIPlus_Carousel($iPerc, $iW, $iH)
$hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG)
If $hB Then _WinAPI_DeleteObject($hB)
_WinAPI_DeleteObject($hHBmp_BG)
$iPerc += 0.2
If $iPerc > 99.9 Then $iPerc = 0
EndFunc ;==>PlayAnim
Func _GDIPlus_Carousel($fPerc, $iW, $iH, $bHBitmap = True)
Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hGfx, 4 + (@OSBuild > 5999))
;~ _GDIPlus_GraphicsSetTextRenderingHint($hGfx, 3)
_GDIPlus_GraphicsSetPixelOffsetMode($hGfx, 4)
_GDIPlus_GraphicsClear($hGfx, 0xFFFFFFFF)
Local Const $iUB = 4
Local $aColors[$iUB][4] = [[0xD8F4B401, 0xE8CF9902], [0xD8E3746C, 0xE8C1645C], [0xD83A7BF9, 0xE8326AD4], [0xD8109D59, 0xE80E864C]]
Local Const $fRadius = 50, $fMid = ($iW - $fRadius) / 2
Local Const $hBrush = _GDIPlus_BrushCreateSolid(), $hPen = _GDIPlus_PenCreate(0x80000000)
Local Const $hPath1 = _GDIPlus_PathCreate(), $hPath2 = _GDIPlus_PathCreate()
Local $hRegion1, $hRegion2, $fPenSize, $i
Local Static $fSpeed
For $i = 0 To $iUB - 1
$aColors[$i][2] = -Sin($fSpeed + $i * 1.570796) * 15 ;z coordinate, 1.570796 = Pi/2 = 90?= 360?/ 4
$aColors[$i][3] = $fMid + Cos($fSpeed + $i * 1.570796) * 80 ;x coordinate
Next
_ArraySort($aColors, 0, 0, 0, 2) ;sort z-axis
For $i = 0 To $iUB - 1
$fPenSize = $aColors[$i][2] / 20 + 1.1
_GDIPlus_PenSetWidth($hPen, $fPenSize)
_GDIPlus_BrushSetSolidColor($hBrush, 0x80E0E0E0) ;shadow color
_GDIPlus_GraphicsFillEllipse($hGfx, $aColors[$i][3], ($iH - $fRadius) / 2 + 10 + $fRadius + $aColors[$i][2], $fRadius + $aColors[$i][2], ($fRadius + $aColors[$i][2]) / 4, $hBrush)
_GDIPlus_PathAddEllipse($hPath1, $aColors[$i][3], ($iH - $fRadius) / 2, $fRadius + $aColors[$i][2], $fRadius + $aColors[$i][2])
_GDIPlus_PathAddEllipse($hPath2, $aColors[$i][3] + $fPenSize - 5 - $aColors[$i][2] / 10, ($iH - $fRadius) / 2 - $fPenSize - 5 - $aColors[$i][2] / 10, $fRadius + $aColors[$i][2], $fRadius + $aColors[$i][2])
$hRegion1 = _GDIPlus_RegionCreateFromPath($hPath1)
$hRegion2 = _GDIPlus_RegionCreateFromPath($hPath2)
_GDIPlus_RegionCombineRegion($hRegion1, $hRegion2, 1) ;combine lighter circle with darker circle
_GDIPlus_BrushSetSolidColor($hBrush, $aColors[$i][1]) ;lighter ball color
_GDIPlus_GraphicsFillPath($hGfx, $hPath1, $hBrush)
_GDIPlus_BrushSetSolidColor($hBrush, $aColors[$i][0]) ;darker ball color
_GDIPlus_GraphicsFillRegion($hGfx, $hRegion1, $hBrush)
_GDIPlus_GraphicsDrawPath($hGfx, $hPath1, $hPen) ;draw circle frame
_GDIPlus_RegionDispose($hRegion1)
_GDIPlus_RegionDispose($hRegion2)
_GDIPlus_PathReset($hPath1)
_GDIPlus_PathReset($hPath2)
Next
$fSpeed += 0.0261799
Local $iW_Progressbar = $iW / 2 + 4
_GDIPlus_PenSetColor($hPen, 0xD048D1CC)
_GDIPlus_GraphicsDrawRect($hGfx, ($iW - $iW_Progressbar) / 2, $iH - 50, $iW_Progressbar, 14, $hPen)
_GDIPlus_BrushSetSolidColor($hBrush, 0xFFAFEEEE)
_GDIPlus_GraphicsFillRect($hGfx, ($iW - $iW_Progressbar) / 2 + 2, $iH - 48, $fPerc * ($iW_Progressbar - 4) / 100, 10, $hBrush)
_GDIPlus_PenSetColor($hPen, 0x20000000)
_GDIPlus_GraphicsDrawRect($hGfx, 0, 0, $iW, $iH, $hPen) ;draw window frame
_GDIPlus_PathDispose($hPath1)
_GDIPlus_PathDispose($hPath2)
_GDIPlus_PenDispose($hPen)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hGfx)
If $bHBitmap Then
Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
_GDIPlus_BitmapDispose($hBitmap)
Return $hHBITMAP
EndIf
Return $hBitmap
EndFunc