Glückwunsch an Tweaky
Beiträge von UEZ
-
-
Nice. Danke fürs Teilen.
Hast du den DLL Code in Rust geschrieben?
-
Die nächste Tipprunde (Europameisterschaft) ist nun am Start. Wer will kann hier mitmachen: https://www.kicktipp.de/autoit-em-wm/. Einfach kostenlos registrieren, tippen und Spaß haben.
Am 14.6. geht's los.
Viel Glück!
-
Man(n) kann auch GDI+ benutzen, um die Textur auf die Kugel zu projizieren.
Beispiel:
C
Alles anzeigen#include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global $hGUI, $iFPS = 0, $iShowFPS = 0, $bExit Global Const $iW = @DesktopWidth * 0.75, $iH = $iW * 10 / 16, $fRad = ACos(-1) / 180, $sTitle = "GDI+ Test" AutoItSetOption("GUIOnEventMode", 1) GDIPlus_BallTest() AutoItSetOption("GUIOnEventMode", 0) _GDIPlus_Shutdown() Func GDIPlus_BallTest() $bExit = False $hGUI = GUICreate($sTitle, $iW, $iH) GUISetState(@SW_SHOW, $hGUI) ;create canvas elements Local Const $hDC = _WinAPI_GetDC($hGUI) Local Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) Local Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Local Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap) Local Const $hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) _GDIPlus_GraphicsSetInterpolationMode($hCanvas, $GDIP_INTERPOLATIONMODE_NEARESTNEIGHBOR) _GDIPlus_GraphicsSetPixelOffsetMode($hCanvas, $GDIP_PIXELOFFSETMODE_HALF) Local Const $hBrush_Clr = _GDIPlus_BrushCreateSolid(0xFF000000), _ $hBrush_FPS = _GDIPlus_BrushCreateSolid(0xFFF0F0F0), _ $hFormat_FPS = _GDIPlus_StringFormatCreate(), _ $hFamily_FPS = _GDIPlus_FontFamilyCreate("Arial"), _ $hFont_FPS = _GDIPlus_FontCreate($hFamily_FPS, 8), _ $tLayout_FPS = _GDIPlus_RectFCreate(0, 0, 60, 16), _ $hImage_Ball = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\13h_310x156.bmp") , _ $hMatrix = _GDIPlus_MatrixCreate() Local $aDim = _GDIPlus_ImageGetDimension($hImage_Ball) Local Const $hTexture_Ball = _GDIPlus_TextureCreate($hImage_Ball) Local $iDiameter = $aDim[0] < $aDim[1] ? $aDim[0] : $aDim[1], _ $fDiameter2 = $iDiameter / 2, _ $fDX = 0, $fDY = 0 $iFPS = 0 GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit_About") AdlibRegister("CalcFPS", 1000) Local $iStep = 5, $vx = Random(), $vy = Random() Do _GDIPlus_GraphicsClear($hCanvas, 0xFF006600) DllCall($__g_hGDIPDll, "int", "GdipTranslateTextureTransform", "ptr", $hTexture_Ball, "float", $vx * 1.57, "float", $vy * 1.57, "long", 0) For $i = 1 To $fDiameter2 Step $iStep $fScale = 1 + $i / $fDiameter2 DllCall($__g_hGDIPDll, "int", "GdipSetMatrixElements", "handle", $hMatrix, "float", 1.0, "float", 0.0, "float", 0.0, "float", 1.0, "float", 0.0, "float", 0.0) DllCall($__g_hGDIPDll, "int", "GdipTranslateMatrix", "handle", $hMatrix, "float", $fDX + $fDiameter2, "float", $fDY + $fDiameter2, "int", 0) DllCall($__g_hGDIPDll, "int", "GdipScaleMatrix", "handle", $hMatrix, "float", $fScale, "float", $fScale, "int", 0) DllCall($__g_hGDIPDll, "int", "GdipTranslateMatrix", "handle", $hMatrix, "float", -$fDiameter2, "float", -$fDiameter2, "int", 0) DllCall($__g_hGDIPDll, "int", "GdipSetWorldTransform", "handle", $hCanvas, "handle", $hMatrix) DllCall($__g_hGDIPDll, "int", "GdipFillEllipse", "handle", $hCanvas, "handle", $hTexture_Ball, _ "float", $i, "float", $i, "float", $iDiameter -2 * $i, "float", $iDiameter - 2 * $i) Next $fDX += $vx $fDY += $vy If $fDX + $iDiameter > $iW Or $fDX < 0 Then $vx = -$vx If $fDY + $iDiameter > $iH Or $fDY < 0 Then $vy = -$vy DllCall($__g_hGDIPDll, "int", "GdipSetMatrixElements", "handle", $hMatrix, "float", 1.0, "float", 0.0, "float", 0.0, "float", 1.0, "float", 0.0, "float", 0.0) DllCall($__g_hGDIPDll, "int", "GdipSetWorldTransform", "handle", $hCanvas, "handle", $hMatrix) _GDIPlus_GraphicsDrawStringEx($hCanvas, "FPS: " & $iShowFPS, $hFont_FPS, $tLayout_FPS, $hFormat_FPS, $hBrush_FPS) ;draw background message text _WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hDC_backbuffer, 0, 0, $SRCCOPY) ;blit drawn bitmap to GUI $iFPS += 1 If $bExit Then ExitLoop Until False ;Not Sleep(10) AdlibUnRegister("CalcFPS") ;release resources _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_ImageDispose($hImage_Ball) _GDIPlus_BrushDispose($hTexture_Ball) _GDIPlus_FontDispose($hFont_FPS) _GDIPlus_FontFamilyDispose($hFamily_FPS) _GDIPlus_StringFormatDispose($hFormat_FPS) _GDIPlus_BrushDispose($hBrush_Clr) _GDIPlus_BrushDispose($hBrush_FPS) _GDIPlus_GraphicsDispose($hCanvas) _WinAPI_SelectObject($hDC_backbuffer, $DC_obj) _WinAPI_DeleteDC($hDC_backbuffer) _WinAPI_DeleteObject($hHBitmap) _WinAPI_ReleaseDC($hGUI, $hDC) GUIDelete($hGUI) EndFunc ;==>GDIPlus_BallTest Func _Exit_About() $bExit = True EndFunc ;==>_Exit_About Func CalcFPS() ;display FPS $iShowFPS = $iFPS $iFPS = 0 EndFunc ;==>CalcFPS
Der Kern des Codes ist aus dem "Rotating Earth" Beispiel, irgendwann hier im Forum gepostet...
Hier der FB Code + Exe.
-
Vielen Dank AspirinJunkie
Das Ganze läuft in Autoit ziemlich langsam ab (liegt in der Natur von Autoit) und mir kommt es vor, dass die Projektion des Bildes auf die Kugel nicht richtig aussieht, aber ich ziehe mir mal deine Mathematik rein. Bin sehr eingerostet, was Vektoren angeht.
Ich habe den FB Code ein wenig frisiert und allen 15 Kugeln Texturen verpasst, die entsprechend dem Bewegungsvektor angezeigt werden, leider nicht physikalisch immer korrekt. Ich habe eukalyptus ' ASM Sinus / Cosinus verwendet, was zu einem echten Performance Boost gebracht hat. Der Flaschenhals waren Trigonometrie aufrufe in der MapImage2Sphere() Funktion.
OneDrive: https://1drv.ms/f/s!AiLeZOpaFqSayCvkcMeBwRcp9ySN?e=qYN7qU (Simple 2D Ball Collision - Billiard Opening2.bas / .exe + die Bitmap Dateien 1-15).
Schade, dass du dich nicht mit FB anfreunden wirst / kannst / willst! Irgendwie gefällt mir die Sprache besser als Autoit.
-
Wenn es um die Windows API geht, kannst du bei MS die Informationen finden: https://learn.microsoft.com/en-us/windows/…parametersinfow
Dort ist im Prinzip alles dokumentiert und kann auch in Autoit angewendet werden. C Kenntnisse sind von Vorteil.
Einfach mit dem Thema beschäftigen und man bekommt langsam ein Gefühl dafür.
-
Ich habe weitere Funktionen portiert (siehe Anhang).
Hier ein weiteres Beispiel.
AutoIt
Alles anzeigen;Coded by UEZ build 2024-03-29 beta #AutoIt3Wrapper_UseX64=y #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPIGdi.au3> #include "Cairo.au3" AutoItSetOption('MustDeclareVars', 1) Global Const $fPi = ACos(-1), $fRad = $fPi / 180, $fDeg = 180 / $fPi, $f2PI = $fPi * 2 Global Const $iW = 960, $iH = 540, $sTitle = "Cairo Test (" & (@AutoItX64 ? "64" : "32") & " Bit) / FPS: " Global $hGUI, $iFPS = 0, $iShowFPS = 0, $bExit AutoItSetOption("GUIOnEventMode", 1) Cairo_Example() AutoItSetOption("GUIOnEventMode", 0) Func Cairo_Example() If Not Cairo_Init() Then ConsoleWrite(@error & @CRLF) Exit EndIf Local $iStride = Cairo_GetStride($iW) $hGUI = GUICreate($sTitle & "0", $iW, $iH) Local Const $hDC = _WinAPI_GetDC($hGUI) Local Const $hGfxDC = _WinAPI_CreateCompatibleDC($hDC) Local $tBIV5HDR = DllStructCreate($tagBITMAPV5HEADER) DllStructSetData($tBIV5HDR, 'bV5Size', DllStructGetSize($tBIV5HDR)) DllStructSetData($tBIV5HDR, 'bV5Width', $iW) DllStructSetData($tBIV5HDR, 'bV5Height', -$iH) DllStructSetData($tBIV5HDR, 'bV5Planes', 1) DllStructSetData($tBIV5HDR, 'bV5BitCount', 32) DllStructSetData($tBIV5HDR, 'biCompression', $BI_RGB) Local $pBits Local $hBitmapGDI = _WinAPI_CreateDIBSection($hGfxDC, $tBIV5HDR, $DIB_RGB_COLORS, $pBits) Local Const $hObjOld = _WinAPI_SelectObject($hGfxDC, $hBitmapGDI) GUISetState(@SW_SHOW, $hGUI) $bExit = False GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") AdlibRegister("CalcFPS", 1000) Local $pSurface = Cairo_Image_CreateForData($pBits, $iW, $iH, $iStride) Local $pContext = Cairo_Context_Create($pSurface) Local $tMatrix = DllStructCreate($tagCairo_matrix) $tMatrix.x0 = $iW / 2 $tMatrix.y0 = $iH / 2 Local $t, $tt = 1 / 15, $b, $i, $q, $t1 Do For $i = 50 To 1 Step -1 $q = $i / 3 $b = Sin($i / 9 - $t) $t1 = $q * Sin($b) $tMatrix.xx = $q * Cos($b) $tMatrix.yx = $t1 $tMatrix.xy = -$t1 $tMatrix.yy = $tMatrix.xx Cairo_Context_Transform($pContext, $tMatrix) Cairo_SetColor($pContext, 1 - 1 / ($i / 4)) Cairo_FillRectangle($pContext, -48, -48, 96, 96) Cairo_Context_ResetIdentity($pContext) Next _WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hGfxDC, 0, 0, $SRCCOPY) $t += $tt $iFPS += 1 If $bExit Then ExitLoop Until Not Sleep(10) Cairo_Context_Destroy($pContext) Cairo_Surface_Destroy($pSurface) _WinAPI_SelectObject($hGfxDC, $hObjOld) _WinAPI_ReleaseDC($hGUI, $hDC) _WinAPI_DeleteDC($hGfxDC) _WinAPI_DeleteObject($hBitmapGDI) GUIDelete($hGUI) Cairo_Close() EndFunc Func _Exit() $bExit = True EndFunc ;==>_Exit_About Func CalcFPS() ;display FPS $iShowFPS = $iFPS $iFPS = 0 WinSetTitle($hGUI, "", $sTitle & $iShowFPS) EndFunc ;==>CalcFPS
Ich habe massiv die UDF geändert, d.h. die UDF im 1. Post wird nicht funktionieren und die UDF im Anhang unten kann noch viele Copy/Paste oder andere Fehler beinhalten! Die DLL kann im 1. Post heruntergeladen werden.
Habt ihr Lust Beispiele zu erstellen? Dann bitte hier Posten.
Etliche Funktionen sind noch nicht portiert, aber ich arbeite daran...
Happy Ostern!
-
Mit 89 ist man eben etwas langsamer.
Echt jetzt?
-
Danke Velted fürs Nachforschen und das Erstellen des Beispiels . Die ursprünglichen zwei DLLs funktionieren, und machen keine Probleme. Das Problem war anscheinend mein Code.
Nachschlag für UEZ
CodeDllCall($g_hCairoDLL, "none:cdecl", "cairo_move_to", "ptr", $pSurface, "double", $x, "double", $y) DllCall($g_hCairoDLL, "none:cdecl", "cairo_line_to", "ptr", $pSurface, "double", $iW, "double", $iH) DllCall($g_hCairoDLL, "none:cdecl", "cairo_stroke", "ptr", $pContext)
Das kann nicht funktionieren, weil Du versuchst, auf $pSurface zu zeichnen.
Ich Idiot und ich suche mir einen Wolf, warum das nicht funzt.
Hier der Code, welches auch bei mir funzt:
C
Alles anzeigen#AutoIt3Wrapper_UseX64=n #include <Array.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPIGdi.au3> #include "Cairo.au3" AutoItSetOption('MustDeclareVars', 1) Global Const $fPi = ACos(-1), $fRad = $fPi / 180, $fDeg = 180 / $fPi, $f2PI = $fPi * 2 Global Const $iW = 600, $iH = 400, $sTitle = "Cairo Test / FPS: " Global $hGUI, $iFPS = 0, $iShowFPS = 0, $bExit AutoItSetOption("GUIOnEventMode", 1) Cairo_Test() AutoItSetOption("GUIOnEventMode", 0) Func Cairo_Test() Cairo_Init() Local $iStride = Cairo_GetStride($iW) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iStride = ' & $iStride & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $hGUI = GUICreate($sTitle & "0", $iW, $iH) Local Const $hDC = _WinAPI_GetDC($hGUI) Local Const $hGfxDC = _WinAPI_CreateCompatibleDC($hDC) Local $tBIV5HDR = DllStructCreate($tagBITMAPV5HEADER) DllStructSetData($tBIV5HDR, 'bV5Size', DllStructGetSize($tBIV5HDR)) DllStructSetData($tBIV5HDR, 'bV5Width', $iW) DllStructSetData($tBIV5HDR, 'bV5Height', -$iH) DllStructSetData($tBIV5HDR, 'bV5Planes', 1) DllStructSetData($tBIV5HDR, 'bV5BitCount', 32) DllStructSetData($tBIV5HDR, 'biCompression', $BI_RGB) DllStructSetData($tBIV5HDR, 'bV5RedMask', 0x00FF0000) DllStructSetData($tBIV5HDR, 'bV5GreenMask', 0x0000FF00) DllStructSetData($tBIV5HDR, 'bV5BlueMask', 0x000000FF) DllStructSetData($tBIV5HDR, 'bV5AlphaMask', 0xFF000000) Local $pBits Local $hBitmapGDI = _WinAPI_CreateDIBSection($hGfxDC, $tBIV5HDR, $DIB_RGB_COLORS, $pBits) Local Const $hObjOld = _WinAPI_SelectObject($hGfxDC, $hBitmapGDI) GUISetState(@SW_SHOW, $hGUI) $bExit = False GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") AdlibRegister("CalcFPS", 1000) Local $pSurface $pSurface = DllCall($g_hCairoDLL, "ptr:cdecl", "cairo_image_surface_create_for_data", "ptr", $pBits, "long", $CAIRO_FORMAT_ARGB32, "long", $iW, "long", $iH, "long", $iStride)[0] Local $pContext = Cairo_CreateContext($pSurface) Local $t, $tt = 1 / 60, $x, $y, $c, $w = $iW / 2, $h = $iH / 2 Local $tPAINTSTRUCT Do _WinAPI_BeginPaint($hGUI, $tPAINTSTRUCT) $c = 0.5 + 0.5 * Sin($t) $x = Int($iW / 4 + Sin($t) * 20) $y = Int($iH / 4 + Cos($t) * 20) Cairo_ClearContext($pContext, $c, $c, $c) Cairo_SetColor($pContext, 1, 1, 0, 1) DllCall($g_hCairoDLL, "none:cdecl", "cairo_arc", "ptr", $pContext, "double", ($iW / 2), "double", ($iH / 2), "double", 70, "double", 0, "double", 2 * $fPi) DllCall($g_hCairoDLL, "none:cdecl", "cairo_fill", "ptr", $pContext) Cairo_SetColor($pContext, 0, 0, 0.5 + 0.5 * Cos($t)) Cairo_SetLineWidth($pContext, 20) Cairo_DrawRectangle($pContext, $x, $y, $w, $h) Cairo_SetColor($pContext, 1, 0, 0, 1) DllCall($g_hCairoDLL, "none:cdecl", "cairo_set_line_width", "ptr", $pContext, "double", 20) DllCall($g_hCairoDLL, "none:cdecl", "cairo_move_to", "ptr", $pContext, "double", $iw / 2, "double", $iH / 2) DllCall($g_hCairoDLL, "none:cdecl", "cairo_line_to", "ptr", $pContext, "double", $x, "double", $y) DllCall($g_hCairoDLL, "none:cdecl", "cairo_stroke", "ptr", $pContext) _WinAPI_EndPaint($hGUI, $tPAINTSTRUCT) $t += $tt _WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hGfxDC, 0, 0, $SRCCOPY) $iFPS += 1 If $bExit Then ExitLoop Until Not Sleep(10) Cairo_DestroyContext($pContext) Cairo_DestroySurface($pSurface) _WinAPI_SelectObject($hGfxDC, $hObjOld) _WinAPI_ReleaseDC($hGUI, $hDC) _WinAPI_DeleteDC($hGfxDC) _WinAPI_DeleteObject($hBitmapGDI) GUIDelete($hGUI) Cairo_Close() EndFunc Func _Exit() $bExit = True EndFunc ;==>_Exit_About Func CalcFPS() ;display FPS $iShowFPS = $iFPS $iFPS = 0 WinSetTitle($hGUI, "", $sTitle & $iShowFPS) EndFunc ;==>CalcFPS
Ich werde weitere Möglichkeiten checken, wie man Cairo unter Windows noch initiieren kann.
-
Liegt an den DLLs!
Mit denen funzt's für x86. Ich habe noch keine DLLs für x64 gefunden...
Edit: für den Kreis funzt's, aber keine Linien möglich - Absturz.
-
Irgendwie schaffe ich es nicht eine Linie zu ziehen oder einen Kreis zu zeichnen, das angezeigt wird.
Hat jemand eine Idee, woran das liegen könnte?
Kreis:
CodeDllCall($g_hCairoDLL, "none:cdecl", "cairo_arc", "ptr", $pContext, "double", ($iW / 2), "double", ($iH / 2), "double", 100, "double", 0, "double", 2 * $fPi) DllCall($g_hCairoDLL, "none:cdecl", "cairo_fill", "ptr", $pContext)
Linie:
CodeDllCall($g_hCairoDLL, "none:cdecl", "cairo_move_to", "ptr", $pSurface, "double", $x, "double", $y) DllCall($g_hCairoDLL, "none:cdecl", "cairo_line_to", "ptr", $pSurface, "double", $iW, "double", $iH) DllCall($g_hCairoDLL, "none:cdecl", "cairo_stroke", "ptr", $pContext)
Danke.
-
Was für ein Unsinn.
Und DllCall($g_hCairoDLL, "none:cdecl", "cairo_set_line_width", "ptr", $pContext, "double", $iH / 10) scheint nur mit ganzen geraden Zahlen zu funktionieren...
Wie auch immer, danke für euer Feedback. Gehe jetzt aber mal in die Mucki Bude mich abreagieren...
-
-
Velted Moin.
Genau, das meine ich, aber warum funktioniert nicht das, wenn ich dies im DllCall eintrage.
Hmmm...
-
Hallo AspirinJunkie,
danke für dein Feedback.
Wenn du einfach die Zeile durch diese ersetzt,
CodeDllCall($g_hCairoDLL, "none:cdecl", "cairo_rectangle", "ptr", $pContext, "double", $t + $iW / 4, "double", $iH / 4, "double", $iW / 2, "double", $iH / 2)
dann sollte die Grafik gelöscht werden und weiter passiert nichts. Eigentlich sollte das Viereck nach rechts wandern.
-
Cairo scheint eine schicke 2D Grafikbibliothek zu sein, die auch auf anderen Plattformen wie Linux läuft. Ich habe einige Beispiele in Freebasic gesehen und dachte mir, warum auch nicht in Autoit.
Ein Manual gibt es hier: https://www.cairographics.org/manual/
Die Cairo UDF: Cairo.au3
AutoIt: Cairo.au3
Alles anzeigen;Ported to Autoit by UEZ build 2024-03-24 #include-once #Region enums and constants ;cairo_status as long Global Enum $CAIRO_STATUS_SUCCESS = 0, $CAIRO_STATUS_NO_MEMORY, $CAIRO_STATUS_INVALID_RESTORE, $CAIRO_STATUS_INVALID_POP_GROUP, $CAIRO_STATUS_NO_CURRENT_POINT, $CAIRO_STATUS_INVALID_MATRIX, _ $CAIRO_STATUS_INVALID_STATUS, $CAIRO_STATUS_NULL_POINTER, $CAIRO_STATUS_INVALID_STRING, $CAIRO_STATUS_INVALID_PATH_DATA, $CAIRO_STATUS_READ_ERROR, $CAIRO_STATUS_WRITE_ERROR, _ $CAIRO_STATUS_SURFACE_FINISHED, $CAIRO_STATUS_SURFACE_TYPE_MISMATCH, $CAIRO_STATUS_PATTERN_TYPE_MISMATCH, $CAIRO_STATUS_INVALID_CONTENT, $CAIRO_STATUS_INVALID_FORMAT, $CAIRO_STATUS_INVALID_VISUAL, _ $CAIRO_STATUS_FILE_NOT_FOUND, $CAIRO_STATUS_INVALID_DASH, $CAIRO_STATUS_INVALID_DSC_COMMENT, $CAIRO_STATUS_INVALID_INDEX, $CAIRO_STATUS_CLIP_NOT_REPRESENTABLE, $CAIRO_STATUS_TEMP_FILE_ERROR, _ $CAIRO_STATUS_INVALID_STRIDE, $CAIRO_STATUS_FONT_TYPE_MISMATCH, $CAIRO_STATUS_USER_FONT_IMMUTABLE, $CAIRO_STATUS_USER_FONT_ERROR, $CAIRO_STATUS_NEGATIVE_COUNT, $CAIRO_STATUS_INVALID_CLUSTERS, _ $CAIRO_STATUS_INVALID_SLANT, $CAIRO_STATUS_INVALID_WEIGHT, $CAIRO_STATUS_INVALID_SIZE, $CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED, $CAIRO_STATUS_DEVICE_TYPE_MISMATCH, $CAIRO_STATUS_DEVICE_ERROR, _ $CAIRO_STATUS_INVALID_MESH_CONSTRUCTION, $CAIRO_STATUS_DEVICE_FINISHED, $CAIRO_STATUS_JBIG2_GLOBAL_MISSING, $CAIRO_STATUS_LAST_STATUS Global Const $g_aCairoStatus[] = ["CAIRO_STATUS_SUCCESS", "CAIRO_STATUS_NO_MEMORY", "CAIRO_STATUS_INVALID_RESTORE", "CAIRO_STATUS_INVALID_POP_GROUP", "CAIRO_STATUS_NO_CURRENT_POINT", "CAIRO_STATUS_INVALID_MATRIX", _ "CAIRO_STATUS_INVALID_STATUS", "CAIRO_STATUS_NULL_POINTER", "CAIRO_STATUS_INVALID_STRING", "CAIRO_STATUS_INVALID_PATH_DATA", "CAIRO_STATUS_READ_ERROR", "CAIRO_STATUS_WRITE_ERROR", _ "CAIRO_STATUS_SURFACE_FINISHED", "CAIRO_STATUS_SURFACE_TYPE_MISMATCH", "CAIRO_STATUS_PATTERN_TYPE_MISMATCH", "CAIRO_STATUS_INVALID_CONTENT", "CAIRO_STATUS_INVALID_FORMAT", "CAIRO_STATUS_INVALID_VISUAL", _ "CAIRO_STATUS_FILE_NOT_FOUND", "CAIRO_STATUS_INVALID_DASH", "CAIRO_STATUS_INVALID_DSC_COMMENT", "CAIRO_STATUS_INVALID_INDEX", "CAIRO_STATUS_CLIP_NOT_REPRESENTABLE", "CAIRO_STATUS_TEMP_FILE_ERROR", _ "CAIRO_STATUS_INVALID_STRIDE", "CAIRO_STATUS_FONT_TYPE_MISMATCH", "CAIRO_STATUS_USER_FONT_IMMUTABLE", "CAIRO_STATUS_USER_FONT_ERROR", "CAIRO_STATUS_NEGATIVE_COUNT", "CAIRO_STATUS_INVALID_CLUSTERS", _ "CAIRO_STATUS_INVALID_SLANT", "CAIRO_STATUS_INVALID_WEIGHT", "CAIRO_STATUS_INVALID_SIZE", "CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED", "CAIRO_STATUS_DEVICE_TYPE_MISMATCH", "CAIRO_STATUS_DEVICE_ERROR", _ "CAIRO_STATUS_INVALID_MESH_CONSTRUCTION", "CAIRO_STATUS_DEVICE_FINISHED", "CAIRO_STATUS_JBIG2_GLOBAL_MISSING", "CAIRO_STATUS_LAST_STATUS"] ;cairo_format as long Global Enum $CAIRO_FORMAT_INVALID = -1, $CAIRO_FORMAT_ARGB32, $CAIRO_FORMAT_RGB24, $CAIRO_FORMAT_A8, $CAIRO_FORMAT_A1, $CAIRO_FORMAT_RGB16_565, $CAIRO_FORMAT_RGB30 ;cairo_operator as long Global Enum $CAIRO_OPERATOR_CLEAR, $CAIRO_OPERATOR_SOURCE, $CAIRO_OPERATOR_OVER, $CAIRO_OPERATOR_IN, $CAIRO_OPERATOR_OUT, $CAIRO_OPERATOR_ATOP, $CAIRO_OPERATOR_DEST, $CAIRO_OPERATOR_DEST_OVER, $CAIRO_OPERATOR_DEST_IN, _ $CAIRO_OPERATOR_DEST_OUT, $CAIRO_OPERATOR_DEST_ATOP, $CAIRO_OPERATOR_XOR, $CAIRO_OPERATOR_ADD, $CAIRO_OPERATOR_SATURATE, $CAIRO_OPERATOR_MULTIPLY, $CAIRO_OPERATOR_SCREEN, $CAIRO_OPERATOR_OVERLAY, _ $CAIRO_OPERATOR_DARKEN, $CAIRO_OPERATOR_LIGHTEN, $CAIRO_OPERATOR_COLOR_DODGE, $CAIRO_OPERATOR_COLOR_BURN, $CAIRO_OPERATOR_HARD_LIGHT, $CAIRO_OPERATOR_SOFT_LIGHT, $CAIRO_OPERATOR_DIFFERENCE, _ $CAIRO_OPERATOR_EXCLUSION, $CAIRO_OPERATOR_HSL_HUE, $CAIRO_OPERATOR_HSL_SATURATION, $CAIRO_OPERATOR_HSL_COLOR, $CAIRO_OPERATOR_HSL_LUMINOSITY ;cairo_antialias as long Global Enum $CAIRO_ANTIALIAS_DEFAULT, $CAIRO_ANTIALIAS_NONE, $CAIRO_ANTIALIAS_GRAY, $CAIRO_ANTIALIAS_SUBPIXEL, $CAIRO_ANTIALIAS_FAST, $CAIRO_ANTIALIAS_GOOD, $CAIRO_ANTIALIAS_BEST ;cairo_fill_rule as long Global Enum $CAIRO_FILL_RULE_WINDING, $CAIRO_FILL_RULE_EVEN_ODD ;cairo_line_join as long Global Enum $CAIRO_LINE_JOIN_MITER, $CAIRO_LINE_JOIN_ROUND, $CAIRO_LINE_JOIN_BEVEL ;cairo_line_cap as long Global Enum $CAIRO_LINE_CAP_BUTT, $CAIRO_LINE_CAP_ROUND, $CAIRO_LINE_CAP_SQUARE ;cairo_text_cluster_flags as long Global Const $CAIRO_TEXT_CLUSTER_FLAG_BACKWARD = 0x00000001 ;cairo_font_slant as long Global Enum $CAIRO_FONT_SLANT_NORMAL, $CAIRO_FONT_SLANT_ITALIC, $CAIRO_FONT_SLANT_OBLIQUE ;cairo_font_weight as long Global Enum $CAIRO_FONT_WEIGHT_NORMAL, $CAIRO_FONT_WEIGHT_BOLD ;cairo_subpixel_order as long Global Enum $CAIRO_SUBPIXEL_ORDER_DEFAULT, $CAIRO_SUBPIXEL_ORDER_RGB, $CAIRO_SUBPIXEL_ORDER_BGR, $CAIRO_SUBPIXEL_ORDER_VRGB, $CAIRO_SUBPIXEL_ORDER_VBGR ;cairo_hint_style as long Global Enum $CAIRO_HINT_STYLE_DEFAULT, $CAIRO_HINT_STYLE_NONE, $CAIRO_HINT_STYLE_SLIGHT, $CAIRO_HINT_STYLE_MEDIUM, $CAIRO_HINT_STYLE_FULL ;cairo_hint_metrics as long Global Enum $CAIRO_HINT_METRICS_DEFAULT, $CAIRO_HINT_METRICS_OFF, $CAIRO_HINT_METRICS_ON ;cairo_font_type as long Global Enum $CAIRO_FONT_TYPE_TOY, $CAIRO_FONT_TYPE_FT, $CAIRO_FONT_TYPE_WIN32, $CAIRO_FONT_TYPE_QUARTZ, $CAIRO_FONT_TYPE_USER ;cairo_path_data_type as long Global Enum $CAIRO_PATH_MOVE_TO, $CAIRO_PATH_LINE_TO, $CAIRO_PATH_CURVE_TO, $CAIRO_PATH_CLOSE_PATH ;cairo_device_type as long Global Enum $CAIRO_DEVICE_TYPE_DRM, $CAIRO_DEVICE_TYPE_GL, $CAIRO_DEVICE_TYPE_SCRIPT, $CAIRO_DEVICE_TYPE_XCB, $CAIRO_DEVICE_TYPE_XLIB, $CAIRO_DEVICE_TYPE_XML, $CAIRO_DEVICE_TYPE_COGL, _ $CAIRO_DEVICE_TYPE_WIN32, $CAIRO_DEVICE_TYPE_INVALID = -1 ;cairo_surface_observer_mode_t as long Global Enum $CAIRO_SURFACE_OBSERVER_NORMAL, $CAIRO_SURFACE_OBSERVER_RECORD_OPERATIONS ;cairo_surface_type as long Global Enum $CAIRO_SURFACE_TYPE_IMAGE, $CAIRO_SURFACE_TYPE_PDF, $CAIRO_SURFACE_TYPE_PS, $CAIRO_SURFACE_TYPE_XLIB, $CAIRO_SURFACE_TYPE_XCB, $CAIRO_SURFACE_TYPE_GLITZ, $CAIRO_SURFACE_TYPE_QUARTZ,$CAIRO_SURFACE_TYPE_WIN32, _ $CAIRO_SURFACE_TYPE_BEOS, $CAIRO_SURFACE_TYPE_DIRECTFB, $CAIRO_SURFACE_TYPE_SVG, $CAIRO_SURFACE_TYPE_OS2, $CAIRO_SURFACE_TYPE_WIN32_PRINTING, $CAIRO_SURFACE_TYPE_QUARTZ_IMAGE, $CAIRO_SURFACE_TYPE_SCRIPT, _ $CAIRO_SURFACE_TYPE_QT, $CAIRO_SURFACE_TYPE_RECORDING, $CAIRO_SURFACE_TYPE_VG, $CAIRO_SURFACE_TYPE_GL, $CAIRO_SURFACE_TYPE_DRM, $CAIRO_SURFACE_TYPE_TEE, $CAIRO_SURFACE_TYPE_XML, $CAIRO_SURFACE_TYPE_SKIA, _ $CAIRO_SURFACE_TYPE_SUBSURFACE, $CAIRO_SURFACE_TYPE_COGL ;cairo_pattern_type as long Global Enum $CAIRO_PATTERN_TYPE_SOLID, $CAIRO_PATTERN_TYPE_SURFACE, $CAIRO_PATTERN_TYPE_LINEAR, $CAIRO_PATTERN_TYPE_RADIAL, $CAIRO_PATTERN_TYPE_MESH, $CAIRO_PATTERN_TYPE_RASTER_SOURCE ;cairo_extend as long Global Enum $CAIRO_EXTEND_NONE, $CAIRO_EXTEND_REPEAT, $CAIRO_EXTEND_REFLECT, $CAIRO_EXTEND_PAD ;cairo_filter as long Global Enum $CAIRO_FILTER_FAST, $CAIRO_FILTER_GOOD, $CAIRO_FILTER_BEST, $CAIRO_FILTER_NEAREST, $CAIRO_FILTER_BILINEAR, $CAIRO_FILTER_GAUSSIAN ;cairo_region_overlap as long Global Enum $CAIRO_REGION_OVERLAP_IN, $CAIRO_REGION_OVERLAP_OUT, $CAIRO_REGION_OVERLAP_PART #EndRegion #Region tag structs ;structs Global Const $tagCairo_rectangle_int = "long x;long y;long width;long height;" Global Const $tagCairo_rectangle_list = "long status;ptr rectangles;long num_rectangles;" Global Const $tagCairo_matrix = "double xx;double yx;double xy;double yy;double x0;double y0;" Global Const $tagCairo_glyph_t = (@AutoItX64 ? "uinteger" : "ulong") & " index;double x;double y;" Global Const $tagCairo_text_cluster_t = "long num_bytes;long num_glyphs;" Global Const $tagCairo_text_extents_t = "double x_bearing;double y_bearing;double width;double height;double x_advance;double y_advance;" Global Const $tagCairo_font_extents_t = "double ascent;double descent;double height;double max_x_advance;double max_y_advance;" Global Const $tagCairo_path_data_t_header = "long type;long length;" Global Const $tagCairo_path_data_t_point = "double x;double y;" Global Const $tagCairo_path_data_t = "ptr path;" Global Const $tagCairo_path = "long status;ptr data;long num_data;" #EndRegion Global $g_hCairoDLL = 0 Func Cairo_Init($sPath = Default) Local Const $sDLL = ($sPath = Default ? (@AutoItX64 ? (@ScriptDir & "\cairo64.dll") : (@ScriptDir & "\cairo.dll")) : $sPath) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) $g_hCairoDLL = DllOpen($sDLL) If $g_hCairoDLL = -1 Or @error Then Return SetError(2, 0, 0) Return 1 EndFunc Func Cairo_Close() If $g_hCairoDLL Then Return DllClose($g_hCairoDLL) Return 0 EndFunc Func Cairo_GetStride($iW, $iFormat = $CAIRO_FORMAT_ARGB32) Local Const $aStride = DllCall($g_hCairoDLL, "long:cdecl", "cairo_format_stride_for_width", "long", $iFormat, "long", $iW) ;BitShift($iW * 32 + 15, 4) * 2 * $iH If @error Or Not IsArray($aStride) Then Return SetError(1, 0, 0) If Not $aStride[0] Then Return SetError(2, 0, 0) Return $aStride[0] EndFunc Func Cairo_CreateWin32Surface($hDC) Local Const $aSurface = DllCall($g_hCairoDLL, "ptr:cdecl", "cairo_win32_surface_create", "ptr", $hDC) If @error Or Not IsArray($aSurface) Then Return SetError(1, 0, 0) If Not $aSurface[0] Then Return SetError(2, 0, 0) Return $aSurface[0] EndFunc Func Cairo_CreateWin32SurfacePrinting($hDC) Local Const $aSurface = DllCall($g_hCairoDLL, "ptr:cdecl", "cairo_win32_printing_surface_create", "ptr", $hDC) If @error Or Not IsArray($aSurface) Then Return SetError(1, 0, 0) If Not $aSurface[0] Then Return SetError(2, 0, 0) Return $aSurface[0] EndFunc Func Cairo_CreateWin32SurfaceWithFormat($hDC, $iFormat = $CAIRO_FORMAT_ARGB32) Local Const $aSurface = DllCall($g_hCairoDLL, "ptr:cdecl", "cairo_win32_surface_create_with_format", "ptr", $hDC, "long", $iFormat) If @error Or Not IsArray($aSurface) Then Return SetError(1, 0, 0) If Not $aSurface[0] Then Return SetError(2, 0, 0) Return $aSurface[0] EndFunc Func Cairo_CreateWin32SurfaceWithDDB($hDC, $iW, $iH, $iFormat = $CAIRO_FORMAT_ARGB32) Local Const $aSurface = DllCall($g_hCairoDLL, "ptr:cdecl", "cairo_win32_surface_create_with_ddb", "ptr", $hDC, "long", $iFormat, "long", $iw, "long", $ih) If @error Or Not IsArray($aSurface) Then Return SetError(1, 0, 0) If Not $aSurface[0] Then Return SetError(2, 0, 0) Return $aSurface[0] EndFunc Func Cairo_CreateSurfaceImageData($pImageData, $iW, $iH, $iStride, $iFormat = $CAIRO_FORMAT_ARGB32) Local Const $aSurface = DllCall($g_hCairoDLL, "ptr:cdecl", "cairo_image_surface_create_for_data", "ptr", $pImageData, "long", $iFormat, "long", $iW, "long", $iH, "long", $iStride) If @error Or Not IsArray($aSurface) Then Return SetError(1, 0, 0) If Not $aSurface[0] Then Return SetError(2, 0, 0) Return $aSurface[0] EndFunc Func Cairo_CreateContext($pSurface) Local Const $aContext = DllCall($g_hCairoDLL, "ptr:cdecl", "cairo_create", "ptr", $pSurface) If @error Or Not IsArray($aContext) Then Return SetError(1, 0, 0) If Not $aContext[0] Then Return SetError(2, 0, 0) Return $aContext[0] EndFunc Func Cairo_DestroyContext($pContext) If Not $pContext Then Return SetError(1, 0, 0) DllCall($g_hCairoDLL, "none:cdecl", "cairo_destroy", "ptr", $pContext) Return 1 EndFunc Func Cairo_DestroySurface($pSurface) If Not $pSurface Then Return SetError(1, 0, 0) DllCall($g_hCairoDLL, "none:cdecl", "cairo_surface_destroy", "ptr", $pSurface) Return 1 EndFunc Func Cairo_ClearContext($pContext, $r = 0, $g = 0, $b = 0, $a = 1) If Not $pContext Then Return SetError(1, 0, 0) DllCall($g_hCairoDLL, "none:cdecl", "cairo_set_source_rgb", "ptr", $pContext, "double", $r, "double", $g, "double", $b, "double", $a) DllCall($g_hCairoDLL, "none:cdecl", "cairo_paint", "ptr", $pContext) EndFunc
Beispiel:
C
Alles anzeigen#AutoIt3Wrapper_UseX64=n #include <Array.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPIGdi.au3> #include "Cairo.au3" AutoItSetOption('MustDeclareVars', 1) Global Const $fPi = ACos(-1), $fRad = $fPi / 180, $fDeg = 180 / $fPi, $f2PI = $fPi * 2 Global Const $iW = 600, $iH = 400, $sTitle = "Cairo Test / FPS: " Global $hGUI, $iFPS = 0, $iShowFPS = 0, $bExit AutoItSetOption("GUIOnEventMode", 1) Cairo_Test() AutoItSetOption("GUIOnEventMode", 0) Func Cairo_Test() Cairo_Init() Local $iStride = Cairo_GetStride($iW) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iStride = ' & $iStride & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $hGUI = GUICreate($sTitle & "0", $iW, $iH) Local Const $hDC = _WinAPI_GetDC($hGUI) ;~ Local $tBits = DllStructCreate("long[" & $iStride * $iH & "]") ;~ Local Const $hBitmapGDI = _WinAPI_CreateBitmap($iW, $iH, 1, 32, $tBits) Local Const $hBitmapGDI = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) Local Const $hGfxDC = _WinAPI_CreateCompatibleDC($hDC) Local Const $hObjOld = _WinAPI_SelectObject($hGfxDC, $hBitmapGDI) GUISetState(@SW_SHOW, $hGUI) $bExit = False GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") AdlibRegister("CalcFPS", 1000) Local $pSurface = Cairo_CreateWin32Surface($hGfxDC) ConsoleWrite("Surface status: " & DllCall($g_hCairoDLL, "long:cdecl", "cairo_surface_status", "ptr", $pSurface)[0] & @CRLF) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $pSurface = ' & $pSurface & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console Local $pContext = Cairo_CreateContext($pSurface) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $pContext = ' & $pContext & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ConsoleWrite(DllCall($g_hCairoDLL, "str:cdecl", "cairo_status_to_string")[0] & @CRLF) Local $t, $tt = 1 / 60, $x, $y, $c Local $tPAINTSTRUCT Do _WinAPI_BeginPaint($hGUI, $tPAINTSTRUCT) $c = 0.5 + 0.5 * Sin($t) Cairo_ClearContext($pContext, $c, $c, $c) DllCall($g_hCairoDLL, "none:cdecl", "cairo_set_source_rgba", "ptr", $pContext, "double", 0, "double", 0, "double", 0.5 + 0.5 * Cos($t), "double", 1.0) DllCall($g_hCairoDLL, "none:cdecl", "cairo_set_line_width", "ptr", $pContext, "double", $iH / 10) DllCall($g_hCairoDLL, "none:cdecl", "cairo_rectangle", "ptr", $pContext, "double", $iW / 4, "double", $iH / 4, "double", $iW / 2, "double", $iH / 2) DllCall($g_hCairoDLL, "none:cdecl", "cairo_stroke", "ptr", $pContext) _WinAPI_EndPaint($hGUI, $tPAINTSTRUCT) $t += $tt _WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hGfxDC, 0, 0, $SRCCOPY) $iFPS += 1 If $bExit Then ExitLoop Until Not Sleep(10) Cairo_DestroyContext($pContext) Cairo_DestroySurface($pSurface) _WinAPI_SelectObject($hGfxDC, $hObjOld) _WinAPI_ReleaseDC($hGUI, $hDC) _WinAPI_DeleteDC($hGfxDC) _WinAPI_DeleteObject($hBitmapGDI) GUIDelete($hGUI) Cairo_Close() EndFunc Func _Exit() $bExit = True EndFunc ;==>_Exit_About Func CalcFPS() ;display FPS $iShowFPS = $iFPS $iFPS = 0 WinSetTitle($hGUI, "", $sTitle & $iShowFPS) EndFunc ;==>CalcFPS
Soweit funktioniert das Beispiel, nur wenn ich die Position über eine Variable in der cairo_rectangle Funktion hinzufüge, dann passiert nichts mehr.
Ich habe nicht herausgefunden, was man tun muss, damit auch Animationen möglich sind. Somit könnte man Cairo mit GDI / GDI+ vergleichen.
Die benötigten DLLs sind im Anhang zu finden.
Hat jemand eine Idee?
-
Vielleicht hilft dir das hier ein wenig weiter:
AutoIt: MsgBox Hook with counter v2.au3
Alles anzeigen;Coded by UEZ build 2023-04-29 beta #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so #Au3Stripper_Ignore_Funcs=_TimerProc #include <Timers.au3> #include <WinAPIConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIProc.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> Const $HCBT_CREATEWND = 3, $HCBT_DESTROYWND = 4, $HCBT_ACTIVATE = 5, $g_iFlagDefault = BitOR($MB_TOPMOST, $MB_ICONINFORMATION) Global $g_hMsgBoxHook, $g_hSubMsgBox, $g_idTImer, $g_sBtn1_Txt = "Close", $g_sBtn2_Txt, $g_sBtn3_Txt Global $g_Timeout = 0 Func _WinAPI_SetDlgItemText($hDlg, $nIDDlgItem, $lpString) ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setdlgitemtextw Local $aRet = DllCall("user32.dll", "int", "SetDlgItemText", "hwnd", $hDlg, "int", $nIDDlgItem, "str", $lpString) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc ;==>_WinAPI_SetDlgItemText Func _TimerProc($hwnd, $iMsg, $wParam, $lParam) If $g_Timeout <= 1 Then WinClose($hwnd) Else $g_Timeout -= 1 _WinAPI_SetDlgItemText($hWnd, $IDOK + 1, $g_sBtn1_Txt & " [" & $g_Timeout & "]") EndIf EndFunc ;==>_TimerProc Func _CBTHookProc($nCode, $wParam, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($g_hMsgBoxHook, $nCode, $wParam, $lParam) Local Const $hHWND = HWnd($wParam) Switch $nCode Case $HCBT_ACTIVATE If _WinAPI_GetClassName($hHWND) = "#32770" Then If $g_Timeout Then $g_idTImer = _Timer_SetTimer($hHWND, 1000, "_TimerProc") _WinAPI_SetDlgItemText($wParam, $IDOK, $g_Timeout ? $g_sBtn1_Txt & " [" & $g_Timeout & "]" : $g_sBtn1_Txt) EndIf Case $HCBT_DESTROYWND If _WinAPI_GetClassName($hHWND) = "#32770" Then _Timer_KillTimer($hHWND, $g_idTImer) EndSwitch Return _WinAPI_CallNextHookEx($g_hMsgBoxHook, $nCode, $wParam, $lParam) EndFunc ;==>_CBTHookProc Func MsgBoxEx($sText, $sTitle = Default, $iTimeout = 0, $iFlag = Default, $sBtn_Txt = Default, $hParentHWND = "") If $sBtn_Txt <> Default Then $g_sBtn1_Txt = $sBtn_Txt If $iFlag = Default Then $iFlag = $g_iFlagDefault $g_Timeout = $iTimeout $g_MsgProc = DllCallbackRegister("_CBTHookProc", "int", "uint;wparam;lparam") Local Const $hThreadID = _WinAPI_GetCurrentThreadId() $g_hMsgBoxHook = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($g_MsgProc), Null, $hThreadID) If $sTitle = Default Then $sTitle = "Information" Local Const $iReturn = MsgBox($iFlag, $sTitle, $sText, $iTimeout, $hParentHWND) _WinAPI_UnhookWindowsHookEx($g_hMsgBoxHook) DllCallbackFree($g_MsgProc) Return $iReturn EndFunc ;==>MsgBoxEx ConsoleWrite(MsgBoxEx("This is a test", "Information", 5) & @CRLF)
-
Ach, iwo, ich finde Alternativen immer sehr gut, das macht die Sache abwechslungsreicher, zumal du immer sehr guten und intelligenten Code postest. Also nichts peinliches, wenn man eine Alternative postest
Mag sein, dass mein Post oben "zu trocken" war, wollte mich einfach bedanken und zugleich sagen, dass es eine ähnliche Funktion bereits gibt. Bin eher der Purist, wenn's um Feedback geht (das Gegenteil von Andy )
Vergleichen mit der Built-in Funktion sind die Ergebnisse aber unterschiedlich in der Darstellung...
-
AspirinJunkie Danke für die Alternative zu der Built-in Funktion _WinAPI_DisplayStruct().
-
Als Start kannst du dies hier verwenden, um iCurrent darzustellen.
AutoIt
Alles anzeigen;coded by UEZ build 2023-20-11 #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global $hGUI, $iFPS = 0, $iShowFPS = 0, $bExit Global Const $iW = 600, $iH = 600, $iWh = $iW / 2, $iHh = $iH / 2, $sTitle = "GDI+ Test" Global Const $fPi = ACos(-1), $fRad = $fPi / 180, $fDeg = 180 / $fPi AutoItSetOption("GUIOnEventMode", 1) GDIPlus_Test() AutoItSetOption("GUIOnEventMode", 0) _GDIPlus_Shutdown() Func GDIPlus_Test() $bExit = False $hGUI = GUICreate($sTitle, $iW, $iH) ;, 0, 0, $WS_POPUP) GUISetState(@SW_SHOW, $hGUI) ;~ GUISetCursor(16, 1) ;create canvas elements Local Const $hDC = _WinAPI_GetDC($hGUI) Local Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) Local Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Local Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap) Local Const $hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) _GDIPlus_GraphicsSetSmoothingMode($hCanvas, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetPixelOffsetMode($hCanvas, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) Local Const $hBrush_Clr = _GDIPlus_BrushCreateSolid(0xFF000000), _ $hBrush_FPS = _GDIPlus_BrushCreateSolid(0xF0808080), _ $hFormat_FPS = _GDIPlus_StringFormatCreate(), _ $hFamily_FPS = _GDIPlus_FontFamilyCreate("Arial"), _ $hFont_FPS = _GDIPlus_FontCreate($hFamily_FPS, 8), _ $tLayout_FPS = _GDIPlus_RectFCreate(0, 0, 60, 16) Local $fDiameter = 600 Local Const $hBitmap_Clock = GenerateGauge($fDiameter) $iFPS = 0 GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit_About") AdlibRegister("CalcFPS", 1000) Do _GDIPlus_GraphicsDrawImageRect($hCanvas, $hBitmap_Clock, 0, 0, $fDiameter, $fDiameter) _GDIPlus_GraphicsDrawStringEx($hCanvas, "FPS: " & $iShowFPS, $hFont_FPS, $tLayout_FPS, $hFormat_FPS, $hBrush_FPS) ;draw background message text _WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hDC_backbuffer, 0, 0, $SRCCOPY) ;blit drawn bitmap to GUI $iFPS += 1 If $bExit Then ExitLoop Until Not Sleep(30) AdlibUnRegister("CalcFPS") ;release resources _GDIPlus_FontDispose($hFont_FPS) _GDIPlus_FontFamilyDispose($hFamily_FPS) _GDIPlus_StringFormatDispose($hFormat_FPS) _GDIPlus_BrushDispose($hBrush_Clr) _GDIPlus_BrushDispose($hBrush_FPS) _GDIPlus_GraphicsDispose($hCanvas) _WinAPI_SelectObject($hDC_backbuffer, $DC_obj) _WinAPI_DeleteDC($hDC_backbuffer) _WinAPI_DeleteObject($hHBitmap) _WinAPI_ReleaseDC($hGUI, $hDC) GUIDelete($hGUI) EndFunc ;==>GDIPlus_Test Func _Exit_About() $bExit = True EndFunc ;==>_Exit_About Func CalcFPS() ;display FPS $iShowFPS = $iFPS $iFPS = 0 EndFunc ;==>CalcFPS Func GenerateGauge($fDiameter) Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($fDiameter, $fDiameter), $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap), _ $hEffect = _GDIPlus_EffectCreateBlur(10.5, 0), $fBorderSize = $fDiameter * 0.03333 Local $hPen = _GDIPlus_PenCreate(0), $hMatrix, $hBrush = _GDIPlus_LineBrushCreate($fDiameter / 2, 0, $fDiameter / 2, $fDiameter, 0xF0F0F0F0, 0xF0303030, 3) _GDIPlus_GraphicsSetSmoothingMode($hGfx, 4) _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, 4) _GDIPlus_GraphicsClear($hGfx, 0xFFFFFFFF) _GDIPlus_PenSetColor($hPen, 0xA0000000) _GDIPlus_PenSetWidth($hPen, $fBorderSize) Local Const $fSize = $fDiameter * 0.95 - $fBorderSize / 2, $fRadius = $fDiameter / 2 _GDIPlus_LineBrushSetGammaCorrection($hBrush) _GDIPlus_GraphicsFillEllipse($hGfx, $fDiameter - $fDiameter * 0.94, $fDiameter - $fDiameter * 0.94, $fDiameter * 0.92, $fDiameter * 0.92, $hBrush) _GDIPlus_GraphicsDrawEllipse($hGfx, $fBorderSize + $fDiameter * 0.005, $fBorderSize + $fDiameter * 0.01, $fSize, $fSize, $hPen) _GDIPlus_BitmapApplyEffect($hBitmap, $hEffect) _GDIPlus_PenSetColor($hPen, 0xF0000000) _GDIPlus_GraphicsDrawEllipse($hGfx, $fBorderSize, $fBorderSize, $fSize, $fSize, $hPen) _GDIPlus_GraphicsTranslateTransform($hGfx, $fDiameter / 2, $fDiameter / 2) _GDIPlus_GraphicsRotateTransform($hGfx, -126) _GDIPlus_GraphicsTranslateTransform($hGfx, -$fDiameter / 2, -$fDiameter / 2) Local $iWidth1 = $fDiameter * 0.0125, $iHeight1 = $fDiameter / 15, $iWidth12 = $iWidth1 / 2, $fPosY = $fDiameter * 0.083333, _ $iWidth2 = $fDiameter * 0.013333, $iHeight2 = $fDiameter * 0.0416667, $iWidth22 = $iWidth2 / 2 _GDIPlus_BrushDispose($hBrush) $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000) For $i = 0 to 40 _GDIPlus_GraphicsTranslateTransform($hGfx, $fRadius, $fRadius) _GDIPlus_GraphicsRotateTransform($hGfx, 6) _GDIPlus_GraphicsTranslateTransform($hGfx, -$fRadius, -$fRadius) Switch Mod($i, 4) Case 0 _GDIPlus_GraphicsFillRect($hGfx, $fRadius - $iWidth12, $fPosY, $iWidth1, $iHeight1, $hBrush) Case Else ;~ _GDIPlus_GraphicsFillRect($hGfx, $fRadius - $iWidth22, $fPosY, $iWidth2, $iHeight2, $hBrush) EndSwitch Next _GDIPlus_GraphicsResetTransform($hGfx) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush) $hBrush = _GDIPlus_LineBrushCreate(0, 0, $fSize, $fSize, 0x8000FF00, 0xC8FF0000, 3) $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixRotate($hMatrix, -5) _GDIPlus_LineBrushSetTransform($hBrush, $hMatrix) $hPen = _GDIPlus_PenCreate2($hBrush, $fDiameter * 0.03) _GDIPlus_GraphicsDrawArc($hGfx, $fBorderSize + $fDiameter * 0.03333, $fBorderSize + $fDiameter * 0.03333, $fSize * 0.93, $fSize * 0.93, -211.5, 243.5, $hPen) _GDIPlus_BrushDispose($hBrush) _GDIPlus_PenDispose($hPen) $hBrush = _GDIPlus_BrushCreateSolid(0x80000000) $hPen = _GDIPlus_PenCreate(0x40000000, 2) _GDIPlus_GraphicsFillEllipse($hGfx, $fDiameter / 2 - $iWidth2, $fDiameter / 2 - $iWidth2, $iWidth2 * 2, $iWidth2 * 2, $hBrush) _GDIPlus_GraphicsDrawEllipse($hGfx, $fDiameter / 2 - $iWidth2, $fDiameter / 2 - $iWidth2, $iWidth2 * 2, $iWidth2 * 2, $hPen) _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_EffectDispose($hEffect) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGfx) Return $hBitmap EndFunc
Dies ist nur das Hintergrundbild, d.h. du müsstest noch einen drehenden Zeiger entsprechend dem $iCurrent Wert implementieren.