Search the Community
Showing results for tags 'Double buffer'.
-
I wrote this after seeing Jerome Herr's post on Tumblr and looking at the code here. A few Google searches later, I came up with these. #include <GDIPlus.au3> #include <Math.au3> ;~ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w- 7 Opt("GUIOnEventMode", 1) Global Const $nPI = 3.1415926535897932384626433832795 Global Const $nTWOPI = $nPI * 2 Global $iNum = 25 Global $nStep, $nSz, $nTheta $nStep = 20 Global $iMaxRad = ($iNum - 1) * $nStep Global $fClose = False Global $iW = $iMaxRad, $iH = $iMaxRad Global $hGUI = GUICreate('"Wave" by Jerome Herr | Written in AutoIt3 by EyeZiS', $iW, $iH) GUISetOnEvent(-3, "_Exit") _GDIPlus_Startup() Global $hCtxt = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hCtxt) Global $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) Global $hPen = _GDIPlus_PenCreate(0xFFFFFFFF, 3, 2) Global $hTimer = TimerInit() GUISetState() While Not $fClose If TimerDiff($hTimer) >= 33 Then $hTimer = TimerInit() _Draw() _GDIPlus_GraphicsDrawImage($hCtxt, $hBitmap, 0, 0) ConsoleWrite(TimerDiff($hTimer) & @CRLF) EndIf Sleep(33 - TimerDiff($hTimer) - 1) WEnd _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hCtxt) GUIDelete() Func _Draw() _GDIPlus_GraphicsClear($hGraphics, 0xFF000000) Local $nArcEnd, $nOffset, $nDrawOffset For $i = 0 To $iNum - 1 $nSz = $i * $nStep $nOffset = $nTWOPI / $iNum * $i $nDrawOffset = $iMaxRad / 2 - $nSz / 2 $nArcEnd = _Degree(_Map(Sin($nTheta + $nOffset), -1, 1, $nPI, $nTWOPI) - $nPI) _GDIPlus_GraphicsDrawArc($hGraphics, $nDrawOffset, $nDrawOffset, $nSz, $nSz, 0, $nArcEnd, $hPen) _GDIPlus_GraphicsDrawArc($hGraphics, $nDrawOffset, $nDrawOffset, $nSz, $nSz, 180, $nArcEnd, $hPen) Next $nTheta += 0.0523 If $nTheta > $nTWOPI Then $nTheta = Mod($nTheta, $nTWOPI) EndIf EndFunc ;==>_Draw Func _Exit() $fClose = True EndFunc ;==>_Exit Func _Map($nVar, $nMin1, $nMax1, $nMin2, $nMax2) Return $nMin2 + ($nMax2 - $nMin2) * (($nVar - $nMin1) / ($nMax1 - $nMin1)) EndFunc ;==>_Map Playing with hue: #include <GDIPlus.au3> #include <Math.au3> #include <WinAPIGdi.au3> ;~ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w- 7 Opt("GUIOnEventMode", 1) Global Const $nPI = 3.1415926535897932384626433832795 Global Const $nTWOPI = $nPI * 2 Global $iNum = 25 Global $nStep, $nSz, $nTheta Global $iStHue = 0 $nStep = 20 Global $iMaxRad = ($iNum - 1) * $nStep Global $fClose = False Global $iW = $iMaxRad, $iH = $iMaxRad Global $hGUI = GUICreate('"Wave" by Jerome Herr | Written in AutoIt3 by EyeZiS', $iW, $iH) GUISetOnEvent(-3, "_Exit") _GDIPlus_Startup() Global $hCtxt = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hCtxt) Global $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) Global $hPen = _GDIPlus_PenCreate(0xFFFFFFFF, 3, 2) Global $hTimer = TimerInit() GUISetState() While Not $fClose If TimerDiff($hTimer) >= 33 Then $hTimer = TimerInit() _Draw() _GDIPlus_GraphicsDrawImage($hCtxt, $hBitmap, 0, 0) ConsoleWrite("Draw: " & TimerDiff($hTimer) & @CRLF) EndIf Sleep(33 - TimerDiff($hTimer) - 1) WEnd _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hCtxt) GUIDelete() Func _Draw() _GDIPlus_GraphicsClear($hGraphics, 0x7F000000) Local $nArcEnd, $nOffset, $nDrawOffset For $i = 0 To $iNum - 1 $nSz = $i * $nStep $nOffset = $nTWOPI / $iNum * $i $nDrawOffset = $iMaxRad / 2 - $nSz / 2 $nArcEnd = _Degree(_Map(Sin($nTheta + $nOffset), -1, 1, $nPI, $nTWOPI) - $nPI) _GDIPlus_PenSetColor($hPen, "0xFF" & Hex(_WinAPI_ColorHLSToRGB($iStHue + $i, 120, 240), 6)) _GDIPlus_GraphicsDrawArc($hGraphics, $nDrawOffset, $nDrawOffset, $nSz, $nSz, 0, $nArcEnd, $hPen) _GDIPlus_GraphicsDrawArc($hGraphics, $nDrawOffset, $nDrawOffset, $nSz, $nSz, 180, $nArcEnd, $hPen) Next $nTheta += 0.0523 $iStHue += 0.5 _ModIfGreater($nTheta, $nTWOPI) _ModIfGreater($iStHue, 239) EndFunc ;==>_Draw Func _Exit() $fClose = True EndFunc ;==>_Exit Func _Map($nVar, $nMin1, $nMax1, $nMin2, $nMax2) Return $nMin2 + ($nMax2 - $nMin2) * (($nVar - $nMin1) / ($nMax1 - $nMin1)) EndFunc ;==>_Map Func _ModIfGreater(ByRef $nVar, $nMod) $nVar = ($nVar > $nMod) ? (Mod($nVar, $nMod)) : ($nVar) EndFunc >#6 - Trunk in space >#7 - Lava Lamp >#8 - Wavy Thing
- 10 replies
-
- GDI+
- Double buffer
-
(and 1 more)
Tagged with: