Malprogramm

  • Hi,
    Ich habe gerade ein kleines Autoit malprogramm entworfen, was allerdings nur bedingt funktioniert. Ich hab gerade erst mit Autoit angefangen, und kann auch keine andere Programmiersprache.(Autoit ist viell. etw langsam) Mein Problem besteht darin, dass die Linie zwar gezeichnet wird aber je schneller man die Maus bewegt, desto größer wird der Abstand zwischen den gemalten Pixeln.

    Hier das Programm bis jetzt: Pc= Pinselcolor Bk: Hintergrundfarbe

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <misc.au3>
    #include <WindowsConstants.au3>
    #include <Array.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 600, 600)
    $MenuItem1 = GUICtrlCreateMenu("Datei")
    $MenuItem2 = GUICtrlCreateMenuItem("Neu", $MenuItem1)
    $MenuItem3 = GUICtrlCreateMenuItem("Öffnen", $MenuItem1)
    $MenuItem4 = GUICtrlCreateMenuItem("Speichern", $MenuItem1)
    $grossesweissesfeld = GUICtrlCreateGraphic(75, 30, 500, 500)
    GuiCtrlSetbkColor(-1, 0xffffff)
    $Button1 = GUICtrlCreateButton("", 8, 64, 25, 25)
    GUICtrlSetBkColor(-1, 0x000000)
    GUICtrlSetCursor (-1, 0)
    $Button2 = GUICtrlCreateButton("", 8, 384, 25, 25)
    GUICtrlSetBkColor(-1, 0x808080)
    GUICtrlSetCursor (-1, 0)
    $Button3 = GUICtrlCreateButton("", 8, 448, 25, 25)
    GUICtrlSetBkColor(-1, 0xC0C0C0)
    GUICtrlSetCursor (-1, 0)
    $Button4 = GUICtrlCreateButton("", 8, 224, 25, 25)
    GUICtrlSetBkColor(-1, 0xFF0000)
    GUICtrlSetCursor (-1, 0)
    $Button5 = GUICtrlCreateButton("", 8, 256, 25, 25)
    GUICtrlSetBkColor(-1, 0xFFFF00)
    GUICtrlSetCursor (-1, 0)
    $Button6 = GUICtrlCreateButton("", 8, 288, 25, 25)
    GUICtrlSetBkColor(-1, 0x0000FF)
    GUICtrlSetCursor (-1, 0)
    $Button7 = GUICtrlCreateButton("", 8, 160, 25, 25)
    GUICtrlSetBkColor(-1, 0x00FF00)
    GUICtrlSetCursor (-1, 0)
    $Button8 = GUICtrlCreateButton("", 8, 320, 25, 25)
    GUICtrlSetBkColor(-1, 0x3399FF)
    GUICtrlSetCursor (-1, 0)
    $Button9 = GUICtrlCreateButton("", 8, 192, 25, 25)
    GUICtrlSetBkColor(-1, 0x800080)
    GUICtrlSetCursor (-1, 0)
    $Button10 = GUICtrlCreateButton("", 8, 96, 25, 25)
    GUICtrlSetBkColor(-1, 0x800000)
    GUICtrlSetCursor (-1, 0)
    $Button11 = GUICtrlCreateButton("", 8, 128, 25, 25)
    GUICtrlSetBkColor(-1, 0x008000)
    GUICtrlSetCursor (-1, 0)
    $Button12 = GUICtrlCreateButton("", 8, 480, 25, 25)
    GUICtrlSetBkColor(-1, 0xFFFBF0)
    GUICtrlSetCursor (-1, 0)
    $Button13 = GUICtrlCreateButton("", 8, 352, 25, 25)
    GUICtrlSetBkColor(-1, 0x00FFFF)
    GUICtrlSetCursor (-1, 0)
    $Button14 = GUICtrlCreateButton("", 8, 416, 25, 25)
    GUICtrlSetBkColor(-1, 0x99B4D1)
    GUICtrlSetCursor (-1, 0)
    $Radio1 = GUICtrlCreateRadio("Bk", 8, 16, 41, 17)
    $Radio2 = GUICtrlCreateRadio("Pc", 8, 40, 49, 17)
    GUICtrlSetState(-1, $GUI_CHECKED)
    $Label1 = GUICtrlCreateLabel("Pensize:", 56, 600, 44, 17)
    $Button15 = GUICtrlCreateButton("1", 104, 592, 41, 33)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $Button16 = GUICtrlCreateButton("2", 144, 592, 41, 33)
    GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif")
    $Button17 = GUICtrlCreateButton("3", 184, 592, 41, 33)
    GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
    $Button18 = GUICtrlCreateButton("4", 224, 592, 41, 33)
    GUICtrlSetFont(-1, 25, 400, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)

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

    #EndRegion ### END Koda GUI section ###
    opt("mousecoordmode", 2)
    $i = 0
    $color = "0x000000"
    $bg = "0x000000"
    dim $mouseposx[1]
    dim $mouseposy[1]
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE

    Exit
    case $button1
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0x000000)
    else
    $color = 0x000000
    EndIf

    case $button2
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0x808080)
    else
    $color = 0x808080
    EndIf

    case $button3
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0xC0C0C0)
    else
    $color = 0xC0C0C0
    Endif

    case $button4
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0xFF0000)
    else
    $color = 0xFF0000
    Endif
    case $button5
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0xFFFF00)
    else
    $color = 0xFFFF00
    EndIf

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

    case $button6
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0x0000FF)
    else
    $color = 0x0000FF
    Endif
    case $button7
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0x00FF00)
    else
    $color = 0x00FF00
    Endif
    case $button8
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0x3399FF)
    else
    $color = 0x3399FF
    Endif
    case $button9
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0x800080)
    else
    $color = 0x800080
    Endif
    case $button10
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0x800000)
    else
    $color = 0x800000
    Endif
    case $button11
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0x008000)
    else
    $color = 0x008000
    Endif
    case $button12
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0xFFFBF0)
    else
    $color = 0xFFFBF0
    Endif
    case $button13
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0x00FFFF)
    else
    $color = 0x00FFFF
    Endif
    case $button14
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0x99B4D1)
    else
    $color = 0x99B4D1
    Endif
    EndSwitch
    if _ispressed("01") then
    if 575 >= mousegetpos(0) and mousegetpos(0) >= 75 and 30 <= mousegetpos(1) And mousegetpos(1) <= 530 Then
    _arrayadd($mouseposx, mousegetpos(0))
    _arrayadd($mouseposy, mousegetpos(1))

    guictrlcreategraphic($mouseposx[$i], $mouseposy[$i], 10, 10)
    guictrlsetbkcolor(-1, $color)
    $i = $i + 1
    endif
    EndIf
    WEnd

    [/autoit]

    Ich hoffe auf eine schnelle Antwort,
    vg
    RapIT

  • Was ist das denn genau, die Erklärungen bei google verstehe ich nicht. Und was bewirkt das genau?

    Hier noch mal etwas verbessert...

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <misc.au3>
    #include <WindowsConstants.au3>
    #include <Array.au3>
    active()
    Func active()
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 600, 600)
    $MenuItem1 = GUICtrlCreateMenu("Datei")
    $MenuItem2 = GUICtrlCreateMenuItem("Neu", $MenuItem1)
    $MenuItem3 = GUICtrlCreateMenuItem("Öffnen", $MenuItem1)
    $MenuItem4 = GUICtrlCreateMenuItem("Speichern", $MenuItem1)
    $grossesweissesfeld = GUICtrlCreateGraphic(75, 30, 500, 500)
    GuiCtrlSetbkColor(-1, 0xffffff)
    $Button1 = GUICtrlCreateButton("", 8, 64, 25, 25)
    GUICtrlSetBkColor(-1, 0x000000)
    GUICtrlSetCursor (-1, 0)
    $Button2 = GUICtrlCreateButton("", 8, 384, 25, 25)
    GUICtrlSetBkColor(-1, 0x808080)
    GUICtrlSetCursor (-1, 0)
    $Button3 = GUICtrlCreateButton("", 8, 448, 25, 25)
    GUICtrlSetBkColor(-1, 0xC0C0C0)
    GUICtrlSetCursor (-1, 0)
    $Button4 = GUICtrlCreateButton("", 8, 224, 25, 25)
    GUICtrlSetBkColor(-1, 0xFF0000)
    GUICtrlSetCursor (-1, 0)
    $Button5 = GUICtrlCreateButton("", 8, 256, 25, 25)
    GUICtrlSetBkColor(-1, 0xFFFF00)
    GUICtrlSetCursor (-1, 0)
    $Button6 = GUICtrlCreateButton("", 8, 288, 25, 25)
    GUICtrlSetBkColor(-1, 0x0000FF)
    GUICtrlSetCursor (-1, 0)
    $Button7 = GUICtrlCreateButton("", 8, 160, 25, 25)
    GUICtrlSetBkColor(-1, 0x00FF00)
    GUICtrlSetCursor (-1, 0)
    $Button8 = GUICtrlCreateButton("", 8, 320, 25, 25)
    GUICtrlSetBkColor(-1, 0x3399FF)
    GUICtrlSetCursor (-1, 0)
    $Button9 = GUICtrlCreateButton("", 8, 192, 25, 25)
    GUICtrlSetBkColor(-1, 0x800080)
    GUICtrlSetCursor (-1, 0)
    $Button10 = GUICtrlCreateButton("", 8, 96, 25, 25)
    GUICtrlSetBkColor(-1, 0x800000)
    GUICtrlSetCursor (-1, 0)
    $Button11 = GUICtrlCreateButton("", 8, 128, 25, 25)
    GUICtrlSetBkColor(-1, 0x008000)
    GUICtrlSetCursor (-1, 0)
    $Button12 = GUICtrlCreateButton("", 8, 480, 25, 25)
    GUICtrlSetBkColor(-1, 0xFFFBF0)
    GUICtrlSetCursor (-1, 0)
    $Button13 = GUICtrlCreateButton("", 8, 352, 25, 25)
    GUICtrlSetBkColor(-1, 0x00FFFF)
    GUICtrlSetCursor (-1, 0)
    $Button14 = GUICtrlCreateButton("", 8, 416, 25, 25)
    GUICtrlSetBkColor(-1, 0x99B4D1)
    GUICtrlSetCursor (-1, 0)
    $Radio1 = GUICtrlCreateRadio("Bk", 8, 16, 41, 17)
    $Radio2 = GUICtrlCreateRadio("Pc", 8, 40, 49, 17)
    GUICtrlSetState(-1, $GUI_CHECKED)
    $Label1 = GUICtrlCreateLabel("Pensize:", 56, 600, 44, 17)
    $Button15 = GUICtrlCreateButton("1", 104, 592, 41, 33)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $Button16 = GUICtrlCreateButton("2", 144, 592, 41, 33)
    GUICtrlSetFont(-1, 15, 400, 0, "MS Sans Serif")
    $Button17 = GUICtrlCreateButton("3", 184, 592, 41, 33)
    GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
    $Button18 = GUICtrlCreateButton("4", 224, 592, 41, 33)
    GUICtrlSetFont(-1, 25, 400, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)

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

    #EndRegion ### END Koda GUI section ###
    opt("mousecoordmode", 2)

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

    $i = 0
    $color = "0x000000"
    $bg = "0x000000"
    dim $mouseposx[1]
    dim $mouseposy[1]
    dim $pixel[1]
    While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE

    Exit
    case $button1
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0x000000)
    else
    $color = 0x000000
    EndIf

    case $button2
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0x808080)
    else
    $color = 0x808080
    EndIf

    case $button3
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0xC0C0C0)
    else
    $color = 0xC0C0C0
    Endif

    case $button4
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0xFF0000)
    else
    $color = 0xFF0000
    Endif
    case $button5
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0xFFFF00)
    else
    $color = 0xFFFF00
    EndIf

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

    case $button6
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0x0000FF)
    else
    $color = 0x0000FF
    Endif
    case $button7
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0x00FF00)
    else
    $color = 0x00FF00
    Endif
    case $button8
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0x3399FF)
    else
    $color = 0x3399FF
    Endif
    case $button9
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0x800080)
    else
    $color = 0x800080
    Endif
    case $button10
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0x800000)
    else
    $color = 0x800000
    Endif
    case $button11
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0x008000)
    else
    $color = 0x008000
    Endif
    case $button12
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0xFFFBF0)
    else
    $color = 0xFFFBF0
    Endif
    case $button13
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0x00FFFF)
    else
    $color = 0x00FFFF
    Endif
    case $button14
    if GuiCtrlRead($Radio1) = 1 Then
    GUICtrlSetBkColor($grossesweissesfeld, 0x99B4D1)
    else
    $color = 0x99B4D1
    Endif
    Case $Menuitem2
    guidelete("Form1")
    active()
    EndSwitch
    if _ispressed("01") then
    if 575 >= mousegetpos(0) and mousegetpos(0) >= 75 and 30 <= mousegetpos(1) And mousegetpos(1) <= 530 Then
    _arrayadd($mouseposx, mousegetpos(0))
    _arrayadd($mouseposy, mousegetpos(1))

    _arrayadd($pixel, guictrlcreategraphic($mouseposx[$i], $mouseposy[$i], 5, 5))
    guictrlsetbkcolor(-1, $color)
    $i = $i + 1
    endif
    EndIf
    WEnd
    EndFunc

    [/autoit]
  • Hi,
    du kannst mit der interpolation die lücken in der linie schließen.

    Beispiel:
    du hast 2 Koordinaten
    x0: 2 y0: 5
    x1: 4 y1: 3
    Formel:
    f(x)=f0+((f1-f0)/(x1-x0))*(x-x0)

    Ges: y bei x = 3
    y = 2 +((3-5)/(4-2))*(3-2)

  • ach ja falls du Punkte in die y richtung interpolieren willst einfach x und y vertauschen.