Advertisement
thedemonsmsc

Untitled

Sep 24th, 2019
790
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.38 KB | None | 0 0
  1.  
  2. #include <WinAPI.au3>
  3. #include <GDIPlus.au3>
  4. #include <misc.au3>
  5. #include <WindowsConstants.au3>
  6. #include <Array.au3>
  7.  
  8. ; gdiplus
  9. Global $g_hGfxCtxt, $hDC, $hHBitmap, $buffer
  10. Global $hPenCircle, $hPenRed, $hPenGreen, $hBrushRed
  11. Global $cBackground = 0xFFFFFFFF
  12. Global $tTime = TimerInit()
  13.  
  14. Global Const $PI = 3.14159
  15. Global $oA = Random(0, $PI*2), $oB = Random(0, $PI*2)
  16.  
  17. ; gui
  18. Global $GuiW = 800, $GuiH = 800
  19. Global $size = 700, $center_x = $GuiW / 2, $center_y = $GuiH / 2
  20.  
  21. $GUI = GUICreate("test", $GuiW, $GuiH)
  22. GUISetState()
  23.  
  24. _Graphic_StartUp()
  25.  
  26.  
  27. While 1
  28.     Draw()
  29.  
  30.     Switch GUIGetMsg()
  31.         Case - 3
  32.             Exit
  33.     EndSwitch
  34. WEnd
  35.  
  36. Func Draw()
  37.  
  38.     _GDIPlus_GraphicsClear($g_hGfxCtxt, $cBackground)
  39.  
  40.     _GDIPlus_GraphicsDrawEllipse($g_hGfxCtxt, $center_x - $size / 2, $center_y - $size / 2, $size, $size, $hPenCircle)
  41.  
  42.     Local $oS = $oA - $oB
  43.     $oS = ($oS < 0 ? $PI * 2 + $oS : ($oS > $PI*2 ? Mod($oS, $PI*2) : $oS))
  44.  
  45.     Local $color = $hPenRed
  46.     If $oS > $PI Then
  47.         $oS = -($PI*2 - $oS)
  48.         $color = $hPenGreen
  49.     EndIf
  50.  
  51.     _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)
  52.  
  53.     _GDIPlus_GraphicsFillRect($g_hGfxCtxt, $center_x + Sin($oA) * $size / 2 - 10, $center_y + Cos($oA) * $size / 2 - 10, 20, 20, $hBrushRed)
  54.     _GDIPlus_GraphicsFillRect($g_hGfxCtxt, $center_x + Sin($oB) * $size / 2 - 10, $center_y + Cos($oB) * $size / 2 - 10, 20, 20, $hBrushRed)
  55.  
  56.     If TimerDiff($tTime) > 2500 Then
  57.         $tTime = TimerInit()
  58.         $oB = Random(0, $PI * 2)
  59.     EndIf
  60.  
  61.     $oa += 0.05
  62.     If $oa > $PI*2 Then $oa = 0
  63.  
  64.     _WinAPI_BitBlt($hDC, 0, 0, $GuiW, $GuiH, $buffer, 0, 0, $SRCCOPY)
  65. EndFunc
  66.  
  67.  
  68. Func _Graphic_StartUp()
  69.  
  70.     _GDIPlus_Startup()
  71.  
  72.     ; install gdi
  73.  
  74.     $hDC = _WinAPI_GetDC($GUI)
  75.     $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $GuiW, $GuiH)
  76.  
  77.     $buffer = _WinAPI_CreateCompatibleDC($hDC)
  78.     _WinAPI_SelectObject($buffer, $hHBitmap)
  79.  
  80.     $g_hGfxCtxt = _GDIPlus_GraphicsCreateFromHDC($buffer)
  81.     _GDIPlus_GraphicsSetSmoothingMode($g_hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
  82.     _GDIPlus_GraphicsSetPixelOffsetMode($g_hGfxCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)
  83.  
  84.     $hPenCircle = _GDIPlus_PenCreate(0xFF222222, 1)
  85.     $hPenRed = _GDIPlus_PenCreate(0xFFEE1111, 6)
  86.     $hPenGreen = _GDIPlus_PenCreate(0xFF11EE11, 6)
  87.     $hBrushRed = _GDIPlus_BrushCreateSolid(0xFFEE1111)
  88. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement