Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <WinAPI.au3>
- #include <GDIPlus.au3>
- #include <misc.au3>
- #include <WindowsConstants.au3>
- #include <Array.au3>
- ; gdiplus
- Global $g_hGfxCtxt, $hDC, $hHBitmap, $buffer
- Global $hPenCircle, $hPenRed, $hPenGreen, $hBrushRed
- Global $cBackground = 0xFFFFFFFF
- Global $tTime = TimerInit()
- Global Const $PI = 3.14159
- Global $oA = Random(0, $PI*2), $oB = Random(0, $PI*2)
- ; gui
- Global $GuiW = 800, $GuiH = 800
- Global $size = 700, $center_x = $GuiW / 2, $center_y = $GuiH / 2
- $GUI = GUICreate("test", $GuiW, $GuiH)
- GUISetState()
- _Graphic_StartUp()
- While 1
- Draw()
- Switch GUIGetMsg()
- Case - 3
- Exit
- EndSwitch
- WEnd
- Func Draw()
- _GDIPlus_GraphicsClear($g_hGfxCtxt, $cBackground)
- _GDIPlus_GraphicsDrawEllipse($g_hGfxCtxt, $center_x - $size / 2, $center_y - $size / 2, $size, $size, $hPenCircle)
- Local $oS = $oA - $oB
- $oS = ($oS < 0 ? $PI * 2 + $oS : ($oS > $PI*2 ? Mod($oS, $PI*2) : $oS))
- Local $color = $hPenRed
- If $oS > $PI Then
- $oS = -($PI*2 - $oS)
- $color = $hPenGreen
- EndIf
- _GDIPlus_GraphicsDrawArc($g_hGfxCtxt, $center_x - $size / 2, $center_y - $size / 2, $size , $size, 360-(($oB / ($PI*2)) * 360) + 90, -(($oS / ($PI*2)) * 360), $color)
- _GDIPlus_GraphicsFillRect($g_hGfxCtxt, $center_x + Sin($oA) * $size / 2 - 10, $center_y + Cos($oA) * $size / 2 - 10, 20, 20, $hBrushRed)
- _GDIPlus_GraphicsFillRect($g_hGfxCtxt, $center_x + Sin($oB) * $size / 2 - 10, $center_y + Cos($oB) * $size / 2 - 10, 20, 20, $hBrushRed)
- If TimerDiff($tTime) > 2500 Then
- $tTime = TimerInit()
- $oB = Random(0, $PI * 2)
- EndIf
- $oa += 0.05
- If $oa > $PI*2 Then $oa = 0
- _WinAPI_BitBlt($hDC, 0, 0, $GuiW, $GuiH, $buffer, 0, 0, $SRCCOPY)
- EndFunc
- Func _Graphic_StartUp()
- _GDIPlus_Startup()
- ; install gdi
- $hDC = _WinAPI_GetDC($GUI)
- $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $GuiW, $GuiH)
- $buffer = _WinAPI_CreateCompatibleDC($hDC)
- _WinAPI_SelectObject($buffer, $hHBitmap)
- $g_hGfxCtxt = _GDIPlus_GraphicsCreateFromHDC($buffer)
- _GDIPlus_GraphicsSetSmoothingMode($g_hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
- _GDIPlus_GraphicsSetPixelOffsetMode($g_hGfxCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)
- $hPenCircle = _GDIPlus_PenCreate(0xFF222222, 1)
- $hPenRed = _GDIPlus_PenCreate(0xFFEE1111, 6)
- $hPenGreen = _GDIPlus_PenCreate(0xFF11EE11, 6)
- $hBrushRed = _GDIPlus_BrushCreateSolid(0xFFEE1111)
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement