1. Dashboard
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forenregeln
  4. Forum
    1. Unerledigte Themen
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. AutoIt.de - Das deutschsprachige Forum.
  2. Mitglieder
  3. eukalyptus

Beiträge von eukalyptus

  • Midi Udf

    • eukalyptus
    • 30. April 2012 um 11:08

    Hier hab ich ein Midi-In-Beispiel:
    es werden 2 Buffer verwendet und die Daten via RegisterMsg empfangen (CALLBACK_WINDOW)

    So lassen sich AutoIt Scripte relativ einfach über einen MIDI-Controller steuern.

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WinAPI.au3>
    #include <MIDI.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("MustDeclareVars", 1)
    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hGui = GUICreate("Midi In Example", 1000, 420)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    Global $cCombo = GUICtrlCreateCombo("", 10, 10, 400, 20)
    Global $cButton_Start = GUICtrlCreateButton("Start", 420, 10, 80, 20)
    GUICtrlSetOnEvent(-1, "_Midi_Start")
    Global $cButton_Stop = GUICtrlCreateButton("Stop", 510, 10, 80, 20)
    GUICtrlSetOnEvent(-1, "_Midi_Stop")
    GUICtrlCreateLabel("MIM_DATA", 10, 40, 100, 20)
    Global $cEdit_Data = GUICtrlCreateEdit("", 10, 60, 485, 350)
    GUICtrlCreateLabel("MIM_LONGDATA", 505, 40, 100, 20)
    Global $cEdit_LongData = GUICtrlCreateEdit("", 505, 60, 485, 350)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    _Midi_Startup()
    Global $tBuffer1 = _CreateBuffer()
    Global $tBuffer2 = _CreateBuffer()
    _GetDevices()

    [/autoit] [autoit][/autoit] [autoit]

    Global $hMidi = 0
    Global $bRelease = False
    Global $iDeviceCurrent = -1

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($MM_MIM_CLOSE, "_MidiWinProc")
    GUIRegisterMsg($MM_MIM_DATA, "_MidiWinProc")
    GUIRegisterMsg($MM_MIM_ERROR, "_MidiWinProc")
    GUIRegisterMsg($MM_MIM_LONGDATA, "_MidiWinProc")
    GUIRegisterMsg($MM_MIM_LONGERROR, "_MidiWinProc")
    GUIRegisterMsg($MM_MIM_MOREDATA, "_MidiWinProc")
    GUIRegisterMsg($MM_MIM_OPEN, "_MidiWinProc")

    [/autoit] [autoit][/autoit] [autoit]

    While Sleep(100)
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _ProcessLongData($pData, $iBytes)
    Local $tGetData = DllStructCreate("byte[" & $iBytes & "];", $pData)
    GUICtrlSetData($cEdit_LongData, DllStructGetData($tGetData, 1) & @CRLF, 1)
    EndFunc ;==>_ProcessLongData

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _ProcessData($iMidiMessage)
    Local $iLoWord = _WinAPI_LoWord($iMidiMessage)
    Local $iHiWord = _WinAPI_HiWord($iMidiMessage)

    [/autoit] [autoit][/autoit] [autoit]

    Local $bStatus = BitAND($iLoWord, 0xFF) ;LoByte
    Local $bData1 = BitShift($iLoWord, 8) ;HiByte
    Local $bData2 = BitAND($iHiWord, 0xFF) ;LoByte

    [/autoit] [autoit][/autoit] [autoit]

    Local $Chan = BitAND($bStatus, 0xF)
    Local $MidiMsg = BitShift($bStatus, 4)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetData($cEdit_Data, "StatusByte: " & $bStatus & @TAB & "DataByte1: " & $bData1 & @TAB & "DataByte2: " & $bData2 & @CRLF, 1)

    [/autoit] [autoit][/autoit] [autoit]

    Switch $MidiMsg

    [/autoit] [autoit][/autoit] [autoit]

    Case 0x8 ; Note Off
    GUICtrlSetData($cEdit_Data, @TAB & "NoteOff: MidiChannel: " & $Chan & @TAB & "NoteNumber: " & $bData1 & @TAB & "Velocity: " & $bData2 & @CRLF, 1)

    [/autoit] [autoit][/autoit] [autoit]

    Case 0x9 ; Note On
    GUICtrlSetData($cEdit_Data, @TAB & "NoteOn: MidiChannel: " & $Chan & @TAB & "NoteNumber: " & $bData1 & @TAB & "Velocity: " & $bData2 & @CRLF, 1)

    [/autoit] [autoit][/autoit] [autoit]

    Case 0xA ; Polyphonic aftertouch
    GUICtrlSetData($cEdit_Data, @TAB & "Polyphonic aftertouch: MidiChannel: " & $Chan & @TAB & "NoteNumber: " & $bData1 & @TAB & "Poly Pressure: " & $bData2 & @CRLF, 1)

    [/autoit] [autoit][/autoit] [autoit]

    Case 0xB ; Control Change
    GUICtrlSetData($cEdit_Data, @TAB & "Control Change: MidiChannel: " & $Chan & @TAB & "Controller: " & $bData1 & @TAB & "Value: " & $bData2 & @CRLF, 1)

    [/autoit] [autoit][/autoit] [autoit]

    Case 0xC ; Program Change
    GUICtrlSetData($cEdit_Data, @TAB & "Program Change: MidiChannel: " & $Chan & @TAB & "Programm: " & $bData1 & @CRLF, 1)

    [/autoit] [autoit][/autoit] [autoit]

    Case 0xD ; Channel aftertouch
    GUICtrlSetData($cEdit_Data, @TAB & "Channel aftertouch: MidiChannel: " & $Chan & @TAB & "Aftertouch : " & $bData1 & @CRLF, 1)

    [/autoit] [autoit][/autoit] [autoit]

    Case 0xE ; Pitch Bend
    GUICtrlSetData($cEdit_Data, @TAB & "Pitch Bend: MidiChannel: " & $Chan & @TAB & "LSB: " & $bData1 & @TAB & "MSB: " & $bData2 & @CRLF, 1)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==>_ProcessData

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _MidiWinProc($hWnd, $iMsg, $wParam, $lParam)
    Switch $iMsg
    Case $MIM_OPEN
    ConsoleWrite("> MIM_OPEN" & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    Case $MIM_CLOSE ;hMidi Handle ab jetzt ungültig
    ConsoleWrite("> MIM_CLOSE" & @CRLF)
    $hMidi = 0

    [/autoit] [autoit][/autoit] [autoit]

    Case $MIM_DATA ; Normale Midi MSG
    ConsoleWrite("> MIM_DATA" & @CRLF)
    _ProcessData($lParam)

    [/autoit] [autoit][/autoit] [autoit]

    Case $MIM_MOREDATA
    ConsoleWrite("> MIM_MOREDATA" & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    Case $MIM_LONGDATA
    ConsoleWrite("> MIM_LONGDATA" & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    Switch $bRelease
    Case False ; SysEx Daten kommen rein
    Local $tMidiHDR = DllStructCreate($MIDIHDR, $lParam)
    Local $iBytesRecorded = DllStructGetData($tMidiHDR, "dwBytesRecorded")
    ConsoleWrite("+ LONGDATA IN: " & $iBytesRecorded & " bytes" & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    _ProcessLongData(DllStructGetData($tMidiHDR, "lpData"), $iBytesRecorded)

    [/autoit] [autoit][/autoit] [autoit]

    _MidiIn_AddBuffer($hMidi, $lParam, 48)

    [/autoit] [autoit][/autoit] [autoit]

    Case Else ; Druch _MidiIn_Reset wird hier der Buffer zurückgegeben und muss hier "unprepared" werden
    ConsoleWrite("! Unprepare Buffer" & @CRLF)
    _MidiIn_UnprepareHeader($hMidi, $lParam, 48)

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    Case $MIM_ERROR
    ConsoleWrite("> MIM_ERROR" & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    Case $MIM_LONGERROR
    ConsoleWrite("> MIM_LONGERROR" & @CRLF)
    _MidiIn_AddBuffer($hMidi, $lParam, 48)

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    EndFunc ;==>_MidiWinProc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Midi_Start()
    ConsoleWrite(@CRLF & "!=============================" & @CRLF)
    ConsoleWrite("! starting..." & @CRLF & @CRLF)
    Local $aRegExp = StringRegExp(GUICtrlRead($cCombo), "<(\d+)>", 3)
    If @error Or Not IsArray($aRegExp) Then Return
    Local $iDevice = $aRegExp[0]

    [/autoit] [autoit][/autoit] [autoit]

    If $iDevice = $iDeviceCurrent Then
    ConsoleWrite("- already running" & @CRLF)
    Return
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $bRelease = False

    [/autoit] [autoit][/autoit] [autoit]

    Local $iRet

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    If $hMidi <> 0 Then _Midi_Stop()
    $hMidi = _MidiIn_Open($iDevice, $hGui, 0, BitOR($CALLBACK_WINDOW, $MIDI_IO_STATUS))
    ConsoleWrite("! MidiIn Open: " & $hMidi & " error: " & @error & @CRLF)
    $iDeviceCurrent = $iDevice

    [/autoit] [autoit][/autoit] [autoit]

    $iRet = _MidiIn_PrepareHeader($hMidi, DllStructGetPtr($tBuffer1, "lpData"), 48)
    ConsoleWrite("! Prepare Header: " & $iRet & " error: " & @error & @CRLF)
    $iRet = _MidiIn_PrepareHeader($hMidi, DllStructGetPtr($tBuffer2, "lpData"), 48)
    ConsoleWrite("! Prepare Header: " & $iRet & " error: " & @error & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    $iRet = _MidiIn_AddBuffer($hMidi, DllStructGetPtr($tBuffer2, "lpData"), 48)
    ConsoleWrite("! Add Buffer: " & $iRet & " error: " & @error & @CRLF)
    $iRet = _MidiIn_AddBuffer($hMidi, DllStructGetPtr($tBuffer1, "lpData"), 48)
    ConsoleWrite("! Add Buffer: " & $iRet & " error: " & @error & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    $iRet = _MidiIn_Start($hMidi)
    ConsoleWrite("! MidiIn Start: " & $iRet & " error: " & @error & @CRLF)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==>_Midi_Start

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Midi_Stop()
    ConsoleWrite(@CRLF & "!=============================" & @CRLF)
    ConsoleWrite("! stopping..." & @CRLF & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    $bRelease = True

    [/autoit] [autoit][/autoit] [autoit]

    Local $iRet
    $iRet = _MidiIn_Reset($hMidi)
    ConsoleWrite("! MidiIn Reset: " & $iRet & " error: " & @error & @CRLF)
    $iRet = _MidiIn_Stop($hMidi)
    ConsoleWrite("! MidiIn Stop: " & $iRet & " error: " & @error & @CRLF)
    $iRet = _MidiIn_Close($hMidi)
    ConsoleWrite("! MidiIn Close: " & $iRet & " error: " & @error & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    $iDeviceCurrent = -1
    EndFunc ;==>_Midi_Stop

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _GetDevices()
    Local $tMidiInCaps = DllStructCreate($MIDIINCAPS)
    Local $pMidiInCaps = DllStructGetPtr($tMidiInCaps)
    Local $iMidiInCaps = DllStructGetSize($tMidiInCaps)

    [/autoit] [autoit][/autoit] [autoit]

    Local $iDeviceCnt = _MidiIn_GetNumDevs()
    Local $sDevice = ""
    Local $sDefault = ""

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 0 To ($iDeviceCnt - 1)
    _MidiIn_GetDevCaps($i, $pMidiInCaps, $iMidiInCaps)
    $sDevice &= "<" & $i & "> " & DllStructGetData($tMidiInCaps, "szPname") & "|"
    If $i = 0 Then $sDefault = "<" & $i & "> " & DllStructGetData($tMidiInCaps, "szPname")
    Next

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetData($cCombo, $sDevice, $sDefault)
    EndFunc ;==>_GetDevices

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _CreateBuffer($iSize = 256, $iID = 0)
    Local $tBuffer = DllStructCreate("uint BufferSize; byte BufferData[" & $iSize & "];" & $MIDIHDR)

    [/autoit] [autoit][/autoit] [autoit]

    DllStructSetData($tBuffer, "BufferSize", $iSize)
    DllStructSetData($tBuffer, "lpData", DllStructGetPtr($tBuffer, "BufferData"))
    DllStructSetData($tBuffer, "dwBufferLength", $iSize)
    DllStructSetData($tBuffer, "dwUser", $iID)

    [/autoit] [autoit][/autoit] [autoit]

    Return $tBuffer
    EndFunc ;==>_CreateBuffer

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    Exit
    EndFunc ;==>_Exit

    [/autoit]

    Ich hab auch die MIDI.au3 etwas angepasst: Der Inhalt kann nicht angezeigt werden, da er nicht mehr verfügbar ist.
    und zwar die DllCall-Return Variable: Local $aResult
    und eine errorabfrage

    Ich würde auch immer $aResult[0] als Rückgabewert verwenden:

    [autoit]

    Switch $aResult[0]
    Case 0 ;$MMSYSERR_NOERROR
    Return $aResult[0]
    Case Else
    Return SetError(1, 0, $aResult[0])
    EndSwitch

    [/autoit]

    Falls du dein System beibehalten willst, dann verwende aber trotzdem Switch statt If:

    [autoit]

    Switch $aResult[0]
    Case $MMSYSERR_NOERROR
    Return 1
    Case $MMSYSERR_INVALHANDLE
    Return SetError(1,1,0)
    Case $MMSYSERR_INVALPARAM
    Return SetError(2,2,0)
    Case $MMSYSERR_NOMEM
    Return SetError(3,3,0)
    Case Else
    Return SetError(4,4,0)
    EndSwitch

    [/autoit]

    E

  • GDI+ 3D Object Viewer (Wavefront .obj Format)

    • eukalyptus
    • 29. April 2012 um 11:59

    Großartiges Script! :thumbup:

    Hier hab ich ein Testscript, das ich vor kurzem erstellt hab.
    Damit kann man schnell zoomen, verschieben und drehen ohne das Objekt selbst neu zu berechnen.
    Es wird einfach der Ziel-GraphicsContext transformiert...

    Vielleicht kannst du das ja gebrauchen.
    (linke Maustaste = verschieben, Scrollrad = zoomen, linke Maustaste + Scrollrad = drehen, rechte Maustaste = reset)

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("MustDeclareVars", 1)
    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global $iWidth = 1000;@DesktopWidth
    Global $iHeight = 580;@DesktopHeight

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    Global $hGui = GUICreate("Test", $iWidth, $iHeight)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_ResetGraphicsTransform")
    Global $hDC = _WinAPI_GetDC($hGui)
    Global $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
    Global $hBmpTmp = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
    _WinAPI_DeleteObject($hBMP)
    $hBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmpTmp)
    _GDIPlus_BitmapDispose($hBmpTmp)
    Global $hCDC = _WinAPI_CreateCompatibleDC($hDC)
    Global $hOBJ = _WinAPI_SelectObject($hCDC, $hBMP)
    Global $hGfxBuffer = _GDIPlus_GraphicsCreateFromHDC($hCDC)
    _GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFFFFFFFF)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hPenR = _GDIPlus_PenCreate(0xFFAA0000, 1)
    Global $hBrushR = _GDIPlus_BrushCreateSolid(0x88AA0000)
    Global $hPenG = _GDIPlus_PenCreate(0xFF00AA00, 1)
    Global $hBrushG = _GDIPlus_BrushCreateSolid(0x8800AA00)
    Global $hPenB = _GDIPlus_PenCreate(0xFF0000FF, 1)
    Global $hBrushB = _GDIPlus_BrushCreateSolid(0x880000FF)

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_PAINT, "WM_PAINT")
    GUIRegisterMsg($WM_ERASEBKGND, "WM_PAINT")

    [/autoit] [autoit][/autoit] [autoit]

    Global $iMouseX, $iMouseY
    GUIRegisterMsg($WM_LBUTTONDOWN, "WM_LBUTTONDOWN")
    GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL")
    GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE")
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    Global $tCurve1 = _CreateCurve(Random(10, 30, 1))
    Global $tCurve2 = _CreateCurve(Random(10, 30, 1))
    Global $tCurve3 = _CreateCurve(Random(10, 30, 1))

    [/autoit] [autoit][/autoit] [autoit]

    _Draw()

    [/autoit] [autoit][/autoit] [autoit]

    While Sleep(10)
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Draw()
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFFFFFFFF)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipFillClosedCurve2", "hwnd", $hGfxBuffer, "hwnd", $hBrushR, "ptr", DllStructGetPtr($tCurve1, "Pnt"), "int", DllStructGetData($tCurve1, "Cnt"), "float", 0, "int", 0)
    DllCall($ghGDIPDll, "uint", "GdipDrawClosedCurve2", "hwnd", $hGfxBuffer, "hwnd", $hPenR, "ptr", DllStructGetPtr($tCurve1, "Pnt"), "int", DllStructGetData($tCurve1, "Cnt"), "float", 0)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipFillClosedCurve2", "hwnd", $hGfxBuffer, "hwnd", $hBrushG, "ptr", DllStructGetPtr($tCurve2, "Pnt"), "int", DllStructGetData($tCurve2, "Cnt"), "float", 0, "int", 0)
    DllCall($ghGDIPDll, "uint", "GdipDrawClosedCurve2", "hwnd", $hGfxBuffer, "hwnd", $hPenG, "ptr", DllStructGetPtr($tCurve2, "Pnt"), "int", DllStructGetData($tCurve2, "Cnt"), "float", 0)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipFillClosedCurve2", "hwnd", $hGfxBuffer, "hwnd", $hBrushB, "ptr", DllStructGetPtr($tCurve3, "Pnt"), "int", DllStructGetData($tCurve3, "Cnt"), "float", 0, "int", 0)
    DllCall($ghGDIPDll, "uint", "GdipDrawClosedCurve2", "hwnd", $hGfxBuffer, "hwnd", $hPenB, "ptr", DllStructGetPtr($tCurve3, "Pnt"), "int", DllStructGetData($tCurve3, "Cnt"), "float", 0)

    [/autoit] [autoit][/autoit] [autoit]

    _WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hCDC, 0, 0, 0x00CC0020)
    EndFunc ;==>_Draw

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _ResetGraphicsTransform()
    DllCall($ghGDIPDll, "uint", "GdipResetWorldTransform", "hwnd", $hGfxBuffer)
    _Draw()
    EndFunc ;==>_ResetGraphicsTransform

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_LBUTTONDOWN($hWnd, $Msg, $wParam, $lParam)
    $iMouseX = BitAND($lParam, 0x0000FFFF)
    $iMouseY = BitShift($lParam, 16)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_LBUTTONDOWN

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_MOUSEMOVE($hWnd, $Msg, $wParam, $lParam)

    [/autoit] [autoit][/autoit] [autoit]

    Switch BitAND($wParam, 0x0000FFFF)
    Case 1
    Local $iX = BitAND($lParam, 0x0000FFFF)
    Local $iY = BitShift($lParam, 16)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipTranslateWorldTransform", "hwnd", $hGfxBuffer, "float", $iX - $iMouseX, "float", $iY - $iMouseY, "int", True)

    [/autoit] [autoit][/autoit] [autoit]

    $iMouseX = $iX
    $iMouseY = $iY

    [/autoit] [autoit][/autoit] [autoit]

    _Draw()

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_MOUSEMOVE

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_MOUSEWHEEL($hWnd, $Msg, $wParam, $lParam)

    [/autoit] [autoit][/autoit] [autoit]

    Switch BitAND($wParam, 0x0000FFFF)
    Case 1
    Local $fAngle = -3
    If BitShift($wParam, 16) < 0 Then $fAngle = 3

    [/autoit] [autoit][/autoit] [autoit]

    Local $tPnt = DllStructCreate("float X; float Y;")
    DllStructSetData($tPnt, "X", $iMouseX)
    DllStructSetData($tPnt, "Y", $iMouseY)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipTransformPoints", "hwnd", $hGfxBuffer, "int", 0, "int", 1, "ptr", DllStructGetPtr($tPnt), "int", 1)

    [/autoit] [autoit][/autoit] [autoit]

    Local $fX = DllStructGetData($tPnt, "X")
    Local $fY = DllStructGetData($tPnt, "Y")

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipTranslateWorldTransform", "hwnd", $hGfxBuffer, "float", $fX, "float", $fY, "int", False)
    DllCall($ghGDIPDll, "uint", "GdipRotateWorldTransform", "hwnd", $hGfxBuffer, "float", $fAngle, "int", False)
    DllCall($ghGDIPDll, "uint", "GdipTranslateWorldTransform", "hwnd", $hGfxBuffer, "float", -$fX, "float", -$fY, "int", False)

    [/autoit] [autoit][/autoit] [autoit]

    Case Else
    Local $aInfo = GUIGetCursorInfo($hGui)
    Local $fScale = 1.1
    If BitShift($wParam, 16) < 0 Then $fScale = 0.9

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipTranslateWorldTransform", "hwnd", $hGfxBuffer, "float", -$aInfo[0], "float", -$aInfo[1], "int", True)
    DllCall($ghGDIPDll, "uint", "GdipScaleWorldTransform", "hwnd", $hGfxBuffer, "float", $fScale, "float", $fScale, "int", True)
    DllCall($ghGDIPDll, "uint", "GdipTranslateWorldTransform", "hwnd", $hGfxBuffer, "float", $aInfo[0], "float", $aInfo[1], "int", True)

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    _Draw()

    [/autoit] [autoit][/autoit] [autoit]

    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_MOUSEWHEEL

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _CreateCurve($iCnt)
    Local $tCurve = DllStructCreate("uint Cnt; float Pnt[" & $iCnt * 2 & "];")
    DllStructSetData($tCurve, "Cnt", $iCnt)
    For $i = 0 To $iCnt - 1
    DllStructSetData($tCurve, "Pnt", Random(0, $iWidth), $i * 2 + 1)
    DllStructSetData($tCurve, "Pnt", Random(0, $iHeight), $i * 2 + 2)
    Next
    Return $tCurve
    EndFunc ;==>_CreateCurve

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hCDC, 0, 0, 0x00CC0020)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_PAINT

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    _GDIPlus_PenDispose($hPenR)
    _GDIPlus_BrushDispose($hBrushR)
    _GDIPlus_PenDispose($hPenG)
    _GDIPlus_BrushDispose($hBrushG)
    _GDIPlus_PenDispose($hPenB)
    _GDIPlus_BrushDispose($hBrushB)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _WinAPI_SelectObject($hCDC, $hOBJ)
    _WinAPI_DeleteObject($hBMP)
    _WinAPI_DeleteDC($hCDC)
    _WinAPI_ReleaseDC($hGui, $hDC)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

    [/autoit]

    E

    EDIT: Hab ich ja total vergessen!
    Ich hab auch mit einer 3D-Matrix experimentiert:

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $bMatrixInit = "0x000000000000F03F0000000000000000000000000000000000000000000000000000000000000000000000000000F03F0000000000000000000000000000000000000000000000000000000000000000000000000000F03F0000000000000000000000000000000000000000000000000000000000000000000000000000F03F"
    Global Const $PI = ATan(1) * 4
    Global Const $LENS = 2560

    [/autoit] [autoit][/autoit] [autoit]

    Opt("MustDeclareVars", 1)
    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global $iWidth = 800
    Global $iHeight = 600
    Global $fCenterX = $iWidth / 2
    Global $fCenterY = $iHeight / 2

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    Global $hGui = GUICreate("Matrix Test", $iWidth, $iHeight, 20, 20)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    Global $hDC = _WinAPI_GetDC($hGui)
    Global $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
    Global $hBmpTmp = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
    _WinAPI_DeleteObject($hBMP)
    $hBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmpTmp)
    _GDIPlus_BitmapDispose($hBmpTmp)
    Global $hCDC = _WinAPI_CreateCompatibleDC($hDC)
    Global $hOBJ = _WinAPI_SelectObject($hCDC, $hBMP)
    Global $hGfxBuffer = _GDIPlus_GraphicsCreateFromHDC($hCDC)
    _GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFFFFFFFF)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hPen = _GDIPlus_PenCreate(0xFF00FF00)

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_PAINT, "WM_PAINT")
    GUIRegisterMsg($WM_ERASEBKGND, "WM_PAINT")

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $tObj = _Create3DObject(60, 20, 18)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(10)
    _Draw()
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Draw()
    Local $tMX = _MX3D_Create()

    [/autoit] [autoit][/autoit] [autoit]

    Local Static $fRX = 0, $fRY = 0, $fRZ = 0, $fS = 1, $fSPlus = 0.01
    $fS += $fSPlus
    If ($fS >= 2.5) Or ($fS < 0.2) Then $fSPlus *= -1
    $fRX += 1
    $fRY += 0.42
    $fRZ += 0.17

    [/autoit] [autoit][/autoit] [autoit]

    Local $iTimer = TimerInit()
    _MX3D_RotateX($tMX, $fRX)
    _MX3D_RotateY($tMX, $fRY)
    _MX3D_RotateZ($tMX, $fRZ)
    _MX3D_Scale($tMX, $fS, $fS, $fS)
    ConsoleWrite("+ Matrix: " & TimerDiff($iTimer) & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    $iTimer = TimerInit()
    TransFormPoints($tObj, $tMX)
    ConsoleWrite("> Transform: " & TimerDiff($iTimer) & @CRLF)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Local $iCnt = DllStructGetData($tObj, "Cnt")
    Local $fX, $fY, $fR

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFF000000)
    $iTimer = TimerInit()
    For $i = 0 To $iCnt - 1
    If DllStructGetData($tObj, "Vis", $i + 1) = True Then
    $fX = DllStructGetData($tObj, "Pnt", $i * 2 + 1)
    $fY = DllStructGetData($tObj, "Pnt", $i * 2 + 2)
    DllCall($ghGDIPDll, "int", "GdipDrawEllipse", "handle", $hGfxBuffer, "handle", $hPen, "float", $fX, "float", $fY, "float", 1, "float", 1)
    EndIf
    Next
    ConsoleWrite("! Draw: " & TimerDiff($iTimer) & @CRLF)

    [/autoit] [autoit][/autoit] [autoit]

    _WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hCDC, 0, 0, 0x00CC0020)
    EndFunc ;==>_Draw

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _MX3D_RotateX(ByRef $tMX, $fD)
    ;[ 1 0 0 0 ]
    ;[ 0 C -S 0 ]
    ;[ 0 S C 0 ]
    ;[ 0 0 0 1 ]

    [/autoit] [autoit][/autoit] [autoit]

    If $fD = 0 Then Return
    Local $fR = $fD * 0.0174532925199433

    [/autoit] [autoit][/autoit] [autoit]

    Local $fC = Cos($fR)
    Local $fS = Sin($fR)

    [/autoit] [autoit][/autoit] [autoit]

    Local $tMX1 = _MX3D_Create()
    DllStructSetData($tMX1, 1, $fC, 6)
    DllStructSetData($tMX1, 1, -$fS, 7)
    DllStructSetData($tMX1, 1, $fS, 10)
    DllStructSetData($tMX1, 1, $fC, 11)

    [/autoit] [autoit][/autoit] [autoit]

    $tMX = _MX3D_MulMatrix($tMX1, $tMX)

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==>_MX3D_RotateX

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _MX3D_RotateY(ByRef $tMX, $fD)
    ;[ C 0 S 0 ]
    ;[ 0 1 0 0 ]
    ;[-S 0 C 0 ]
    ;[ 0 0 0 1 ]

    [/autoit] [autoit][/autoit] [autoit]

    If $fD = 0 Then Return
    Local $fR = $fD * 0.0174532925199433

    [/autoit] [autoit][/autoit] [autoit]

    Local $fC = Cos($fR)
    Local $fS = Sin($fR)

    [/autoit] [autoit][/autoit] [autoit]

    Local $tMX1 = _MX3D_Create()
    DllStructSetData($tMX1, 1, $fC, 1)
    DllStructSetData($tMX1, 1, $fS, 3)
    DllStructSetData($tMX1, 1, -$fS, 9)
    DllStructSetData($tMX1, 1, $fC, 11)

    [/autoit] [autoit][/autoit] [autoit]

    $tMX = _MX3D_MulMatrix($tMX1, $tMX)

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==>_MX3D_RotateY

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _MX3D_RotateZ(ByRef $tMX, $fD)
    ;[ C -S 0 0 ]
    ;[ S C 0 0 ]
    ;[ 0 0 1 0 ]
    ;[ 0 0 0 1 ]

    [/autoit] [autoit][/autoit] [autoit]

    If $fD = 0 Then Return
    Local $fR = $fD * 0.0174532925199433

    [/autoit] [autoit][/autoit] [autoit]

    Local $fC = Cos($fR)
    Local $fS = Sin($fR)

    [/autoit] [autoit][/autoit] [autoit]

    Local $tMX1 = _MX3D_Create()
    DllStructSetData($tMX1, 1, $fC, 1)
    DllStructSetData($tMX1, 1, -$fS, 2)
    DllStructSetData($tMX1, 1, $fS, 5)
    DllStructSetData($tMX1, 1, $fC, 6)

    [/autoit] [autoit][/autoit] [autoit]

    $tMX = _MX3D_MulMatrix($tMX1, $tMX)

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==>_MX3D_RotateZ

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _MX3D_Scale(ByRef $tMX, $fX, $fY, $fZ)
    ;[ X 0 0 0 ]
    ;[ 0 Y 0 0 ]
    ;[ 0 0 Z 0 ]
    ;[ 0 0 0 1 ]

    [/autoit] [autoit][/autoit] [autoit]

    Local $tMX1 = _MX3D_Create()
    DllStructSetData($tMX1, 1, $fX, 1)
    DllStructSetData($tMX1, 1, $fY, 6)
    DllStructSetData($tMX1, 1, $fZ, 11)

    [/autoit] [autoit][/autoit] [autoit]

    $tMX = _MX3D_MulMatrix($tMX1, $tMX)

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==>_MX3D_Scale

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _MX3D_Translate(ByRef $tMX, $fX, $fY, $fZ)
    ;[ 1 0 0 X ]
    ;[ 0 1 0 Y ]
    ;[ 0 0 1 Z ]
    ;[ 0 0 0 1 ]
    Local $tMX1 = _MX3D_Create()
    DllStructSetData($tMX1, 1, $fX, 4)
    DllStructSetData($tMX1, 1, $fY, 8)
    DllStructSetData($tMX1, 1, $fZ, 12)

    [/autoit] [autoit][/autoit] [autoit]

    $tMX = _MX3D_MulMatrix($tMX1, $tMX)
    EndFunc ;==>_MX3D_Translate

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _MX3D_MulMatrix($tMX1, $tMX2)
    Local $tMX = DllStructCreate("double[16];")

    [/autoit] [autoit][/autoit] [autoit]

    Local $fS
    For $x = 0 To 2
    For $y = 0 To 3
    $fS = 0
    For $z = 0 To 3
    $fS += DllStructGetData($tMX2, 1, $x * 4 + $z + 1) * DllStructGetData($tMX1, 1, $z * 4 + $y + 1)
    Next
    DllStructSetData($tMX, 1, $fS, $x * 4 + $y + 1)
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit]

    DllStructSetData($tMX, 1, 1, 16)

    [/autoit] [autoit][/autoit] [autoit]

    Return $tMX
    EndFunc ;==>_MX3D_MulMatrix

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _MX3D_MulVector($tMX, $fX, $fY, $fZ, ByRef $fRX, ByRef $fRY, ByRef $fRZ)
    $fRX = ($fX * DllStructGetData($tMX, 1, 1)) + ($fY * DllStructGetData($tMX, 1, 2)) + ($fZ * DllStructGetData($tMX, 1, 3)) + DllStructGetData($tMX, 1, 4)
    $fRY = ($fX * DllStructGetData($tMX, 1, 5)) + ($fY * DllStructGetData($tMX, 1, 6)) + ($fZ * DllStructGetData($tMX, 1, 7)) + DllStructGetData($tMX, 1, 8)
    $fRZ = ($fX * DllStructGetData($tMX, 1, 9)) + ($fY * DllStructGetData($tMX, 1, 10)) + ($fZ * DllStructGetData($tMX, 1, 11)) + DllStructGetData($tMX, 1, 12)
    Return True
    EndFunc ;==>_MX3D_MulVector

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _MX3D_Clear(ByRef $tMX)
    $tMX = 0
    $tMX = DllStructCreate("double[16];")
    EndFunc ;==>_MX3D_Clear

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _MX3D_Reset(ByRef $tMX)
    ;[ 1 0 0 0 ]
    ;[ 0 1 0 0 ]
    ;[ 0 0 1 0 ]
    ;[ 0 0 0 1 ]
    Local $tSet = DllStructCreate("byte[128];", DllStructGetPtr($tMX))
    DllStructSetData($tSet, 1, $bMatrixInit)
    EndFunc ;==>_MX3D_Reset

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _MX3D_Create()
    ;[ 1 0 0 0 ]
    ;[ 0 1 0 0 ]
    ;[ 0 0 1 0 ]
    ;[ 0 0 0 1 ]
    Local $tMX = DllStructCreate("double[16];")

    [/autoit] [autoit][/autoit] [autoit]

    DllStructSetData($tMX, 1, 1, 1)
    DllStructSetData($tMX, 1, 1, 6)
    DllStructSetData($tMX, 1, 1, 11)
    DllStructSetData($tMX, 1, 1, 16)

    [/autoit] [autoit][/autoit] [autoit]

    Return $tMX
    EndFunc ;==>_MX3D_Create

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func TransFormPoints($tPnt, $tMX)
    Local $iCnt = DllStructGetData($tPnt, "Cnt")
    Local $fX, $fY, $fZ, $fRX, $fRY, $fRZ, $fD
    Local $iIdx

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 0 To $iCnt - 1
    $iIdx = $i * 3
    $fX = DllStructGetData($tPnt, "3D", $iIdx + 1)
    $fY = DllStructGetData($tPnt, "3D", $iIdx + 2)
    $fZ = DllStructGetData($tPnt, "3D", $iIdx + 3)

    [/autoit] [autoit][/autoit] [autoit]

    _MX3D_MulVector($tMX, $fX, $fY, $fZ, $fRX, $fRY, $fRZ)

    [/autoit] [autoit][/autoit] [autoit]

    $fD = ($LENS - $fRZ)
    If $fD > 0 Then
    $iIdx = $i * 2
    DllStructSetData($tPnt, "Pnt", $fCenterX + ($LENS * $fRX / $fD), $iIdx + 1)
    DllStructSetData($tPnt, "Pnt", $fCenterY - ($LENS * $fRY / $fD), $iIdx + 2)
    DllStructSetData($tPnt, "Vis", True, $i + 1)
    Else
    DllStructSetData($tPnt, "Vis", False, $i + 1)
    EndIf
    Next

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==>TransFormPoints

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Create3DObject($fRadius, $iSlices, $iBands)
    Local $iCnt = $iSlices * $iBands
    Local $tPnt = DllStructCreate("uint Cnt; float Pnt[" & $iCnt * 2 & "]; byte Vis[" & $iCnt & "]; float 3D[" & $iCnt * 3 & "];")
    DllStructSetData($tPnt, "Cnt", $iCnt - 1)

    [/autoit] [autoit][/autoit] [autoit]

    Local $iPnt = 0, $iIdx, $fPhi, $fTheta
    For $i = 0 To $iSlices - 1
    $fPhi = $PI / ($iSlices - 1) * $i
    For $j = 0 To $iBands - 1
    $fTheta = 2 * (-$PI / ($iBands - 1) * $j)
    $iIdx = $iPnt * 3
    DllStructSetData($tPnt, "3D", -Int($fRadius * Sin($fPhi) * Cos($fTheta)), $iIdx + 1)
    DllStructSetData($tPnt, "3D", -Int($fRadius * Sin($fPhi) * Sin($fTheta)), $iIdx + 2)
    DllStructSetData($tPnt, "3D", -Int($fRadius * Cos($fPhi)), $iIdx + 3)

    [/autoit] [autoit][/autoit] [autoit]

    $iPnt += 1
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit]

    Return $tPnt
    EndFunc ;==>_Create3DObject

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hCDC, 0, 0, 0x00CC0020)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_PAINT

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _WinAPI_SelectObject($hCDC, $hOBJ)
    _WinAPI_DeleteObject($hBMP)
    _WinAPI_DeleteDC($hCDC)
    _WinAPI_ReleaseDC($hGui, $hDC)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

    [/autoit]
  • GDIPlus gebürstetes Aluminium ;)

    • eukalyptus
    • 17. April 2012 um 17:50

    Eine weitere GdiPlus-Spielerei...
    Diesmal: gebürstetes Aluminium
    Der Inhalt kann nicht angezeigt werden, da er nicht mehr verfügbar ist.

    Im Prinzip sind es nur 3 Schritte:
    1 Schritt: Noise erstellen; zufällige Grautöne für jeden Pixel der Bitmap; wegen der Geschwindigkeit wird nur ein kleines NoiseBitmap erstellt und dann wiederholt
    Das Ergebnis ist zwar nicht so schön, aber AutoIt ist etwas zu langsam, als dass man das gesammte Bild "noisen" könnte...
    (Ein besseres Ergebnis hätte man vielleicht noch mit "Gaussian noise")
    2 Schritt: MotionBlur; verwandlelt die Grautonpixel zu Linien
    Der Effekt ergibt sich einfach, indem das Bild transparent mit einem immer größeren X-Offset wiederholt wird.
    (Ist warscheinlich der schlechteste Algo, aber auch der schnellste ;)
    3 Schritt: Lichtreflexion; ein Verlauf von Transparent zu Weiß wird darübergezeichnent
    -fertig

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <GDIPlusConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("MustDeclareVars", 1)
    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global $iWidth = 1200
    Global $iHeight = 600

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()
    Global $hGui = GUICreate("GDIPlus Script by Eukalyptus", $iWidth, $iHeight)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    Global $hDC = _WinAPI_GetDC($hGui)
    Global $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
    Global $hBmpTmp = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
    _WinAPI_DeleteObject($hBMP)
    $hBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmpTmp)
    _GDIPlus_BitmapDispose($hBmpTmp)
    Global $hCDC = _WinAPI_CreateCompatibleDC($hDC)
    Global $hOBJ = _WinAPI_SelectObject($hCDC, $hBMP)
    Global $hGfxBuffer = _GDIPlus_GraphicsCreateFromHDC($hCDC)
    _GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFFFFFFFF)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_PAINT, "WM_PAINT")
    GUIRegisterMsg($WM_ERASEBKGND, "WM_PAINT")

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $hBitmap = _CreateBackground()

    [/autoit] [autoit][/autoit] [autoit]

    _Draw()
    While 1
    Sleep(10)

    [/autoit] [autoit][/autoit] [autoit]

    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _CreateBackground()
    Local $hBitmap_ALU = _CreateBrushedAluminum($iWidth, $iHeight)
    Local $hBitmap_ALU2 = _CreateBrushedAluminum($iWidth, $iHeight, 14, 0.6, 0.2, 0.2, 0.2, 0x33FFFFFF)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 1, False)
    Local $hBitmap = $aResult[6]
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hContext, 2)
    DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "hwnd", $hContext, "int", 7)
    _GDIPlus_GraphicsDrawImage($hContext, $hBitmap_ALU, 0, 0)

    [/autoit] [autoit][/autoit] [autoit]

    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 3, False)
    Local $hPath = $aResult[2]

    [/autoit] [autoit][/autoit] [autoit]

    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial Black")

    [/autoit] [autoit][/autoit] [autoit]

    _PathAddText($hPath, "Brushed", $hFamily, $hFormat, 100, 40)
    _PathAddText($hPath, "Aluminium", $hFamily, $hFormat, 100)
    _PathAddText($hPath, "AutoIt GdiPlus Script", $hFamily, $hFormat, 50, 80)

    [/autoit] [autoit][/autoit] [autoit]

    $aResult = DllCall($ghGDIPDll, "uint", "GdipClonePath", "hwnd", $hPath, "int*", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 3, False)
    Local $hPath_Clone = $aResult[2]

    [/autoit] [autoit][/autoit] [autoit]

    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, 2, 2)
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPath_Clone, "hwnd", $hMatrix)
    Local $hBrush = _GDIPlus_BrushCreateSolid(0x44FFFFFF)
    DllCall($ghGDIPDll, "uint", "GdipFillPath", "hwnd", $hContext, "hwnd", $hBrush, "hwnd", $hPath_Clone)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_MatrixTranslate($hMatrix, -5, -5)
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPath_Clone, "hwnd", $hMatrix)
    _GDIPlus_BrushSetSolidColor($hBrush, 0x88000000)
    DllCall($ghGDIPDll, "uint", "GdipFillPath", "hwnd", $hContext, "hwnd", $hBrush, "hwnd", $hPath_Clone)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_MatrixDispose($hMatrix)
    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath_Clone)
    _GDIPlus_BrushDispose($hBrush)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateTexture", "hwnd", $hBitmap_ALU2, "int", 0, "int*", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 2, False)
    $hBrush = $aResult[3]
    DllCall($ghGDIPDll, "uint", "GdipFillPath", "hwnd", $hContext, "hwnd", $hBrush, "hwnd", $hPath)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_BrushDispose($hBrush)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_BitmapDispose($hBitmap_ALU)
    _GDIPlus_BitmapDispose($hBitmap_ALU2)
    Return $hBitmap
    EndFunc ;==>_CreateBackground

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _PathAddText($hPath, $sText, $hFamily, $hFormat, $fSize, $fYOff = 0)
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)
    Local $tBounds = _GDIPlus_RectFCreate(0, 0, 0, 0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 1, False)
    Local $hPath_Tmp = $aResult[2]

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipAddPathString", "hwnd", $hPath_Tmp, "wstr", $sText, "int", -1, "hwnd", $hFamily, "int", 1, "float", $fSize, "ptr", DllStructGetPtr($tLayout), "hwnd", $hFormat)
    DllCall($ghGDIPDll, "uint", "GdipGetPathWorldBounds", "hwnd", $hPath_Tmp, "ptr", DllStructGetPtr($tBounds), "hwnd", 0, "hwnd", 0)
    DllStructSetData($tLayout, "X", ($iWidth / 2) - (DllStructGetData($tBounds, "Width") / 2) - DllStructGetData($tBounds, "X"))

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipGetPathWorldBounds", "hwnd", $hPath, "ptr", DllStructGetPtr($tBounds), "hwnd", 0, "hwnd", 0)
    DllStructSetData($tLayout, "Y", DllStructGetData($tBounds, "Y") + DllStructGetData($tBounds, "Height") + $fYOff)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipAddPathString", "hwnd", $hPath, "wstr", $sText, "int", -1, "hwnd", $hFamily, "int", 1, "float", $fSize, "ptr", DllStructGetPtr($tLayout), "hwnd", $hFormat)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath_Tmp)
    EndFunc ;==>_PathAddText

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Draw()
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFF000000)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawImage($hGfxBuffer, $hBitmap, 0, 0)

    [/autoit] [autoit][/autoit] [autoit]

    _WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hCDC, 0, 0, 0x00CC0020)
    EndFunc ;==>_Draw

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _CreateBrushedAluminum($iW, $iH, $iBlurDist = 14, $fBlurTrans = 0.6, $fRed = 0.8, $fGreen = 0.9, $fBlue = 1, $iLightColor = 0xAAFFFFFF, $fLightAngle = -8, $fLightSigma = 0.48, $fLightScale = 0.83)
    $iBlurDist = Ceiling($iBlurDist)
    $iBlurDist += 1 - Mod($iBlurDist, 2)

    [/autoit] [autoit][/autoit] [autoit]

    Local $iOverSize = 0
    For $i = 1 To $iBlurDist Step 2
    $iOverSize += $i + $i + 1
    Next

    [/autoit] [autoit][/autoit] [autoit]

    Local $iWO = $iW + $iOverSize

    [/autoit] [autoit][/autoit] [autoit]

    ;=========================================
    ; Add Noise
    ;=========================================

    [/autoit] [autoit][/autoit] [autoit]

    Local $iNoiseSize = 40

    [/autoit] [autoit][/autoit] [autoit]

    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iNoiseSize, "int", $iNoiseSize, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 1, False)
    Local $hBmp_Noise = $aResult[6]
    Local $hGfx_Noise = _GDIPlus_ImageGetGraphicsContext($hBmp_Noise)

    [/autoit] [autoit][/autoit] [autoit]

    Local $tData = _GDIPlus_BitmapLockBits($hBmp_Noise, 0, 0, $iNoiseSize, $iNoiseSize, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32ARGB)
    Local $iStride = DllStructGetData($tData, "Stride")
    Local $iWidth = DllStructGetData($tData, "Width")
    Local $iHeight = DllStructGetData($tData, "Height")
    Local $pScan0 = DllStructGetData($tData, "Scan0")
    Local $tPixel = DllStructCreate("dword[" & $iWidth * $iHeight & "];", $pScan0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $iAmp
    For $row = 0 To $iHeight - 1
    For $col = 0 To $iWidth - 1
    $iAmp = Random(0, 0xFF, 1)
    DllStructSetData($tPixel, 1, BitOR(0xFF000000, BitShift($iAmp, -16), BitShift($iAmp, -8), $iAmp), $row * $iWidth + $col + 1)
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_BitmapUnlockBits($hBmp_Noise, $tData)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;=========================================
    ; Create Full NoiseBitmap
    ;=========================================

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWO, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 3, False)
    Local $hBmp_Full = $aResult[6]
    Local $hGfx_Full = _GDIPlus_ImageGetGraphicsContext($hBmp_Full)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx_Full, 2)
    DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "hwnd", $hGfx_Full, "int", 7)

    [/autoit] [autoit][/autoit] [autoit]

    Local $iXOff, $iYOff, $iSizeX, $iSizeY
    For $y = 0 To $iH Step $iNoiseSize / 2
    For $x = 0 To $iWO Step $iNoiseSize / 2
    $iXOff = Random(0, $iNoiseSize / 2, 1)
    $iYOff = Random(0, $iNoiseSize / 2, 1)
    $iSizeX = $iNoiseSize - $iXOff
    $iSizeY = $iNoiseSize - $iYOff
    _GDIPlus_GraphicsDrawImageRectRect($hGfx_Full, $hBmp_Noise, $iXOff, $iYOff, $iSizeX, $iSizeY, $x, $y, $iSizeX, $iSizeY)
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDispose($hGfx_Noise)
    _GDIPlus_BitmapDispose($hBmp_Noise)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;=========================================
    ; MotionBlur
    ;=========================================
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWO, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 3, False)
    Local $hBmp_Full2 = $aResult[6]
    Local $hGfx_Full2 = _GDIPlus_ImageGetGraphicsContext($hBmp_Full2)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx_Full2, 2)
    DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "hwnd", $hGfx_Full2, "int", 7)

    [/autoit] [autoit][/autoit] [autoit]

    Local $tColorMatrix = DllStructCreate("float[5]; float[5]; float[5]; float[5]; float[5];")
    DllStructSetData($tColorMatrix, 1, 1, 1)
    DllStructSetData($tColorMatrix, 2, 1, 2)
    DllStructSetData($tColorMatrix, 3, 1, 3)
    DllStructSetData($tColorMatrix, 4, $fBlurTrans, 4)
    DllStructSetData($tColorMatrix, 5, 1, 5)

    [/autoit] [autoit][/autoit] [autoit]

    $aResult = DllCall($ghGDIPDll, "int", "GdipCreateImageAttributes", "ptr*", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 4, False)
    Local $hImgAttrib = $aResult[1]
    DllCall($ghGDIPDll, "int", "GdipSetImageAttributesColorMatrix", "ptr", $hImgAttrib, "int", 1, "int", 1, "ptr", DllStructGetPtr($tColorMatrix), "ptr", 0, "int", 0)

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To $iBlurDist Step 2
    DllCall($ghGDIPDll, "int", "GdipDrawImageRectRectI", "hwnd", $hGfx_Full2, "hwnd", $hBmp_Full, "int", $i, "int", 0, "int", $iWO, "int", $iH, "int", 0, "int", 0, "int", $iWO, "int", $iH, "int", 2, "ptr", $hImgAttrib, "int", 0, "int", 0)
    If $i >= $iBlurDist Then
    DllStructSetData($tColorMatrix, 1, $fRed, 1)
    DllStructSetData($tColorMatrix, 2, $fGreen, 2)
    DllStructSetData($tColorMatrix, 3, $fBlue, 3)
    DllStructSetData($tColorMatrix, 4, 1, 4)
    DllCall($ghGDIPDll, "int", "GdipSetImageAttributesColorMatrix", "ptr", $hImgAttrib, "int", 1, "int", 1, "ptr", DllStructGetPtr($tColorMatrix), "ptr", 0, "int", 0)
    EndIf
    DllCall($ghGDIPDll, "int", "GdipDrawImageRectRectI", "hwnd", $hGfx_Full, "hwnd", $hBmp_Full2, "int", $i + 1, "int", 0, "int", $iWO, "int", $iH, "int", 0, "int", 0, "int", $iWO, "int", $iH, "int", 2, "ptr", $hImgAttrib, "int", 0, "int", 0)
    Next
    DllCall($ghGDIPDll, "int", "GdipDisposeImageAttributes", "ptr", $hImgAttrib)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDispose($hGfx_Full2)
    _GDIPlus_BitmapDispose($hBmp_Full2)
    _GDIPlus_GraphicsDispose($hGfx_Full)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;=========================================
    ; Add Light
    ;=========================================

    [/autoit] [autoit][/autoit] [autoit]

    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 3, False)
    Local $hBmp_Alu = $aResult[6]
    Local $hGfx_Alu = _GDIPlus_ImageGetGraphicsContext($hBmp_Alu)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx_Alu, 2)
    DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "hwnd", $hGfx_Alu, "int", 7)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawImage($hGfx_Alu, $hBmp_Full, -$iOverSize, 0)
    _GDIPlus_BitmapDispose($hBmp_Full)

    [/autoit] [autoit][/autoit] [autoit]

    Local $tPointF1 = DllStructCreate("float; float;")
    Local $tPointF2 = DllStructCreate("float; float;")
    DllStructSetData($tPointF2, 2, $iH * $fLightScale)

    [/autoit] [autoit][/autoit] [autoit]

    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateLineBrush", "ptr", DllStructGetPtr($tPointF1), "ptr", DllStructGetPtr($tPointF2), "uint", 0, "uint", $iLightColor, "int", 0, "int*", 0)
    If @error Or Not IsArray($aResult) Then Return SetError(1, 4, False)
    Local $hBrush = $aResult[6]

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipSetLineSigmaBlend", "hwnd", $hBrush, "float", $fLightSigma, "float", 1)
    DllCall($ghGDIPDll, "uint", "GdipSetLineGammaCorrection", "hwnd", $hBrush, "int", True)
    DllCall($ghGDIPDll, "uint", "GdipRotateLineTransform", "hwnd", $hBrush, "float", $fLightAngle, "int", 0)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsFillRect($hGfx_Alu, 0, 0, $iW, $iH, $hBrush)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGfx_Alu)

    [/autoit] [autoit][/autoit] [autoit]

    Return $hBmp_Alu
    EndFunc ;==>_CreateBrushedAluminum

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hCDC, 0, 0, 0x00CC0020)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_PAINT

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _WinAPI_SelectObject($hCDC, $hOBJ)
    _WinAPI_DeleteObject($hBMP)
    _WinAPI_DeleteDC($hCDC)
    _WinAPI_ReleaseDC($hGui, $hDC)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

    [/autoit]

    E

    Dateien

    Alu.JPG 79,14 kB – 0 Downloads
  • Parameter an laufenden Prozess übergeben

    • eukalyptus
    • 13. April 2012 um 19:08

    Es gibt noch die Möglichkeit per $WM_COPYDATA Message - da hat ProgAndy glaub ich mal ein Beispiel gepostet...

    Dann noch per NamedPipes: Deutsche Hilfe - Funktionen ohne Beispiel

    Und in meiner Signatur findest du die UDF exchange Variables.

    E

  • Midi Udf

    • eukalyptus
    • 12. April 2012 um 15:44

    Viel interessanter als Midi Dateien finde ich die Steuerung von Midifähigen Geräten, bzw. die Steuerung vom AutoItscript durch Midi Controller.
    Darin hab ich etwas Erfahrung und kann auch mal ein Beispiel schreiben, wenn ich Zeit finde...

    2 Sachen musst du unbedingt noch einbauen:
    @error-check bzw. IsArray($ret)-check bei den DllCalls; sonst führt das evtl zu einem Scriptabsturz, wenn du direkt danach $ret[0] verwendest...

    $ret als Local deklarieren - Die UDF muss auch mit Opt("MustDeclareVars", 1) funktionieren.

    Ansonsten schon mal ganz ordendlich! :thumbup:

    E

  • Fokus von Child-GUI an Parent binden

    • eukalyptus
    • 11. April 2012 um 08:11

    Du kannst WM_KillFocus - Msg abfragen und jedesmal den Fokus wieder auf Parent setzen.
    Das funktioniert allerdings nur, wenn keine Controls in Parent vorhanden sind, also keine Labels, Buttons usw...

    E

  • Zwei Fragen: 1.) Kollision Ellipse(Kugel) mit Rechteck, 2.) FPS

    • eukalyptus
    • 11. April 2012 um 08:09

    Am besten misst du die Zeit in der Schleife mit TimerInit und TimerDiff.
    Bei einer Framerate von 40 machst du ein Sleep mit (25 - TimerDiff)

    Das fiese daran ist, dass ein Sleep(1) genausoviel Zeit benötigt wie Sleep(10), also hast du trotzdem eine Schwankungsbreite von 10ms.
    evtl. hilft hier die Funktion HighPrecisionSleep (hier im Forum zu finden), oder du machst es etwas anders:

    Sleep(10), wenn gemessene Zeit <= 15
    Wenn Zeit >= 25ms, dann werden die Berechnungen ausgeführt.
    (Wenn ich mich richtig erinnere, ist dies die Methode, wie ich sie bei SuperMario verwendet hab)


    Zum KollisionsCheck:
    Du könnest die Bricks in Gruppen verwalten. z.B. alle Bricks einer Zeile gehören zusammen.
    Somit kannst du die ganze Gruppe überspringen, wenn die Y-Koordinate des Balles nicht passt. anstatt jedesmal einen kompletten Kollisionscheck durchzuführen...


    E

  • Juhu!

    • eukalyptus
    • 3. April 2012 um 20:56

    Möge die Macht mit ihm sein! :rock:

  • MP3 schneiden

    • eukalyptus
    • 3. April 2012 um 20:41

    Mit MP3 schneiden meinst du wahrscheinlich ein Framegenaues Scheiden ohne die MP3 zu decodieren (also ohne Qualtiätsverlust)
    Das ist in AutoIt eingentlich möglich, aber nicht leicht.
    Im Printip muss du nur die FameHeader finden und bei dort abschneiden.

    Schneiden mit decodieren geht mit der Bass.dll (siehe meine Signatur)

    E

  • Gebogenes Objekt auf gerade Linie abrollen ( Oder "Mathe für Runaways" )

    • eukalyptus
    • 24. März 2012 um 08:12

    Das war wie gesagt nur der erste Test.
    Die Zähne sind nicht wirklich symmetrisch.
    Aber ich glaub ich weiß schon, wie das besser und einfacher geht...
    Das kann ich aber erst nächste Woche probieren.

    Für mich ist das deshalb so interessant, weil ich selber gelernter Schreiner bin und auch etwa 4 Jahre mit einer CNC Fräse gearbeitet hab.
    Das war allerdings vor fast 10 Jahren.
    Damals hatten wir zwar ein verstellbares Sägemodul, aber die Neigung musste manuell verstellt werden - also hierfür nicht geeignet!

    Und JA - bitte schreib eine DXF-UDF! sowas hätte ich schon ein paar mal gebraucht :thumbup:

    E

  • Gebogenes Objekt auf gerade Linie abrollen ( Oder "Mathe für Runaways" )

    • eukalyptus
    • 23. März 2012 um 17:16

    Das ist mal der erste Test:

    Ich biege keine AutoCad-Kurve gerade, sondern berechne die Verzahnung gleich selber!

    Das Script liest eine Kurve aus einer Datei (hier noch InkScape-SVG)
    und berechnet dann die Verzahnungen.
    Dann wird die Verzahnung 2 Mal gradegebogen und zwar einmal auf der Unterseite und einmal auf der Oberseite
    Die fertige Verzahnung wird zu Testzwecken als EMF abgespeichert.

    Ein großer Teil des Codes dient nur zum Visualisieren. Ein "fertiger" Code sollte dann viel kleiner und schöner sein :D
    Deshalb auch das Durcheinander...

    Script:

    Spoiler anzeigen
    [autoit]

    #include <Array.au3>
    ;#include "GDIp.au3"
    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $iOffSetX = -1
    Global $iOffSetY = -1

    [/autoit] [autoit][/autoit] [autoit]

    Opt("MustDeclareVars", 1)
    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $PI = ATan(1) * 4
    Global Const $2PI = $PI * 2
    Global Const $PI2 = $PI / 2
    Global Const $Deg2Rad = $PI / 180
    Global Const $Rad2Deg = 180 / $PI
    Global $_ME_hMSVCRT = DllOpen('msvcrt.dll')

    [/autoit] [autoit][/autoit] [autoit]

    Global $tPath = _Load(@ScriptDir & "\Bogen2.svg")

    [/autoit] [autoit][/autoit] [autoit]

    Global $iWidth = 1200
    Global $iHeight = 600

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $hGui = GUICreate("Test", $iWidth, $iHeight)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
    Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFF000000)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hPen = _GDIPlus_PenCreate(0xFF00FF00, 1)
    Global $hPen2 = _GDIPlus_PenCreate(0xFFFF0000, 1)
    Global $hPen3 = _GDIPlus_PenCreate(0xFF0000FF, 1)

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_PAINT, "WM_PAINT")
    GUIRegisterMsg($WM_ERASEBKGND, "WM_PAINT")
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    _Draw()
    Global $tGears = _CalcGears($tPath, 10, 40, 18)
    ;#cs
    Global $tFlat_Up = _Flatten($tGears, 1)
    Global $tFlat_Lo = _Flatten($tGears, 0)
    _Show($tPath, $tFlat_Up, 0.8, 10, 100)
    _Show($tPath, $tFlat_Lo, 0.8, 10, 200)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    ;MsgBox(0, "", "")

    [/autoit] [autoit][/autoit] [autoit]

    _Save($tFlat_Lo, @ScriptDir & "\Unten.emf")
    _Save($tFlat_Up, @ScriptDir & "\Oben.emf")
    ;#ce

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(10)
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Save($tFlat, $sFileName)
    Local $iCnt = DllStructGetData($tFlat, "Cnt")
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
    Local $hPath = $aResult[2]

    [/autoit] [autoit][/autoit] [autoit]

    ;DllCall($ghGDIPDll, "uint", "GdipAddPathPolygon", "hwnd", $hPath, "ptr", DllStructGetPtr($tFlat, "Pnt"), "int", $iCnt)
    DllCall($ghGDIPDll, "uint", "GdipAddPathCurve3", "hwnd", $hPath, "ptr", DllStructGetPtr($tFlat, "Pnt"), "int", $iCnt, "int", 0, "int", $iCnt-1, "float", 0)
    ;DllCall($ghGDIPDll, "uint", "GdipClosePathFigure", "hwnd", $hPath)

    [/autoit] [autoit][/autoit] [autoit]

    Local $tRectF = DllStructCreate("float X; float Y; float Width; float Height;")
    DllCall($ghGDIPDll, "uint", "GdipGetPathWorldBounds", "hwnd", $hPath, "ptr", DllStructGetPtr($tRectF), "hwnd", 0, "hwnd", 0)
    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, -DllStructGetData($tRectF, "X"), -DllStructGetData($tRectF, "Y"))
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPath, "hwnd", $hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)
    DllStructSetData($tRectF, "X", 0)
    DllStructSetData($tRectF, "Y", 0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hPen = _GDIPlus_PenCreate(0xFF000000)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hDC = _WinAPI_GetDC($hGui)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipRecordMetafileFileName", "wstr", $sFileName, "hwnd", $hDC, "int", 5, "ptr", DllStructGetPtr($tRectF), "int", 6, "wstr", "Platte Unten", "int*", 0)
    Local $hImage = $aResult[7]
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hImage) ;GraphicContext vom Metafile bekommen (um darauf zu zeichnen)
    DllCall($ghGDIPDll, "uint", "GdipSetPageUnit", "hwnd", $hContext, "int", 6) ; Einheit auf mm setzen

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hContext, "hwnd", $hPen, "hwnd", $hPath)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDispose($hContext) ; Metafile abschliesen und speichern
    _GDIPlus_ImageDispose($hImage) ; Metafile aus Speicher löschen

    [/autoit] [autoit][/autoit] [autoit]

    _WinAPI_ReleaseDC($hGui, $hDC)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath)
    _GDIPlus_PenDispose($hPen)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _CalcGears($tPath, $fW = 10, $fH = 20, $fR = 8)
    Local $fGA = $fR * $Deg2Rad
    Local $fGA_Plus
    Local $fGR = $fH / Tan($PI2 - $fGA) ; X-Offset der Schräge
    Local $fGH = $fH / Cos($fGA) ; Länge der Höhe
    Local $fGW = $fW + $fGR

    [/autoit] [autoit][/autoit] [autoit]

    Local $iCnt = DllStructGetData($tPath, "Cnt")
    Local $tGears = DllStructCreate("int Cnt; float Pnt[" & $iCnt * 2 & "];")
    _GearAddPoint($tGears, 0, 0)

    [/autoit] [autoit][/autoit] [autoit]

    Local $iStep = 0, $fX1, $fY1, $fX2 = 0, $fY2 = 0, $fD, $fA, $iIdx

    [/autoit] [autoit][/autoit] [autoit]

    Local $aLast, $iDir = 0
    Local $fATmp = _MathEx_Atan2(DllStructGetData($tPath, "Pnt", 4), DllStructGetData($tPath, "Pnt", 3))
    While $iStep < $iCnt
    $iStep += 1
    $fX1 = DllStructGetData($tPath, "Pnt", ($iStep - 1) * 2 + 1)
    $fY1 = DllStructGetData($tPath, "Pnt", ($iStep - 1) * 2 + 2)
    $fD = Sqrt(($fX1 - $fX2) ^ 2 + ($fY1 - $fY2) ^ 2)
    If $fD >= $fGW * 2 Then ; Suche nächten Winkelpunkt
    ;ConsoleWrite("! " & $fD & @CRLF)
    ;_GDIPlus_GraphicsDrawLine($hGfxBuffer, $fX1+$iOffSetX, $fY1+$iOffSetY, $fX2+$iOffSetX, $fY2+$iOffSetY, $hPen2)
    ;_GDIPlus_GraphicsDrawLine($hGfxBuffer, $fX1+$iOffSetX, $fY1+$iOffSetY, $fX1+Cos($fA)*$fD*10+$iOffSetX, $fY1+Sin($fA)*$fD*10+$iOffSetY, $hPen2)
    Do
    $fA = _MathEx_Atan2($fY1 - $fY2, $fX1 - $fX2)

    [/autoit] [autoit][/autoit] [autoit]

    Select
    Case ($fA - $fATmp) < 0
    If $iDir = 1 Then
    $iIdx = DllStructGetData($tGears, "Cnt")
    DllStructSetData($tGears, "Cnt", $iIdx - 1)
    $fGA_Plus = ($fATmp - $fA) / 2
    ConsoleWrite("! Plus: " & $fGA_Plus * $Rad2Deg & " A: " & $fA * $Rad2Deg & " ATmp: " & $fATmp * $Rad2Deg & @CRLF)
    _GearAddPoint($tGears, $fGH, $fA + $PI2 - $fGA + $fGA_Plus)
    _ShowDrawLastPnt($tGears)
    $iDir = 2
    EndIf
    _GearAddPoint($tGears, $fW, $fA)
    ;_ShowDrawLastPnt($tGears)
    _GearAddPoint($tGears, $fGH, $fA - $PI2 + $fGA)
    ;_ShowDrawLastPnt($tGears)
    $fGA_Plus = ($fATmp - $fA) / 3
    ConsoleWrite("> Plus: " & $fGA_Plus * $Rad2Deg & " A: " & $fA * $Rad2Deg & " ATmp: " & $fATmp * $Rad2Deg & @CRLF)
    _GearAddPoint($tGears, $fW, $fA - $fGA_Plus * 1)
    ;_ShowDrawLastPnt($tGears)
    _GearAddPoint($tGears, $fGH, $fA + $PI2 - $fGA - $fGA_Plus * 2)
    ;_ShowDrawLastPnt($tGears)
    ;MsgBox(0,"","")
    ;ContinueCase
    Case Else
    $fGA_Plus = ($fATmp - $fA) / 2
    ConsoleWrite("+ Plus: " & $fGA_Plus * $Rad2Deg & " A: " & $fA * $Rad2Deg & " ATmp: " & $fATmp * $Rad2Deg & @CRLF)
    _GearAddPoint($tGears, $fW, $fA + $fGA_Plus)
    _GearAddPoint($tGears, $fGH, $fA - $PI2 + $fGA)
    _GearAddPoint($tGears, $fW, $fA)
    _GearAddPoint($tGears, $fGH, $fA + $PI2 - $fGA)
    $iDir = 1
    EndSelect
    $fATmp = $fA

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $iIdx = DllStructGetData($tGears, "Cnt")
    $fX2 = DllStructGetData($tGears, "Pnt", ($iIdx - 1) * 2 + 1)
    $fY2 = DllStructGetData($tGears, "Pnt", ($iIdx - 1) * 2 + 2)

    [/autoit] [autoit][/autoit] [autoit]

    Until Sqrt(($fX1 - $fX2) ^ 2 + ($fY1 - $fY2) ^ 2) < $fGW
    ;ExitLoop
    EndIf
    WEnd
    ;_GDIPlus_GraphicsClear($hGfxBuffer, 0xFFFFFFFF)
    _Show($tPath, $tGears)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    MsgBox(0, "", "")
    ;_Exit()
    Return $tGears
    EndFunc ;==>_CalcGears

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _ShowDrawLastPnt($tGears)
    Local $iCnt = DllStructGetData($tGears, "Cnt")
    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen2, "float", _
    DllStructGetData($tGears, "Pnt", ($iCnt - 2) * 2 + 1) + $iOffSetX, "float", DllStructGetData($tGears, "Pnt", ($iCnt - 2) * 2 + 2) + $iOffSetY, "float", _
    DllStructGetData($tGears, "Pnt", ($iCnt - 1) * 2 + 1) + $iOffSetX, "float", DllStructGetData($tGears, "Pnt", ($iCnt - 1) * 2 + 2) + $iOffSetY)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    EndFunc ;==>_ShowDrawLastPnt

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _GearAddPoint($tGears, $fD, $fA)
    Local $iCnt = DllStructGetData($tGears, "Cnt")
    Local $fX = DllStructGetData($tGears, "Pnt", ($iCnt - 1) * 2 + 1)
    Local $fY = DllStructGetData($tGears, "Pnt", ($iCnt - 1) * 2 + 2)
    Local $aReturn[2]
    $aReturn[0] = $fX + Cos($fA) * $fD
    $aReturn[1] = $fY + Sin($fA) * $fD
    DllStructSetData($tGears, "Pnt", $aReturn[0], $iCnt * 2 + 1)
    DllStructSetData($tGears, "Pnt", $aReturn[1], $iCnt * 2 + 2)
    DllStructSetData($tGears, "Cnt", $iCnt + 1)
    Return $aReturn
    EndFunc ;==>_GearAddPoint

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Draw()
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFFFFFFFF)

    [/autoit] [autoit][/autoit] [autoit]

    _Show($tPath, 0)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    EndFunc ;==>_Draw

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Show($tPath, $tGears, $fScale = 1, $iOffX = 100, $iOffY = 100)
    Local $iPathCnt = DllStructGetData($tPath, "Cnt")
    Local $iGearCnt = DllStructGetData($tGears, "Cnt")
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
    Local $hPathPath = $aResult[2]
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
    Local $hPathGear = $aResult[2]

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipAddPathCurve", "hwnd", $hPathPath, "ptr", DllStructGetPtr($tPath, "Pnt"), "int", $iPathCnt)
    ;DllCall($ghGDIPDll, "uint", "GdipAddPathCurve3", "hwnd", $hPathGear, "ptr", DllStructGetPtr($tGears, "Pnt"), "int", $iGearCnt, "int", 0, "int", $iGearCnt-1, "float", 0)
    DllCall($ghGDIPDll, "uint", "GdipAddPathPolygon", "hwnd", $hPathGear, "ptr", DllStructGetPtr($tGears, "Pnt"), "int", $iGearCnt)

    [/autoit] [autoit][/autoit] [autoit]

    Local $tRectF = DllStructCreate("float X; float Y; float Width; float Height;")
    DllCall($ghGDIPDll, "uint", "GdipGetPathWorldBounds", "hwnd", $hPathPath, "ptr", DllStructGetPtr($tRectF), "hwnd", 0, "hwnd", 0)
    Local $hMatrix = _GDIPlus_MatrixCreate()

    [/autoit] [autoit][/autoit] [autoit]

    If $iOffSetX = -1 Then
    $iOffSetX = -DllStructGetData($tRectF, "X") + $iOffX
    $iOffSetY = -DllStructGetData($tRectF, "Y") + $iOffY
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_MatrixTranslate($hMatrix, -DllStructGetData($tRectF, "X"), -DllStructGetData($tRectF, "Y"))
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPathPath, "hwnd", $hMatrix)
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPathGear, "hwnd", $hMatrix)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipSetMatrixElements", "hwnd", $hMatrix, "float", 1, "float", 0, "float", 0, "float", 1, "float", 0, "float", 0)
    _GDIPlus_MatrixScale($hMatrix, $fScale, $fScale)
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPathPath, "hwnd", $hMatrix)
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPathGear, "hwnd", $hMatrix)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipSetMatrixElements", "hwnd", $hMatrix, "float", 1, "float", 0, "float", 0, "float", 1, "float", 0, "float", 0)
    _GDIPlus_MatrixTranslate($hMatrix, $iOffX, $iOffY)
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPathPath, "hwnd", $hMatrix)
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPathGear, "hwnd", $hMatrix)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfxBuffer, "hwnd", $hPen, "hwnd", $hPathPath)
    DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfxBuffer, "hwnd", $hPen3, "hwnd", $hPathGear)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_MatrixDispose($hMatrix)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;#cs
    ; Bemassung
    $aResult = DllCall($ghGDIPDll, "uint", "GdipGetPointCount", "hwnd", $hPathGear, "int*", 0)
    Local $iCnt = $aResult[2]
    Local $tPoints = DllStructCreate("float[" & $iCnt * 2 & "]")
    DllCall($ghGDIPDll, "uint", "GdipGetPathPoints", "hwnd", $hPathGear, "ptr", DllStructGetPtr($tPoints), "int", $iCnt)

    [/autoit] [autoit][/autoit] [autoit]

    Local $fX1 = 0, $fY1 = 0, $fX2, $fY2, $fD, $fA1, $fA2, $fADiff, $fATmp
    For $i = 1 To $iCnt
    $fX2 = DllStructGetData($tPoints, 1, ($i - 1) * 2 + 1)
    $fY2 = DllStructGetData($tPoints, 1, ($i - 1) * 2 + 2)
    $fD = Sqrt(Abs(($fX2 - $fX1) ^ 2 + ($fY2 - $fY1) ^ 2))
    $fA2 = 180 + _MathEx_Atan2($fY2 - $fY1, $fX2 - $fX1) * $Rad2Deg
    ;If $fA2 > 180 Then $fA2 = 180 + _MathEx_Atan2($fY1 - $fY2, $fX1 - $fX2) * $Rad2Deg
    $fADiff = Mod(180 + $fA1 - $fA2, 360)
    $fATmp = 1
    If $fADiff > 180 Then
    $fADiff = 360 - $fADiff
    $fATmp = 0
    EndIf
    If $fADiff < 0 Then $fADiff += 360

    [/autoit] [autoit][/autoit] [autoit]

    If $i > 1 Then
    If $fATmp = 1 Then
    ;_GDIPlus_GraphicsDrawPie($hGfxBuffer, $fX1 - 10, $fY1 - 10, 20, 20, $fA2 + 180, $fADiff, $hPen)
    ConsoleWrite("! " & $fX1 - 10 & " " & $fY1 - 10 & @CRLF)
    Else
    ;_GDIPlus_GraphicsDrawPie($hGfxBuffer, $fX1 - 10, $fY1 - 10, 20, 20, $fA1, $fADiff, $hPen)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;_GDIPlus_GraphicsDrawString_C($hGfxBuffer, Round($fA2, 2), $fX1 + (($fX2 - $fX1) / 2), $fY1 + (($fY2 - $fY1) / 2), "Arial", 6.5, 0, 0xFFFF0000)
    ;_GDIPlus_GraphicsDrawString_C($hGfxBuffer, Round($fADiff, 2), $fX1, $fY1, "Arial", 6.5, 0, 0xFF0000FF)
    ;_GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    ;MsgBox(0,"","")
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $fX1 = $fX2
    $fY1 = $fY2
    $fA1 = $fA2
    Next
    ; Bemassung
    ;#ce

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPathPath)
    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPathGear)
    EndFunc ;==>_Show

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func __Flatten($tFlat, $iI1, $iI2)
    Local $iCnt = DllStructGetData($tFlat, "Cnt")
    Local $fX1, $fY1, $fX2, $fY2, $fA

    [/autoit] [autoit][/autoit] [autoit]

    $fX1 = DllStructGetData($tFlat, "Pnt", $iI1 * 2 + 1)
    $fY1 = DllStructGetData($tFlat, "Pnt", $iI1 * 2 + 2)
    $fX2 = DllStructGetData($tFlat, "Pnt", $iI2 * 2 + 1)
    $fY2 = DllStructGetData($tFlat, "Pnt", $iI2 * 2 + 2)
    $fA = _MathEx_Atan2($fY2 - $fY1, $fX2 - $fX1)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, -$fX1, -$fY1)
    DllCall($ghGDIPDll, "uint", "GdipTransformMatrixPoints", "hwnd", $hMatrix, "ptr", DllStructGetPtr($tFlat, "Pnt"), "int", $iCnt)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipSetMatrixElements", "hwnd", $hMatrix, "float", 1, "float", 0, "float", 0, "float", 1, "float", 0, "float", 0)
    _GDIPlus_MatrixRotate($hMatrix, -$fA * $Rad2Deg)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipTransformMatrixPoints", "hwnd", $hMatrix, "ptr", DllStructGetPtr($tFlat, "Pnt") + $iI1 * 8, "int", $iCnt - $iI1)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_MatrixDispose($hMatrix)
    EndFunc ;==>__Flatten

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Flatten($tGears, $iFlag = 1)
    Local $iCnt = DllStructGetData($tGears, "Cnt")
    Local $tFlat = DllStructCreate("int Cnt; float Pnt[" & $iCnt * 2 & "];")

    [/autoit] [autoit][/autoit] [autoit]

    If $iFlag Then
    $iCnt -=3
    DllCall("kernel32.dll", "none", "RtlMoveMemory", "ptr", DllStructGetPtr($tFlat, "Pnt"), "ptr", DllStructGetPtr($tGears, "Pnt") + 2 * 8, "ulong_ptr", $iCnt * 8)
    Else
    DllCall("kernel32.dll", "none", "RtlMoveMemory", "ptr", DllStructGetPtr($tFlat, "Pnt"), "ptr", DllStructGetPtr($tGears, "Pnt"), "ulong_ptr", $iCnt * 8)
    EndIf
    DllStructSetData($tFlat, "Cnt", $iCnt)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
    Local $hPath = $aResult[2]
    Local $tRectF = DllStructCreate("float X; float Y; float Width; float Height;")

    [/autoit] [autoit][/autoit] [autoit]

    Local $hMatrix = _GDIPlus_MatrixCreate()

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 0 To $iCnt - 3 Step 4

    [/autoit] [autoit][/autoit] [autoit]

    __Flatten($tFlat, $i, $i + 1)
    If $i < $iCnt - 3 Then __Flatten($tFlat, $i + 1, $i + 4)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipResetPath", "hwnd", $hPath)
    DllCall($ghGDIPDll, "uint", "GdipAddPathPolygon", "hwnd", $hPath, "ptr", DllStructGetPtr($tFlat, "Pnt"), "int", $iCnt)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipGetPathWorldBounds", "hwnd", $hPath, "ptr", DllStructGetPtr($tRectF), "hwnd", 0, "hwnd", 0)
    ConsoleWrite("- " & DllStructGetData($tRectF, "X") & " " & DllStructGetData($tRectF, "Y") & " " & DllStructGetData($tRectF, "Width") & " " & DllStructGetData($tRectF, "Height") & @CRLF)
    DllCall($ghGDIPDll, "uint", "GdipSetMatrixElements", "hwnd", $hMatrix, "float", 1, "float", 0, "float", 0, "float", 1, "float", 0, "float", 0)
    _GDIPlus_MatrixTranslate($hMatrix, -DllStructGetData($tRectF, "X"), -DllStructGetData($tRectF, "Y"))
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPath, "hwnd", $hMatrix)
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFFFFFFFF)
    DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfxBuffer, "hwnd", $hPen3, "hwnd", $hPath)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    ;MsgBox(0,"","")
    Next
    DllCall($ghGDIPDll, "uint", "GdipSetMatrixElements", "hwnd", $hMatrix, "float", 1, "float", 0, "float", 0, "float", 1, "float", 0, "float", 0)
    _GDIPlus_MatrixTranslate($hMatrix, -DllStructGetData($tRectF, "X"), -DllStructGetData($tRectF, "Y"))
    DllCall($ghGDIPDll, "uint", "GdipTransformMatrixPoints", "hwnd", $hMatrix, "ptr", DllStructGetPtr($tFlat, "Pnt"), "int", $iCnt)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath)
    _GDIPlus_MatrixDispose($hMatrix)

    [/autoit] [autoit][/autoit] [autoit]

    Return $tFlat
    EndFunc ;==>_Flatten

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Load($sPath, $fScale = 1)
    Local $sFile = FileRead($sPath)
    Local $aRegExp = StringRegExp($sFile, "(?s)\<path(.*)\/\>", 3)
    $aRegExp = StringRegExp($aRegExp[0], 'd="([^"]+)', 3)
    Local $aSplit = StringSplit($aRegExp[0], " ")
    Local $tPath = DllStructCreate("int Cnt; float Pnt[" & $aSplit[0] * 2 & "];")
    Local $iCnt = 0, $fX = 0, $fY = 0
    For $i = 1 To $aSplit[0]
    $aRegExp = StringRegExp($aSplit[$i], "[\d.-]+", 3)
    If UBound($aRegExp) <> 2 Then ContinueLoop
    $iCnt += 1
    If $iCnt = 1 Then
    $aRegExp[0] = 0
    $aRegExp[1] = 0
    EndIf
    DllStructSetData($tPath, "Pnt", $fX + $aRegExp[0], ($iCnt - 1) * 2 + 1)
    DllStructSetData($tPath, "Pnt", $fY + $aRegExp[1], ($iCnt - 1) * 2 + 2)
    $fX += $aRegExp[0]
    $fY += $aRegExp[1]
    Next

    [/autoit] [autoit][/autoit] [autoit]

    If $fScale <> 1 Then
    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixScale($hMatrix, $fScale, $fScale)
    DllCall($ghGDIPDll, "uint", "GdipTransformMatrixPoints", "hwnd", $hMatrix, "ptr", DllStructGetPtr($tPath, "Pnt"), "int", $iCnt)
    _GDIPlus_MatrixDispose($hMatrix)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    DllStructSetData($tPath, "Cnt", $iCnt)
    Return $tPath
    EndFunc ;==>_Load

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_PAINT

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_PenDispose($hPen3)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _GDIPlus_BitmapDispose($hBmpBuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

    [/autoit] [autoit][/autoit] [autoit]

    Func _MathEx_Atan2($fY, $fX)
    Local $aResult = DllCall($_ME_hMSVCRT, "double:cdecl", "atan2", "double", $fY, "double", $fX)
    If @error Then Return SetError(1, 1, False)
    Return $aResult[0]
    EndFunc ;==>_MathEx_Atan2

    [/autoit] [autoit][/autoit] [autoit]

    Func _GDIPlus_GraphicsDrawString_C($hGraphics, $sString, $nX, $nY, $sFont = "Arial", $nSize = 10, $iFormat = 0, $iColor = 0xFF000000)
    Local $hBrush = _GDIPlus_BrushCreateSolid($iColor)
    Local $hFormat = _GDIPlus_StringFormatCreate($iFormat)
    Local $hFamily = _GDIPlus_FontFamilyCreate($sFont)
    Local $hFont = _GDIPlus_FontCreate($hFamily, $nSize)
    Local $tLayout = _GDIPlus_RectFCreate($nX, $nY, 0, 0)
    Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat)
    Local $aResult = _GDIPlus_GraphicsDrawStringEx($hGraphics, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)
    Local $iError = @error
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    Return SetError($iError, 0, $aResult)
    EndFunc ;==>_GDIPlus_GraphicsDrawString_C

    [/autoit]

    Bogen2.svg:

    Spoiler anzeigen
    XML
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!-- Created with Inkscape (http://www.inkscape.org/) -->
    
    
    <svg
       xmlns:dc="http://purl.org/dc/elements/1.1/"
       xmlns:cc="http://creativecommons.org/ns#"
       xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
       xmlns:svg="http://www.w3.org/2000/svg"
       xmlns="http://www.w3.org/2000/svg"
       xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
       xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
       width="210mm"
       height="297mm"
       id="svg3078"
       version="1.1"
       inkscape:version="0.48.1 "
       sodipodi:docname="Bogen2.svg">
      <defs
         id="defs3080" />
      <sodipodi:namedview
         id="base"
         pagecolor="#ffffff"
         bordercolor="#666666"
         borderopacity="1.0"
         inkscape:pageopacity="0.0"
         inkscape:pageshadow="2"
         inkscape:zoom="0.35"
         inkscape:cx="350"
         inkscape:cy="520"
         inkscape:document-units="px"
         inkscape:current-layer="layer1"
         showgrid="false"
         inkscape:window-width="1366"
         inkscape:window-height="719"
         inkscape:window-x="-4"
         inkscape:window-y="-4"
         inkscape:window-maximized="1" />
      <metadata
         id="metadata3083">
        <rdf:RDF>
          <cc:Work
             rdf:about="">
            <dc:format>image/svg+xml</dc:format>
            <dc:type
               rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
            <dc:title />
          </cc:Work>
        </rdf:RDF>
      </metadata>
      <g
         inkscape:label="Ebene 1"
         inkscape:groupmode="layer"
         id="layer1">
        <path
           style="fill:none;stroke:#000000;stroke-width:0.38037771;stroke-linejoin:bevel"
           d="m 12.623162,1036.7734 0.988621,-4.7591 0.496297,-2.3766 0.50441,-2.3889 0.504491,-2.3949 0.512604,-2.395 0.512603,-2.401 0.52477,-2.4011 0.528827,-2.4011 0.53702,-2.4071 0.545133,-2.4013 0.553327,-2.4132 0.565411,-2.4071 0.573689,-2.4011 0.585773,-2.4011 0.593968,-2.39494 0.602079,-2.38876 0.610274,-2.38274 0.622358,-2.37658 0.630635,-2.37657 0.638664,-2.3644 0.646859,-2.36424 0.659026,-2.35823 0.66722,-2.35206 0.675332,-2.3459 0.687499,-2.33987 0.691555,-2.3337 0.703805,-2.32142 0.711917,-2.32146 0.724167,-2.32145 0.728223,-2.30305 0.74039,-2.3092 0.744529,-2.29694 0.756613,-2.28471 0.768946,-2.28469 0.772919,-2.27855 0.781115,-2.27246 0.79328,-2.26019 0.801476,-2.2602 0.809505,-2.25408 0.817698,-2.2467 0.825893,-2.23936 0.83806,-2.23264 0.846172,-2.22587 0.858341,-2.21915 0.866532,-2.21243 0.874646,-2.20446 0.886896,-2.19709 0.895007,-2.18916 0.907174,-2.18056 0.915369,-2.17199 0.927536,-2.1628 0.939787,-2.15423 0.947899,-2.14443 0.960065,-2.134 0.972316,-2.12421 0.980426,-2.11442 0.992596,-2.10339 1.004844,-2.09174 1.017095,-2.08135 1.029262,-2.06909 1.04143,-2.05744 1.049625,-2.04581 1.065847,-2.03232 1.078015,-2.02008 1.086209,-2.00723 1.102514,-1.99315 1.114683,-1.97844 1.122794,-1.96251 1.135044,-1.94779 1.147212,-1.9325 1.159461,-1.91657 1.167574,-1.90187 1.179741,-1.88592 1.191991,-1.87126 1.200102,-1.85532 1.212353,-1.83941 1.224521,-1.82406 1.232631,-1.80816 1.244882,-1.79283 1.252993,-1.77633 1.261188,-1.75976 1.273356,-1.74444 1.285522,-1.72791 1.289575,-1.7114 1.305885,-1.69543 1.310023,-1.6789 1.322107,-1.66237 1.326246,-1.64524 1.342469,-1.6293 1.346608,-1.61214 1.35472,-1.59561 1.366887,-1.57846 1.375081,-1.56192 1.383193,-1.54539 1.391302,-1.52825 1.40347,-1.51107 1.40761,-1.49332 1.41978,-1.47555 1.42798,-1.45717 1.43608,-1.4388 1.44419,-1.42044 1.45231,-1.40145 1.46455,-1.38184 1.46863,-1.36226 1.48086,-1.34201 1.48897,-1.32243 1.49303,-1.30159 1.5052,-1.28079 1.51339,-1.25932 1.51745,-1.23852 1.52961,-1.21708 1.53368,-1.19441 1.54592,-1.17236 1.54997,-1.14969 1.56223,-1.12643 1.5662,-1.10376 1.5744,-1.08049 1.58664,-1.05659 1.59062,-1.0327 1.59476,-1.00696 1.60286,-0.9825 1.60693,-0.95735 1.61098,-0.9335 1.61917,-0.90958 1.62315,-0.88631 1.62729,-0.86242 1.63134,-0.84037 1.63548,-0.81708 1.63539,-0.79508 1.64351,-0.77359 1.64765,-0.75156 1.64756,-0.73075 1.65577,-0.70929 1.65576,-0.68969 1.65575,-0.6689 1.66387,-0.64925 1.6599,-0.62967 1.66793,-0.61066 1.66792,-0.59172 1.66801,-0.57271 1.67198,-0.55554 1.67207,-0.53657 1.67198,-0.52003 1.67612,-0.50226 1.67612,-0.48512 1.67604,-0.46918 1.68018,-0.45264 1.68018,-0.43552 1.68017,-0.42018 1.68424,-0.40304 1.68423,-0.38773 1.68423,-0.37117 1.68423,-0.35526 1.68829,-0.33997 1.68829,-0.32341 1.68828,-0.3087 1.69235,-0.29277 1.68829,-0.27747 1.69243,-0.26202 1.69234,-0.24692 1.69234,-0.23153 1.69235,-0.2167 1.69648,-0.20215 1.69235,-0.18732 1.69648,-0.1722 1.69235,-0.15796 1.69639,-0.14335 1.69358,-0.12939 1.69483,-0.1151 1.69524,-0.1005 1.69475,-0.087 1.69442,-0.0727 1.69482,-0.0612 1.69441,-0.0429 1.69401,-0.0305 1.69317,-0.0192 1.69276,-0.005 1.69201,0.005 1.69069,0.0192 1.68994,0.0368 1.6887,0.0429 1.68746,0.0612 1.68671,0.0692 1.6854,0.0807 1.68423,0.0917 1.68341,0.10292 1.68224,0.11267 1.68101,0.12306 1.67975,0.13296 1.67895,0.14287 1.67769,0.15179 1.67645,0.1604 1.67529,0.16973 1.67406,0.17772 1.67288,0.18621 1.67158,0.19363 1.6704,0.20158 1.66925,0.20821 1.66793,0.21504 1.6671,0.22248 1.66635,0.2285 1.66471,0.23456 1.66304,0.24061 1.66271,0.24636 1.66263,0.2524 1.66188,0.25845 1.66188,0.2645 1.66106,0.27081 1.66056,0.27624 1.66023,0.28237 1.65948,0.2879 1.6594,0.29401 1.65816,0.30011 1.65824,0.30567 1.65734,0.31177 1.657,0.31727 1.65617,0.32341 1.65576,0.32892 1.65493,0.33505 1.65493,0.34057 1.6537,0.34667 1.65335,0.35158 1.65287,0.35834 1.65211,0.36324 1.65171,0.36933 1.65087,0.37487 1.65046,0.38036 1.64964,0.3865 1.64922,0.39202 1.64847,0.39753 1.64757,0.40302 1.64723,0.40856 1.64641,0.41467 1.64558,0.41959 1.64434,0.42447 1.64392,0.43059 1.64276,0.43491 1.64235,0.44101 1.64111,0.4453 1.64069,0.45018 1.63945,0.45574 1.63871,0.45999 1.63821,0.46491 1.63706,0.46979 1.63663,0.4747 1.63582,0.47837 1.63507,0.48328 1.63415,0.48756 1.63341,0.49246 1.6325,0.49614 1.63176,0.50042 1.63134,0.50413 1.6301,0.50898 1.62977,0.51206 1.62886,0.51635 1.62811,0.52065 1.62729,0.52371 1.62687,0.52739 1.62563,0.53104 1.62521,0.53471 1.62448,0.53842 1.62364,0.54147 1.62314,0.54454 1.622,0.54818 1.62124,0.55066 1.62116,0.55433 1.62033,0.55738 1.61992,0.56046 1.61959,0.56414 1.61876,0.56658 1.61868,0.57024 1.61793,0.57334 1.61793,0.57696 1.61711,0.57948 1.61627,0.58311 1.61628,0.58616 1.61553,0.58985 1.61504,0.59232 1.61421,0.59597 1.61387,0.59906 1.61347,0.60209 1.61305,0.60517 1.61221,0.60886 1.61181,0.6119 1.61098,0.61558 1.61099,0.61804 1.61023,0.6217 1.60932,0.62475 1.609,0.62846 1.60857,0.63149 1.60817,0.63459 1.60733,0.63825 1.60694,0.64128 1.60608,0.64436 1.60578,0.64805 1.60526,0.65112 1.60453,0.65417 1.60369,0.65786 1.60328,0.66026 1.60205,0.66398 1.60162,0.66643 1.60081,0.67009 1.60005,0.67255 1.59963,0.67559 1.59882,0.67807 1.59799,0.68112 1.59756,0.68358 1.59675,0.68664 1.59591,0.68908 1.59558,0.69151 1.59468,0.69401 1.59434,0.69705 1.59352,0.69888 1.60129,0.705 1.59228,0.70379 1.59144,0.7056 1.59111,0.70808 1.59022,0.71051 1.58987,0.71237 1.58945,0.71419 1.58864,0.71604 1.58779,0.71848 1.58781,0.72034 1.58697,0.72153 1.58615,0.724 1.58623,0.72583 1.58541,0.72706 1.58491,0.7289 1.58458,0.73012 1.58374,0.73195 1.58375,0.73382 1.58292,0.7344 1.58259,0.73624 1.58168,0.73747 1.58168,0.7387 1.58093,0.73992 1.58085,0.74116 1.5801,0.74236 1.58012,0.74299 1.57927,0.74421 1.57928,0.7448 1.57844,0.74608 1.57846,0.74664 1.57804,0.74728 1.57762,0.74789 1.57729,0.74908 1.57721,0.74913 1.57688,0.74973 1.57638,0.75032 1.57606,0.75097 1.57596,0.75092 1.57563,0.75157 1.57564,0.75156 1.57514,0.75156 1.57523,0.75216 1.5748,0.75218 1.5744,0.75157 1.57919,0.76015 1.57928,0.76013 1.5744,0.75156 1.57472,0.75218 1.57523,0.75217 1.57521,0.75156 1.57565,0.75156 1.57555,0.75156 1.57604,0.75095 1.57605,0.75094 1.57639,0.75033 1.5768,0.74973 1.57729,0.74913 1.5772,0.74908 1.57763,0.74789 1.57804,0.74728 1.57853,0.74664 1.57844,0.74606 1.57928,0.74482 1.5792,0.74419 1.5801,0.74301 1.58012,0.74236 1.58084,0.74115 1.58094,0.73993 1.58168,0.7387 1.58176,0.73747 1.58251,0.73624 1.58292,0.7344 1.58374,0.73382 1.58375,0.73195 1.58458,0.73012 1.58499,0.7289 1.58531,0.72706 1.58624,0.72583 1.58614,0.724 1.58707,0.72154 1.5878,0.72033 1.5878,0.71848 1.58863,0.71604 1.58947,0.71419 1.58978,0.71237 1.59029,0.7105 1.59104,0.70809 1.59152,0.7056 1.59228,0.70377 1.60121,0.70502 1.59352,0.6989 1.59434,0.69703 1.59476,0.69399 1.5955,0.69153 1.59599,0.68907 1.59674,0.68664 1.59757,0.68359 1.59799,0.68111 1.59882,0.67806 1.59963,0.67561 1.59997,0.67254 1.6008,0.6701 1.60163,0.66643 1.60212,0.66398 1.60328,0.66026 1.60362,0.65785 1.60452,0.65417 1.60527,0.65112 1.60576,0.64805 1.6061,0.64437 1.60692,0.64128 1.60734,0.63825 1.60817,0.63459 1.60858,0.63147 1.609,0.62848 1.6094,0.62475 1.61015,0.6217 1.61098,0.61804 1.61098,0.61558 1.6119,0.61189 1.61221,0.60886 1.61305,0.60518 1.61339,0.60209 1.61387,0.59906 1.61421,0.59597 1.61511,0.59231 1.61546,0.58985 1.61627,0.58617 1.61636,0.58311 1.61711,0.57948 1.61784,0.57696 1.61794,0.57334 1.61876,0.57023 1.61876,0.56659 1.6195,0.56414 1.61992,0.56046 1.62042,0.55738 1.62116,0.55433 1.62116,0.55066 1.62199,0.54818 1.62323,0.54454 1.62356,0.54147 1.62447,0.5384 1.62522,0.53473 1.62563,0.53105 1.62687,0.52738 1.62729,0.52371 1.62811,0.52064 1.62894,0.51634 1.62969,0.51207 1.6301,0.50899 1.63134,0.50413 1.63176,0.50041 1.63258,0.49615 1.63341,0.49246 1.63415,0.48755 1.63498,0.48329 1.63581,0.47837 1.63664,0.47471 1.63705,0.4698 1.63831,0.46491 1.63862,0.45999 1.63953,0.45572 1.64062,0.45018 1.64111,0.4453 1.64234,0.44103 1.64277,0.4349 1.64392,0.43058 1.64438,0.42448 1.64559,0.41958 1.64642,0.41468 1.6472,0.40854 1.64761,0.40303 1.64841,0.39753 1.64926,0.39202 1.64966,0.38649 1.65047,0.38038 1.65086,0.37487 1.65169,0.36934 1.6521,0.36323 1.6529,0.35834 1.65329,0.35158 1.65372,0.34667 1.65495,0.34057 1.65495,0.33505 1.65573,0.32893 1.65619,0.32341 1.65696,0.31727 1.65738,0.31177 1.65821,0.30566 1.65819,0.30011 1.6594,0.29401 1.6594,0.2879 1.66023,0.28237 1.66064,0.27625 1.66105,0.27081 1.66186,0.26449 1.66184,0.25845 1.66268,0.2524 1.66267,0.24636 1.66306,0.2406 1.66472,0.23456 1.66632,0.22851 1.66715,0.22247 1.66793,0.21505 1.66921,0.2082 1.6704,0.2016 1.67163,0.19363 1.67281,0.18621 1.67407,0.1777 1.6753,0.16973 1.67647,0.1604 1.67774,0.15195 1.67893,0.14287 1.67976,0.13296 1.68096,0.12306 1.68222,0.11267 1.6834,0.10292 1.68423,0.0917 1.68546,0.0807 1.68667,0.0692 1.68748,0.0612 1.6887,0.0429 1.68993,0.0369 1.69073,0.0192 1.69199,0.005 1.69274,-0.005 1.6932,-0.0192 1.694,-0.0305 1.69439,-0.0429 1.69481,-0.0612 1.69439,-0.0727 1.69483,-0.087 1.69524,-0.1005 1.69475,-0.1151 1.69358,-0.12939 1.69649,-0.14335 1.69234,-0.15796 1.6964,-0.17222 1.69243,-0.1873 1.6964,-0.20215 1.69234,-0.21671 1.69243,-0.23152 1.69234,-0.24692 1.69235,-0.26202 1.68828,-0.27747 1.69235,-0.29277 1.68829,-0.3087 1.68837,-0.32342 1.68828,-0.33996 1.68424,-0.35526 1.68423,-0.37118 1.68423,-0.38772 1.68424,-0.40304 1.68017,-0.42018 1.68018,-0.43552 1.68018,-0.45264 1.67603,-0.46918 1.67605,-0.48513 1.67612,-0.50225 1.67206,-0.52003 1.67198,-0.53657 1.67206,-0.55554 1.66793,-0.57271 1.66802,-0.59172 1.66792,-0.61067 1.65981,-0.62968 1.66387,-0.64925 1.65576,-0.6689 1.65576,-0.68967 1.65576,-0.70929 1.64765,-0.73075 1.64756,-0.75158 1.6436,-0.77357 1.63539,-0.79508 1.6354,-0.8171 1.63134,-0.84036 1.62729,-0.86243 1.62322,-0.88631 1.6191,-0.90957 1.61106,-0.93349 1.60693,-0.95737 1.60287,-0.9825 1.59475,-1.00696 1.59061,-1.0327 1.58657,-1.05659 1.57439,-1.08049 1.56629,-1.10375 1.56214,-1.12646 1.54998,-1.14966 1.54592,-1.17236 1.53375,-1.19441 1.52962,-1.21709 1.51745,-1.23852 1.51331,-1.25931 1.50528,-1.28079 1.49303,-1.30159 1.48898,-1.32244 1.48077,-1.34201 1.46862,-1.36226 1.46455,-1.38183 1.4524,-1.40145 1.44419,-1.42044 1.43608,-1.43881 1.42789,-1.45716 1.41987,-1.47556 1.40752,-1.49332 1.40356,-1.51106 1.3913,-1.52826 1.38319,-1.54538 1.375,-1.56193 1.36697,-1.57847 1.35472,-1.59559 1.34653,-1.61214 1.34246,-1.6293 1.32625,-1.64525 1.3222,-1.66236 1.30993,-1.6789 1.30589,-1.69546 1.28966,-1.71139 1.28552,-1.7279 1.27336,-1.74443 1.26111,-1.75976 1.25298,-1.77634 1.24488,-1.79283 1.23273,-1.80815 1.22451,-1.82407 1.21227,-1.83941 1.20011,-1.85531 1.19198,-1.87125 1.17983,-1.88595 1.16749,-1.90186 1.15946,-1.91657 1.14721,-1.9325 1.13504,-1.94779 1.12288,-1.96251 1.11468,-1.97844 1.10243,-1.99313 1.08622,-2.00724 1.07809,-2.02008 1.06585,-2.03233 1.04963,-2.04581 1.04142,-2.05744 1.02927,-2.06909 1.01701,-2.08135 1.00485,-2.09174 0.9927,-2.10338 0.9804,-2.11442 0.9722,-2.1242 0.9602,-2.13401 0.9479,-2.14444 0.9397,-2.15423 0.9276,-2.1628 0.9153,-2.17199 0.9072,-2.18056 0.895,-2.18916 0.8869,-2.19709 0.8746,-2.20445 0.8665,-2.21243 0.8585,-2.21915 0.8461,-2.22587 0.8381,-2.23264 0.8258,-2.23937 0.8177,-2.24669 0.8096,-2.25409 0.8014,-2.26018 0.7933,-2.26019 0.7812,-2.27246 0.7729,-2.27855 0.7688,-2.28469 0.7567,-2.2847 0.7446,-2.29695 0.7404,-2.3092 0.7282,-2.30307 0.7241,-2.32143 0.7119,-2.32146 0.7038,-2.32142 0.6916,-2.33372 0.6875,-2.33981 0.6754,-2.34595 0.6671,-2.35206 0.6591,-2.3582 0.6468,-2.36431 0.6387,-2.36433 0.6306,-2.37656 0.6224,-2.37658 0.6102,-2.38271 0.6021,-2.3888 0.594,-2.39495 0.5858,-2.40106 0.5736,-2.40108 0.5655,-2.40721 0.5533,-2.4133 0.5451,-2.40109 0.537,-2.40721 0.5288,-2.40105 0.5249,-2.40108 0.5126,-2.40109 0.5126,-2.39492 0.5044,-2.39495 0.5045,-2.3888 0.4963,-2.3766 0.9885,-4.75925"
           id="polygon3007"
           inkscape:connector-curvature="0"
           sodipodi:nodetypes="ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" />
      </g>
    </svg>
    Alles anzeigen

    Die fertigen EMF´s hab ich in einem Grafikprogramm zerschnitten und Kante an Kante zusammengebaut - Das Ergebnis reicht fast an die original-Kurve heran:
    Der Inhalt kann nicht angezeigt werden, da er nicht mehr verfügbar ist.


    Das Ergebnis dann noch in MPR umzuwandeln, sollte das geringste Problem sein...


    Wie gedenkst du denn eigentlich die Verzahnung zu fräsen?
    Kann deine CNC den Fräskopf bzw. Sägeblatt neigen?


    Ach ja: In Zeile 46 kannst mit den Parametern Breite, Höhe und Steigungswinkel einstellen!

    E

    Dateien

    Test.JPG 21,32 kB – 0 Downloads
  • Gebogenes Objekt auf gerade Linie abrollen ( Oder "Mathe für Runaways" )

    • eukalyptus
    • 22. März 2012 um 11:57

    Ich hab da schon mal eine Idee.
    Wird aber noch dauern, bis ich das ausprobieren kann...

  • Gebogenes Objekt auf gerade Linie abrollen ( Oder "Mathe für Runaways" )

    • eukalyptus
    • 22. März 2012 um 03:18

    Sind die grünen Einzelfelder nur durch die 4 Eckpunkte definiert, oder sind die Kanten tatsächlich geschwungen und das soll auch mitberechnet werden?

  • StringReplace zu viel für Autoit?

    • eukalyptus
    • 21. März 2012 um 13:21

    Vielleicht erkennst du selber deinen Fehler anhand dieses Scriptes:

    [autoit]

    $Text1 = "Dies ist ein 21 Test"
    $Text2 = "Dies ist ein 2 Test"

    [/autoit][autoit][/autoit][autoit]

    MsgBox(64, "Test", StringReplace($Text1, $Text2, ""))

    [/autoit]


    ;)

  • Taste loslassen abfragen

    • eukalyptus
    • 20. März 2012 um 18:43

    Die "saubere" Lösung wäre WM_KEYUP:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $VK_ADD = 0x6B
    Global Const $VK_SUBTRACT = 0x6D

    [/autoit] [autoit][/autoit] [autoit]

    Global $iStart = 0

    [/autoit] [autoit][/autoit] [autoit]

    Global $hGui = GUICreate("Test")
    GUIRegisterMsg($WM_KEYDOWN, "WM_KEYDOWN")
    GUIRegisterMsg($WM_KEYUP, "WM_KEYUP")
    GUISetState(@SW_SHOW, $hGui)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While GUIGetMsg() <> $GUI_EVENT_CLOSE
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_KEYDOWN($hWnd, $msg, $wParam, $lParam)
    Switch $wParam
    Case $VK_ADD
    $iStart += 1
    ToolTip("Add: " & $iStart)
    Case $VK_SUBTRACT
    $iStart -= 1
    ToolTip("Sub: " & $iStart)
    EndSwitch
    Return 'GUI_RUNDEFMSG'
    EndFunc ;==>WM_KEYDOWN

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_KEYUP($hWnd, $msg, $wParam, $lParam)
    Switch $wParam
    Case $VK_ADD, $VK_SUBTRACT
    MsgBox(0, "", "es wurde bei: " & $iStart & " losgelassen")
    EndSwitch
    Return 'GUI_RUNDEFMSG'
    EndFunc ;==>WM_KEYUP

    [/autoit]

    Allerdings setzt diese Variante ein GUI voraus...

    E

  • GDI+ Spielerei 3D-Linien

    • eukalyptus
    • 10. März 2012 um 14:04

    Ich zeichne einen Punkt auf einen Pfad, verzerre diesen als Wand bzw. Boden und lese die neuen Koordinaten wieder aus.

    Das hast du wahrscheinlich nicht verstanden, deshalb probier mal dieses Script:

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("MustDeclareVars", 1)
    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()

    [/autoit] [autoit][/autoit] [autoit]

    Global $iWidth = 500
    Global $iHeight = 500

    [/autoit] [autoit][/autoit] [autoit]

    Global $fPersp = 0.2

    [/autoit] [autoit][/autoit] [autoit]

    Global $tWarp_V = DllStructCreate("float[8];")
    Global $pWarp_V = DllStructGetPtr($tWarp_V)
    DllStructSetData($tWarp_V, 1, ($iWidth / 2) - ($iWidth * $fPersp), 1)
    DllStructSetData($tWarp_V, 1, ($iWidth / 2) - ($iWidth * $fPersp), 2)
    DllStructSetData($tWarp_V, 1, ($iWidth / 2) - ($iWidth * $fPersp), 3)
    DllStructSetData($tWarp_V, 1, ($iWidth / 2) + ($iWidth * $fPersp), 4)
    DllStructSetData($tWarp_V, 1, 0, 5)
    DllStructSetData($tWarp_V, 1, 0, 6)
    DllStructSetData($tWarp_V, 1, 0, 7)
    DllStructSetData($tWarp_V, 1, $iHeight, 8)

    [/autoit] [autoit][/autoit] [autoit]

    Global $tWarp_H = DllStructCreate("float[8];")
    Global $pWarp_H = DllStructGetPtr($tWarp_H)
    DllStructSetData($tWarp_H, 1, ($iWidth / 2) - ($iWidth * $fPersp), 1)
    DllStructSetData($tWarp_H, 1, ($iHeight / 2) + ($iHeight * $fPersp), 2)
    DllStructSetData($tWarp_H, 1, ($iWidth / 2) + ($iWidth * $fPersp), 3)
    DllStructSetData($tWarp_H, 1, ($iHeight / 2) + ($iHeight * $fPersp), 4)
    DllStructSetData($tWarp_H, 1, 0, 5)
    DllStructSetData($tWarp_H, 1, $iHeight, 6)
    DllStructSetData($tWarp_H, 1, $iWidth, 7)
    DllStructSetData($tWarp_H, 1, $iHeight, 8)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $hGui = GUICreate("GDI+ Script by Eukalyptus", $iWidth + 200, $iHeight)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth + 200, $iHeight, $hGraphics)
    Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFF000000)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hPen = _GDIPlus_PenCreate(0xFF00FF00, 1)
    Global $hPen2 = _GDIPlus_PenCreate(0xFFFF0000, 1)

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_PAINT, "WM_PAINT")
    GUIRegisterMsg($WM_ERASEBKGND, "WM_PAINT")

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    _Draw()
    Sleep(10)
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Draw()
    Local Static $fRect_W = Random(5, 10), $fRect_H = Random(5, 10), $fRect_T = Random(5, 10)
    Local Static $fRect_X = Random(0, 100 - $fRect_W), $fRect_Y = Random(0, 100 - $fRect_H), $iRect_Z = Int(-$fRect_T)
    $iRect_Z += 1

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFF000000)

    [/autoit] [autoit][/autoit] [autoit]

    If $iRect_Z > 100 Then
    $fRect_W = Random(5, 10) ; Neue Breite
    $fRect_H = Random(5, 10) ; Neue Höhe
    $fRect_T = Random(5, 10) ; Neue Tiefe
    $iRect_Z = Int(-$fRect_T)
    $fRect_X = Random(0, 100 - $fRect_W) ; Neue Position X (0..100% von $iWidth) Range kann beliebig gewählt werden, aber derselbe Wert muss später auch bei Warp verwendet werden
    $fRect_Y = Random(0, 100 - $fRect_H) ; Neue Position Y
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0) ;neuen Pfad erstellen
    Local $hPath_H = $aResult[2]
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0) ;neuen Pfad erstellen
    Local $hPath_V = $aResult[2]

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipAddPathRectangle", "hwnd", $hPath_H, "float", $fRect_X, "float", $iRect_Z, "float", $fRect_W, "float", $fRect_T) ; Rechteck in Pfad einfügen
    DllCall($ghGDIPDll, "uint", "GdipAddPathRectangle", "hwnd", $hPath_V, "float", $fRect_Y, "float", $iRect_Z, "float", $fRect_H, "float", $fRect_T)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;#####################################################################
    ; nur um zu demonstrieren, wie der Pfad verzerrt bzw. verwendet wird
    $aResult = DllCall($ghGDIPDll, "uint", "GdipClonePath", "hwnd", $hPath_H, "int*", 0)
    Local $hPath_H_Clone = $aResult[2]
    $aResult = DllCall($ghGDIPDll, "uint", "GdipClonePath", "hwnd", $hPath_V, "int*", 0)
    Local $hPath_V_Clone = $aResult[2]
    DllCall($ghGDIPDll, "uint", "GdipAddPathRectangle", "hwnd", $hPath_H_Clone, "float", 0, "float", 0, "float", 100, "float", 100)
    DllCall($ghGDIPDll, "uint", "GdipAddPathRectangle", "hwnd", $hPath_V_Clone, "float", 0, "float", 0, "float", 100, "float", 100)

    [/autoit] [autoit][/autoit] [autoit]

    $aResult = DllCall($ghGDIPDll, "uint", "GdipClonePath", "hwnd", $hPath_H_Clone, "int*", 0)
    Local $hPath_H_Clone2 = $aResult[2]
    $aResult = DllCall($ghGDIPDll, "uint", "GdipClonePath", "hwnd", $hPath_V_Clone, "int*", 0)
    Local $hPath_V_Clone2 = $aResult[2]

    [/autoit] [autoit][/autoit] [autoit]

    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, $iWidth, 0)
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPath_H_Clone, "hwnd", $hMatrix)
    _GDIPlus_MatrixTranslate($hMatrix, 100, 0)
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPath_V_Clone, "hwnd", $hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfxBuffer, "hwnd", $hPen2, "hwnd", $hPath_H_Clone)
    DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfxBuffer, "hwnd", $hPen2, "hwnd", $hPath_V_Clone)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipWarpPath", "hwnd", $hPath_H_Clone2, "hwnd", 0, "ptr", $pWarp_H, "int", 4, "float", 0, "float", 0, "float", 100, "float", 100, "int", 0, "float", 0)
    DllCall($ghGDIPDll, "uint", "GdipWarpPath", "hwnd", $hPath_V_Clone2, "hwnd", 0, "ptr", $pWarp_V, "int", 4, "float", 0, "float", 0, "float", 100, "float", 100, "int", 0, "float", 0)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfxBuffer, "hwnd", $hPen2, "hwnd", $hPath_H_Clone2)
    DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfxBuffer, "hwnd", $hPen2, "hwnd", $hPath_V_Clone2)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath_V_Clone)
    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath_H_Clone)
    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath_V_Clone2)
    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath_H_Clone2)
    ;#####################################################################

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipWarpPath", "hwnd", $hPath_H, "hwnd", 0, "ptr", $pWarp_H, "int", 4, "float", 0, "float", 0, "float", 100, "float", 100, "int", 0, "float", 0) ; Parameter 7 und 8 sollten den gleichen Wert haben, wie $iRect_X bzw. $iRect_Z
    DllCall($ghGDIPDll, "uint", "GdipWarpPath", "hwnd", $hPath_V, "hwnd", 0, "ptr", $pWarp_V, "int", 4, "float", 0, "float", 0, "float", 100, "float", 100, "int", 0, "float", 0) ; Parameter 7 und 8 sollten den gleichen Wert haben, wie $iRect_Y bzw. $iRect_Z

    [/autoit] [autoit][/autoit] [autoit]

    Local $tPoints_H = DllStructCreate("float[8];")
    Local $tPoints_V = DllStructCreate("float[8];")

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipGetPathPoints", "hwnd", $hPath_H, "ptr", DllStructGetPtr($tPoints_H), "int", 4) ; Die 4 Expunkte des Rechtecks(Horizontal) in die Struct lesen
    DllCall($ghGDIPDll, "uint", "GdipGetPathPoints", "hwnd", $hPath_V, "ptr", DllStructGetPtr($tPoints_V), "int", 4) ; Die 4 Expunkte des Rechtecks(Vertikal) in die Struct lesen

    [/autoit] [autoit][/autoit] [autoit]

    Local $aP_H[8][2], $aP_V[8][2] ;Zum leichteren Verständniss wandle ich die Struct in ein Array
    For $i = 0 To 7
    For $j = 0 To 1
    $aP_H[$i][$j] = DllStructGetData($tPoints_H, 1, $i * 2 + $j + 1)
    Next
    Next
    For $i = 0 To 7
    For $j = 0 To 1
    $aP_V[$i][$j] = DllStructGetData($tPoints_V, 1, $i * 2 + $j + 1)
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit]

    ;Punkte Horizontal
    ; 0---1
    ; / \
    ;3------2

    [/autoit] [autoit][/autoit] [autoit]

    ;Punkte Vertikal
    ;3--__
    ;| --0
    ;| |
    ;| __--1
    ;2--

    [/autoit] [autoit][/autoit] [autoit]

    ;Punkte 3D
    ;0----1
    ;|\ |\
    ;| 4----5
    ;3----2 |
    ; \| \|
    ; 7----6

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[0][0], "float", $aP_V[0][1], "float", $aP_H[1][0], "float", $aP_V[0][1]);0-1
    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[3][0], "float", $aP_V[3][1], "float", $aP_H[2][0], "float", $aP_V[3][1]);3-2

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[0][0], "float", $aP_V[1][1], "float", $aP_H[1][0], "float", $aP_V[1][1]);4-5
    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[3][0], "float", $aP_V[2][1], "float", $aP_H[2][0], "float", $aP_V[2][1]);7-6

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[0][0], "float", $aP_V[0][1], "float", $aP_H[3][0], "float", $aP_V[3][1]);0-3
    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[1][0], "float", $aP_V[0][1], "float", $aP_H[2][0], "float", $aP_V[3][1]);1-2

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[0][0], "float", $aP_V[1][1], "float", $aP_H[3][0], "float", $aP_V[2][1]);4-7
    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[1][0], "float", $aP_V[1][1], "float", $aP_H[2][0], "float", $aP_V[2][1]);5-6

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[0][0], "float", $aP_V[0][1], "float", $aP_H[0][0], "float", $aP_V[1][1]);0-4
    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[1][0], "float", $aP_V[0][1], "float", $aP_H[1][0], "float", $aP_V[1][1]);1-5

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[3][0], "float", $aP_V[3][1], "float", $aP_H[3][0], "float", $aP_V[2][1]);3-7
    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[2][0], "float", $aP_V[3][1], "float", $aP_H[2][0], "float", $aP_V[2][1]);2-6

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath_V) ;Pfad löschen
    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath_H) ;Pfad löschen
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    EndFunc ;==>_Draw

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_PAINT

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _GDIPlus_BitmapDispose($hBmpBuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

    [/autoit]

    Rechts siehst du die unverzerrten Pfade "Horizontal" und "Vertikal"
    Im linken Bildauschnitt sind in Rot gezeichnet die verzerrten Pfade und in Grün die Linien, die ich aus den verzerrten Koordinaten auslese!

    Diese Methode stimmt nicht wirklich, denn eigenlich müsste man für jede Ebene des Quaders einen eigenen Pfad ertellen und verzerren.
    (Das hab ich bei meinem BlockOut-Versuch gemacht: Blockout 3D Tetris)
    Das ist mir meistens zu Aufwändig, aber auch so ist das Ergebnis ganz OK.

    E

  • GDI+ Spielerei 3D-Linien

    • eukalyptus
    • 9. März 2012 um 23:44

    Verwendest du AutoIt 3.3.8.1?

    Bei diesem DllCall wird eine Struct via "struct*" übergeben und das geht erst ab 3.3.8.0
    Kann aber ohne weiteres auf "ptr", DllStructGetPtr($tData_P) geändert werden... (natürlich überall im Script)

    Einige der DllCalls sind die GDIPlus Funktionen, welche nicht in der Standard UDF enthalten sind.
    Das Arbeiten mit Structs bringt in diesem Fall einen Geschwindigkeitsvorteil, da nicht jedesmal zwischen Structs und AutoIt-Arrays gewandelt werden muss.

    z.B.: $tWarp_V in Zeile 24: ich erstelle diese Struct nur einmal selber. Würde ich die Funktion _GDIPlus_PathWarp aus der GDIp.au3 verwenden, dann würde diese Struct bei jedem Aufruf erneut ertellt und befüllt werden - und das kostet Zeit!

    E

  • GDI+ Spielerei 3D-Linien

    • eukalyptus
    • 9. März 2012 um 23:12

    Nach langer Pause hab ich mich mal wieder mit GDI+ gespielt.

    viel Vergnügen!

    Der Inhalt kann nicht angezeigt werden, da er nicht mehr verfügbar ist.

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <Misc.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("MustDeclareVars", 1)
    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()

    [/autoit] [autoit][/autoit] [autoit]

    Global $iWidth = 500
    Global $iHeight = 400
    Global $iStyle = $GUI_SS_DEFAULT_GUI, $iExStyle = 0, $iX = -1, $iY = -1

    [/autoit] [autoit][/autoit] [autoit]

    If MsgBox(4, "Fullscreen?", "Fullscreen?") = 6 Then
    $iWidth = @DesktopWidth
    $iHeight = @DesktopHeight
    $iStyle = $WS_POPUP
    $iExStyle = $WS_EX_TOPMOST
    $iX = 0
    $iY = 0
    _WinAPI_ShowCursor(False)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Global $iPlanes = 16
    Global $iLines = 32
    Global $iCount = $iPlanes * $iLines
    Global $fPersp = 0.04
    Global $fSpeed = 0.2

    [/autoit] [autoit][/autoit] [autoit]

    Global $hMatrix_Speed = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix_Speed, 0, $fSpeed)

    [/autoit] [autoit][/autoit] [autoit]

    Global $tWarp_V = DllStructCreate("float[8];")
    Global $pWarp_V = DllStructGetPtr($tWarp_V)
    DllStructSetData($tWarp_V, 1, 0, 1)
    DllStructSetData($tWarp_V, 1, $iHeight, 2)
    DllStructSetData($tWarp_V, 1, 0, 3)
    DllStructSetData($tWarp_V, 1, 0, 4)
    DllStructSetData($tWarp_V, 1, ($iWidth / 2) - ($iWidth * $fPersp), 5)
    DllStructSetData($tWarp_V, 1, ($iHeight / 2) + ($iHeight * $fPersp), 6)
    DllStructSetData($tWarp_V, 1, ($iWidth / 2) - ($iWidth * $fPersp), 7)
    DllStructSetData($tWarp_V, 1, ($iHeight / 2) - ($iHeight * $fPersp), 8)

    [/autoit] [autoit][/autoit] [autoit]

    Global $tWarp_H = DllStructCreate("float[8];")
    Global $pWarp_H = DllStructGetPtr($tWarp_H)
    DllStructSetData($tWarp_H, 1, $iWidth, 1)
    DllStructSetData($tWarp_H, 1, $iHeight, 2)
    DllStructSetData($tWarp_H, 1, 0, 3)
    DllStructSetData($tWarp_H, 1, $iHeight, 4)
    DllStructSetData($tWarp_H, 1, ($iWidth / 2) + ($iWidth * $fPersp), 5)
    DllStructSetData($tWarp_H, 1, ($iHeight / 2) + ($iHeight * $fPersp), 6)
    DllStructSetData($tWarp_H, 1, ($iWidth / 2) - ($iWidth * $fPersp), 7)
    DllStructSetData($tWarp_H, 1, ($iHeight / 2) + ($iHeight * $fPersp), 8)

    [/autoit] [autoit][/autoit] [autoit]

    Global $tData = DllStructCreate("int Count; ptr Points; ptr Types;")
    Global $pData = DllStructGetPtr($tData)
    Global $tData_P = DllStructCreate("float[" & $iCount * 2 & "]")
    Global $pData_P = DllStructGetPtr($tData_P)
    Global $tData_T = DllStructCreate("ubyte[" & $iCount & "]")
    Global $pData_T = DllStructGetPtr($tData_T)
    DllStructSetData($tData, "Count", $iCount)
    DllStructSetData($tData, "Points", $pData_P)
    DllStructSetData($tData, "Types", $pData_T)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $tPoints_V = DllStructCreate("float[" & $iCount * 2 & "];")
    Global $pPoints_V = DllStructGetPtr($tPoints_V)
    For $j = 0 To $iLines - 1
    DllStructSetData($tPoints_V, 1, Random(-300, 300), $j * 2 + 1)
    DllStructSetData($tPoints_V, 1, 0, $j * 2 + 2)
    Next
    For $i = 1 To $iPlanes - 1
    For $j = 0 To $iLines - 1
    DllStructSetData($tPoints_V, 1, _CalcNewPoint(DllStructGetData($tPoints_V, 1, (($i - 1) * $iLines + $j) * 2 + 1)), ($i * $iLines + $j) * 2 + 1)
    DllStructSetData($tPoints_V, 1, $i, ($i * $iLines + $j) * 2 + 2)
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit]

    Global $tPoints_H = DllStructCreate("float[" & $iCount * 2 & "];")
    Global $pPoints_H = DllStructGetPtr($tPoints_H)
    For $j = 0 To $iLines - 1
    DllStructSetData($tPoints_H, 1, Random(-300, 300), $j * 2 + 1)
    DllStructSetData($tPoints_H, 1, 0, $j * 2 + 2)
    Next
    For $i = 1 To $iPlanes - 1
    For $j = 0 To $iLines - 1
    DllStructSetData($tPoints_H, 1, _CalcNewPoint(DllStructGetData($tPoints_H, 1, (($i - 1) * $iLines + $j) * 2 + 1)), ($i * $iLines + $j) * 2 + 1)
    DllStructSetData($tPoints_H, 1, $i, ($i * $iLines + $j) * 2 + 2)
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit]

    Global $tWarped_H = DllStructCreate("float[" & $iCount * 2 & "];")
    Global $pWarped_H = DllStructGetPtr($tWarped_H)
    Global $tWarped_V = DllStructCreate("float[" & $iCount * 2 & "];")
    Global $pWarped_V = DllStructGetPtr($tWarped_V)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $hGui = GUICreate("GDI+ Script by Eukalyptus", $iWidth, $iHeight, $iX, $iY, $iStyle, $iExStyle)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    Global $hDC = _WinAPI_GetDC($hGui)
    Global $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
    Global $hBmpTmp = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
    _WinAPI_DeleteObject($hBMP)
    $hBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmpTmp)
    _GDIPlus_BitmapDispose($hBmpTmp)
    Global $hCDC = _WinAPI_CreateCompatibleDC($hDC)
    Global $hOBJ = _WinAPI_SelectObject($hCDC, $hBMP)
    Global $hGfxBuffer = _GDIPlus_GraphicsCreateFromHDC($hCDC)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFF000000)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hPen = _GDIPlus_PenCreate(0xFF005500, 1)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_PAINT, "WM_PAINT")
    GUIRegisterMsg($WM_ERASEBKGND, "WM_PAINT")

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    Select
    Case _IsPressed("25")
    _Move_H(0.5)
    Case _IsPressed("27")
    _Move_H(-0.5)
    Case _IsPressed("26")
    _Move_V(0.5)
    Case _IsPressed("28")
    _Move_V(-0.5)
    EndSelect
    _Draw()
    Sleep(10)
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Move_H($fMove)
    Local $hMatrix = _GDIPlus_MatrixCreate()
    DllCall($ghGDIPDll, "uint", "GdipShearMatrix", "hwnd", $hMatrix, "float", $fMove, "float", 0, "int", 0)
    DllCall($ghGDIPDll, "uint", "GdipTransformMatrixPoints", "hwnd", $hMatrix, "ptr", $pPoints_H, "int", $iCount)
    _GDIPlus_MatrixDispose($hMatrix)
    EndFunc ;==>_Move_H

    [/autoit] [autoit][/autoit] [autoit]

    Func _Move_V($fMove)
    Local $hMatrix = _GDIPlus_MatrixCreate()
    DllCall($ghGDIPDll, "uint", "GdipShearMatrix", "hwnd", $hMatrix, "float", $fMove, "float", 0, "int", 0)
    DllCall($ghGDIPDll, "uint", "GdipTransformMatrixPoints", "hwnd", $hMatrix, "ptr", $pPoints_V, "int", $iCount)
    _GDIPlus_MatrixDispose($hMatrix)
    EndFunc ;==>_Move_V

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _CalcNewPoint($fOld)
    Local $fTmp
    Do
    $fTmp = Random(-30, 30)
    Until Abs($fOld + $fTmp) < 300; And Abs($fX + $fTmp) > 10
    Return $fOld + $fTmp
    EndFunc ;==>_CalcNewPoint

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Draw()
    DllCall($ghGDIPDll, "uint", "GdipTransformMatrixPoints", "hwnd", $hMatrix_Speed, "ptr", $pPoints_H, "int", $iCount)
    DllCall($ghGDIPDll, "uint", "GdipTransformMatrixPoints", "hwnd", $hMatrix_Speed, "ptr", $pPoints_V, "int", $iCount)

    [/autoit] [autoit][/autoit] [autoit]

    If DllStructGetData($tPoints_H, 1, 2) >= 1 Then
    Local $fX, $fTmp
    DllCall("kernel32.dll", "none", "RtlMoveMemory", "ptr", $pPoints_H + ($iLines * 8), "ptr", $pPoints_H, "ulong_ptr", DllStructGetSize($tPoints_H) - ($iLines * 8))
    For $i = 1 To $iLines
    DllStructSetData($tPoints_H, 1, _CalcNewPoint(DllStructGetData($tPoints_H, 1, ($i - 1) * 2 + 1)), ($i - 1) * 2 + 1)
    DllStructSetData($tPoints_H, 1, 0, ($i - 1) * 2 + 2)
    Next

    [/autoit] [autoit][/autoit] [autoit]

    DllCall("kernel32.dll", "none", "RtlMoveMemory", "ptr", $pPoints_V + ($iLines * 8), "ptr", $pPoints_V, "ulong_ptr", DllStructGetSize($tPoints_V) - ($iLines * 8))
    For $i = 1 To $iLines
    DllStructSetData($tPoints_V, 1, _CalcNewPoint(DllStructGetData($tPoints_V, 1, ($i - 1) * 2 + 1)), ($i - 1) * 2 + 1)
    DllStructSetData($tPoints_V, 1, 0, ($i - 1) * 2 + 2)
    Next
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
    Local $hPath_Temp = $aResult[2]
    DllCall($ghGDIPDll, "uint", "GdipAddPathLine2", "hwnd", $hPath_Temp, "ptr", $pPoints_V, "int", $iCount)

    [/autoit] [autoit][/autoit] [autoit]

    Local $fOff = DllStructGetData($tPoints_H, 1, 2)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipGetPathData", "hwnd", $hPath_Temp, "ptr", $pData)

    [/autoit] [autoit][/autoit] [autoit]

    Local $fX1, $fY1, $fX2, $fY2
    For $i = 1 To $iLines
    $fX1 = DllStructGetData($tData_P, 1, ($iLines + $i - 1) * 2 + 1)
    $fY1 = DllStructGetData($tData_P, 1, ($iLines + $i - 1) * 2 + 2)
    $fX2 = DllStructGetData($tData_P, 1, ($i - 1) * 2 + 1)
    $fY2 = DllStructGetData($tData_P, 1, ($i - 1) * 2 + 2)
    DllStructSetData($tData_P, 1, $fX1 + ($fX2 - $fX1) * $fOff, ($i - 1) * 2 + 1)
    DllStructSetData($tData_P, 1, $fY1 + ($fY2 - $fY1) * $fOff, ($i - 1) * 2 + 2)
    Next

    [/autoit] [autoit][/autoit] [autoit]

    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath2", "ptr", $pData_P, "ptr", $pData_T, "int", $iCount, "int", 0, "int*", 0)
    Local $hPath_V = $aResult[5]

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipWarpPath", "hwnd", $hPath_V, "hwnd", 0, "ptr", $pWarp_V, "int", 4, "float", -50, "float", 2, "float", 100, "float", $iPlanes, "int", 0, "float", 0)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipResetPath", "hwnd", $hPath_Temp)
    DllCall($ghGDIPDll, "uint", "GdipAddPathLine2", "hwnd", $hPath_Temp, "ptr", $pPoints_H, "int", $iCount)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipGetPathData", "hwnd", $hPath_Temp, "ptr", $pData)

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To $iLines
    $fX1 = DllStructGetData($tData_P, 1, ($iLines + $i - 1) * 2 + 1)
    $fY1 = DllStructGetData($tData_P, 1, ($iLines + $i - 1) * 2 + 2)
    $fX2 = DllStructGetData($tData_P, 1, ($i - 1) * 2 + 1)
    $fY2 = DllStructGetData($tData_P, 1, ($i - 1) * 2 + 2)
    DllStructSetData($tData_P, 1, $fX1 + ($fX2 - $fX1) * $fOff, ($i - 1) * 2 + 1)
    DllStructSetData($tData_P, 1, $fY1 + ($fY2 - $fY1) * $fOff, ($i - 1) * 2 + 2)
    Next

    [/autoit] [autoit][/autoit] [autoit]

    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath2", "ptr", $pData_P, "ptr", $pData_T, "int", $iCount, "int", 0, "int*", 0)
    Local $hPath_H = $aResult[5]

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipWarpPath", "hwnd", $hPath_H, "hwnd", 0, "ptr", $pWarp_H, "int", 4, "float", -50, "float", 2, "float", 100, "float", $iPlanes, "int", 0, "float", 0)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipGetPathPoints", "hwnd", $hPath_H, "ptr", $pWarped_H, "int", $iCount)
    DllCall($ghGDIPDll, "uint", "GdipGetPathPoints", "hwnd", $hPath_V, "ptr", $pWarped_V, "int", $iCount)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFF040008)
    For $i = $iPlanes - 2 To 0 Step -1
    _GDIPlus_PenSetWidth($hPen, _CalcPenW(DllStructGetData($tPoints_H, 1, ($i * $iLines) * 2 + 2), $iPlanes, 2))
    _GDIPlus_PenSetColor($hPen, BitOR(BitShift(0xFF - ($i * 0xFF / $iPlanes), -24), BitShift(0xFF - ($i * 0xFF / $iPlanes), -16), ($i * 0xFF / $iPlanes)))
    For $j = 0 To $iLines - 1
    $fX1 = DllStructGetData($tWarped_H, 1, ($i * $iLines + $j) * 2 + 1)
    $fY1 = DllStructGetData($tWarped_V, 1, ($i * $iLines + $j) * 2 + 2)
    $fX2 = DllStructGetData($tWarped_H, 1, (($i + 1) * $iLines + $j) * 2 + 1)
    $fY2 = DllStructGetData($tWarped_V, 1, (($i + 1) * $iLines + $j) * 2 + 2)
    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $fX1, "float", $fY1, "float", $fX2, "float", $fY2)
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath_V)
    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath_H)
    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath_Temp)

    [/autoit] [autoit][/autoit] [autoit]

    _WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hCDC, 0, 0, 0x00CC0020)
    EndFunc ;==>_Draw

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _CalcPenW($fVal, $iRange, $iMax)
    Local $fW = (Log($iRange * 2) - Log($fVal + 1)) * $iMax
    Return $fW
    EndFunc ;==>_CalcPenW

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hCDC, 0, 0, 0x00CC0020)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_PAINT

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    _GDIPlus_MatrixDispose($hMatrix_Speed)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _WinAPI_SelectObject($hCDC, $hOBJ)
    _WinAPI_DeleteObject($hBMP)
    _WinAPI_DeleteDC($hCDC)
    _WinAPI_ReleaseDC($hGui, $hDC)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

    [/autoit] [autoit][/autoit] [autoit][/autoit]

    E

    Edit.: sollte nun auch auf älteren AutoIt Versionen laufen...

    Dateien

    3D_Lines.JPG 16,58 kB – 0 Downloads
  • Deutsche Hilfe - Funktionen ohne Beispiel

    • eukalyptus
    • 9. März 2012 um 22:47

    Ich hätte ein Testscript für NamedPipes.
    Ist etwas umfangreicher als ein normales Beispiel.

    Beide Scripte kompilieren und dann starten.
    Die Scripte können beliebig beendet und wieder gestartet werden, die Verbindung sollte jedesmal wieder aufgebaut werden.

    Sender.au3

    Spoiler anzeigen
    [autoit]

    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiRichEdit.au3>
    #include <Memory.au3>
    #include <NamedPipes.au3>
    #include <WinAPI.au3>
    #include <WinAPIError.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Opt("MustDeclareVars", 1)
    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hGui = GUICreate("Sender", 400, 600, @DesktopWidth / 2 + 5)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    Global $hREdit = _GUICtrlRichEdit_Create($hGui, "", 5, 5, 390, 590, BitOR($ES_MULTILINE, $WS_VSCROLL, $WS_HSCROLL, $ES_READONLY))
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $sPIPE_NAME = "\\.\pipe\AutoItPipe"

    [/autoit] [autoit][/autoit] [autoit]

    Global $hPipe

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $iBufferSize = 256

    [/autoit] [autoit][/autoit] [autoit]

    Global $tBuffer = DllStructCreate("byte[" & $iBufferSize & "];")
    Global $pBuffer = DllStructGetPtr($tBuffer)
    Global $iBuffer = 0

    [/autoit] [autoit][/autoit] [autoit]

    Global $iWritten = 0
    Global $iByte = 0
    Global $iStatus

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $ERROR_INVALID_HANDLE = 0x6
    Global Const $ERROR_IO_PENDING = 0x3E5
    Global Const $ERROR_PIPE_CONNECTED = 0x217
    Global Const $ERROR_NO_DATA = 0xE8

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(Random(500, 2000, 1))

    [/autoit] [autoit][/autoit] [autoit]

    _BufferAddData($iByte, 12)
    $iByte += 1

    [/autoit] [autoit][/autoit] [autoit]

    If $iBuffer > 0 Then
    If $iByte > 0xFF Then $iByte = 0

    [/autoit] [autoit][/autoit] [autoit]

    $iStatus = _WinAPI_WriteFile($hPipe, $pBuffer, $iBuffer, $iWritten, 0)
    If $iStatus = 0 Then
    _Log("! Write Error " & _WinAPI_GetLastError() & " " & _WinAPI_GetLastErrorMessage())
    _NamedPipes_DisconnectNamedPipe($hPipe)
    _Log("> Disconnect " & _WinAPI_GetLastError() & " " & _WinAPI_GetLastErrorMessage())
    _WinAPI_CloseHandle($hPipe)
    _Log("> Close " & _WinAPI_GetLastError() & " " & _WinAPI_GetLastErrorMessage())
    $hPipe = _WinAPI_CreateFile($sPIPE_NAME, 2, 6)
    If $hPipe = 0 Then
    _Log("! Pipe creation failed " & _WinAPI_GetLastError() & " " & _WinAPI_GetLastErrorMessage())
    Else
    _Log("+ Pipe creation OK " & _WinAPI_GetLastError() & " " & _WinAPI_GetLastErrorMessage())
    EndIf
    Else
    _Log("+ " & $iWritten & " Bytes written")
    _BufferRemoveData($iWritten)
    EndIf
    EndIf
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _BufferRemoveData($iLen)
    If $iLen > $iBuffer Then $iLen = $iBuffer
    Local $iMove = $iBuffer - $iLen
    _MemMoveMemory($pBuffer + $iLen, $pBuffer, $iMove)
    $iBuffer = $iMove
    _Log("> " & $iLen & " Bytes removed, " & $iMove & " Bytes left")
    EndFunc ;==>_BufferRemoveData

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _BufferAddData($iByte, $iLen = 14)
    Local $iOver = ($iLen + $iBuffer) - $iBufferSize
    If $iOver > 0 Then
    _Log("- Buffer overflow: " & $iOver)
    _BufferRemoveData($iOver)
    EndIf
    For $i = $iBuffer To $iBuffer + $iLen
    DllStructSetData($tBuffer, 1, $iByte, $i + 1)
    Next
    $iBuffer += $iLen
    _Log("> Bufferdata: " & $iBuffer & " " & BinaryMid(DllStructGetData($tBuffer, 1), 1, $iBuffer))
    EndFunc ;==>_BufferAddData

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    MsgBox(0, "", "")
    _GUICtrlRichEdit_Destroy($hREdit)
    ;_WinAPI_CloseHandle($hPipe)
    Exit
    EndFunc ;==>_Exit

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Log($sLog)
    Local Static $iLogPos = 0
    Local $aSel

    [/autoit] [autoit][/autoit] [autoit]

    $sLog = StringRegExpReplace($sLog, "[\r|\n]*", "")

    [/autoit] [autoit][/autoit] [autoit]

    _GUICtrlRichEdit_AppendText($hREdit, $sLog & @CRLF)
    _GUICtrlRichEdit_SetSel($hREdit, $iLogPos, -1, True)
    _GUICtrlRichEdit_SetFont($hREdit, 9, "Courier New")

    [/autoit] [autoit][/autoit] [autoit]

    Switch StringLeft($sLog, 1)
    Case "!"
    _GUICtrlRichEdit_SetCharColor($hREdit, 0x0000F7)
    _GUICtrlRichEdit_SetCharAttributes($hREdit, "+bo")
    Case ">"
    _GUICtrlRichEdit_SetCharColor($hREdit, 0xFF0000)
    _GUICtrlRichEdit_SetCharAttributes($hREdit, "-bo")
    Case "-"
    _GUICtrlRichEdit_SetCharColor($hREdit, 0x0088FF)
    _GUICtrlRichEdit_SetCharAttributes($hREdit, "+bo")
    Case "+"
    _GUICtrlRichEdit_SetCharColor($hREdit, 0x007F00)
    _GUICtrlRichEdit_SetCharAttributes($hREdit, "+bo")
    Case Else
    _GUICtrlRichEdit_SetCharColor($hREdit, 0)
    _GUICtrlRichEdit_SetCharAttributes($hREdit, "-bo")
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    $aSel = _GUICtrlRichEdit_GetSel($hREdit)
    $iLogPos = $aSel[1] - 1
    EndFunc ;==>_Log

    [/autoit]


    Empfänger.au3:

    Spoiler anzeigen
    [autoit]

    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiRichEdit.au3>
    #include <NamedPipes.au3>
    #include <WinAPI.au3>
    #include <WinAPIError.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("MustDeclareVars", 1)
    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hGui = GUICreate("Empänger", 400, 600, @DesktopWidth / 2 - 405)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    Global $hREdit = _GUICtrlRichEdit_Create($hGui, "", 5, 5, 390, 590, BitOR($ES_MULTILINE, $WS_VSCROLL, $WS_HSCROLL, $ES_READONLY))
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $sPIPE_NAME = "\\.\pipe\AutoItPipe"

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $iPipeBuffer = 512

    [/autoit] [autoit][/autoit] [autoit]

    Global $hPipe = _NamedPipes_CreateNamedPipe($sPIPE_NAME, 2, 3, 0, 0, 0, 0, 5, $iPipeBuffer, $iPipeBuffer)
    _Log("> New Pipe " & $hPipe & " " & _WinAPI_GetLastError() & " " & _WinAPI_GetLastErrorMessage())
    Global Const $iBufferSize = 256

    [/autoit] [autoit][/autoit] [autoit]

    Global $tBuffer = DllStructCreate("byte[" & $iBufferSize & "];")
    Global $pBuffer = DllStructGetPtr($tBuffer)
    Global $iBuffer = DllStructGetSize($tBuffer)

    [/autoit] [autoit][/autoit] [autoit]

    Global $iRead = 0
    Global $iStatus

    [/autoit] [autoit][/autoit] [autoit]

    Global Const $ERROR_INVALID_HANDLE = 0x6
    Global Const $ERROR_IO_PENDING = 0x3E5
    Global Const $ERROR_PIPE_CONNECTED = 0x217
    Global Const $ERROR_BROKEN_PIPE = 0x6D

    [/autoit] [autoit][/autoit] [autoit]

    _NamedPipes_ConnectNamedPipe($hPipe)
    _Log("+ Client Connected")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $iStatus = _WinAPI_ReadFile($hPipe, $pBuffer, $iBuffer, $iRead, 0)
    If $iStatus = 0 Then
    If _WinAPI_GetLastError() = $ERROR_BROKEN_PIPE Then
    _Log("! Broken Pipe " & _WinAPI_GetLastError() & " " & _WinAPI_GetLastErrorMessage())
    _NamedPipes_DisconnectNamedPipe($hPipe)
    _Log("> Disconnect " & _WinAPI_GetLastError() & " " & _WinAPI_GetLastErrorMessage())
    _WinAPI_CloseHandle($hPipe)
    _Log("> Close " & _WinAPI_GetLastError() & " " & _WinAPI_GetLastErrorMessage())
    $hPipe = _NamedPipes_CreateNamedPipe($sPIPE_NAME, 2, 2, 0, 0, 0, 0, 1, 32, 32)
    If $hPipe = 0 Then
    _Log("! Pipe creation failed " & _WinAPI_GetLastError() & " " & _WinAPI_GetLastErrorMessage())
    Else
    _Log("+ Pipe creation OK " & _WinAPI_GetLastError() & " " & _WinAPI_GetLastErrorMessage())
    _NamedPipes_ConnectNamedPipe($hPipe)
    _Log("> Connect " & _WinAPI_GetLastError() & " " & _WinAPI_GetLastErrorMessage())
    EndIf
    EndIf
    Else
    _Log("+ " & $iRead & " Bytes read: " & BinaryMid(DllStructGetData($tBuffer, 1), 1, $iRead))
    EndIf
    Sleep(10)
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    MsgBox(0, "", "")
    _GUICtrlRichEdit_Destroy($hREdit)
    Exit
    EndFunc ;==>_Exit

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Log($sLog)
    Local Static $iLogPos = 0
    Local $aSel

    [/autoit] [autoit][/autoit] [autoit]

    $sLog = StringRegExpReplace($sLog, "[\r|\n]*", "")

    [/autoit] [autoit][/autoit] [autoit]

    _GUICtrlRichEdit_AppendText($hREdit, $sLog & @CRLF)
    _GUICtrlRichEdit_SetSel($hREdit, $iLogPos, -1, True)
    _GUICtrlRichEdit_SetFont($hREdit, 9, "Courier New")

    [/autoit] [autoit][/autoit] [autoit]

    Switch StringLeft($sLog, 1)
    Case "!"
    _GUICtrlRichEdit_SetCharColor($hREdit, 0x0000F7)
    _GUICtrlRichEdit_SetCharAttributes($hREdit, "+bo")
    Case ">"
    _GUICtrlRichEdit_SetCharColor($hREdit, 0xFF0000)
    _GUICtrlRichEdit_SetCharAttributes($hREdit, "-bo")
    Case "-"
    _GUICtrlRichEdit_SetCharColor($hREdit, 0x0088FF)
    _GUICtrlRichEdit_SetCharAttributes($hREdit, "+bo")
    Case "+"
    _GUICtrlRichEdit_SetCharColor($hREdit, 0x007F00)
    _GUICtrlRichEdit_SetCharAttributes($hREdit, "+bo")
    Case Else
    _GUICtrlRichEdit_SetCharColor($hREdit, 0)
    _GUICtrlRichEdit_SetCharAttributes($hREdit, "-bo")
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    $aSel = _GUICtrlRichEdit_GetSel($hREdit)
    $iLogPos = $aSel[1] - 1
    EndFunc ;==>_Log

    [/autoit] [autoit][/autoit] [autoit][/autoit]
  • Bass.dll UDF Version_10 Download

    • eukalyptus
    • 8. März 2012 um 15:12

    zum Messen kannst du die Funktion _BASS_EXT_Level2dB verwenden.
    Kennst du dich mit dB aus?

    Kommt drauf an, was du messen willst. Bei der Lautstärke sind 6dB das doppelte. Bei Leistung 3dB das doppelte.
    Den Unterschied zwischen Out und In beim Kalibrieren in dB messen und bei den Messergebnissen mit einrechnen.

    z.B.: Kalibrieren: Out = -10 dB / In = -5 dB / Unterschied = 5dB
    Messen: Out = -10 dB / In = -20 dB / Dämpfung = 15dB

    Falls du wirklich den In und Out auf die gleiche Lautstärke bringen willst, dann kannst du das mit _BASS_RecordSetInput machen.

    E

Spenden

Jeder Euro hilft uns, Euch zu helfen.

Download

AutoIt Tutorial
AutoIt Buch
Onlinehilfe
AutoIt Entwickler
  1. Datenschutzerklärung
  2. Impressum
  3. Shoutbox-Archiv
Community-Software: WoltLab Suite™