Mandelbrot Fraktal zoomen

  • Hallo,

    ich blicke in deisem Script nicht so ganz durch aber weiß jemand wie ich hier zoomen kann. Also z.b alles doppelt so groß darstellen usw?

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>

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

    Opt("GUIOnEventMode", 1)

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

    $Form1 = GUICreate("lokster's Mandelbrot Set example", 200, 200)
    GUISetState(@SW_SHOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Bye")

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

    $user32 = DllOpen("user32.dll")
    $gdi32 = DllOpen("gdi32.dll")

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

    Mandelbrot()

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

    While 1
    Sleep(100)
    WEnd

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

    Func Bye()
    Exit
    EndFunc ;==>Bye

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

    Func pix($dc, $x, $y, $color)
    DllCall($gdi32, "long", "SetPixel", "long", $dc, "long", $x, "long", $y, "long", $color)
    EndFunc ;==>pix

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

    Func GetDC($handle)
    $dc = DllCall($user32, "int", "GetDC", "hwnd", $handle)
    Return $dc[0]
    EndFunc ;==>GetDC

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

    Func Mandelbrot()
    $dc = GetDC(WinGetHandle($Form1))

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

    $width = 200
    $height = 200
    $maxiteration = 80 ; Die Schärfe

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

    For $py = 0 To $height Step 1
    For $px = 0 To $width Step 1
    $x0 = (4 / $width) * $px - 2
    $y0 = (4 / $height) * $py - 2
    $x = $x0
    $y = $y0
    $iteration = 0

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

    While (($x * $x + $y * $y) < 4 And $iteration < $maxiteration)
    $xtemp = $x * $x - $y * $y + $x0
    $y = 2 * $x * $y + $y0
    $x = $xtemp
    $iteration += 1
    WEnd
    pix($dc, $px , $py, ($iteration / $maxiteration) * 0xFF) ; I did't had time to implement some fancy colouring
    Next
    Next
    EndFunc ;==>Mandelbrot

    [/autoit]
  • mit $width und $height (beides in der _Mandelbrot) änderst du die Größe von dem was er in die Gui reinzeichnet und wenn du width+height größer als die Ausmaße der GUI wählst dann hast du "Zoom".

  • besorg dir halt mal ne flotte Kiste ;)

    kannst ja die Schärfe runtersetzen dann siehts halt teilweise nimmer so schön aus aber nuja

  • Schneller wirds bei der gleichen Malfunktion wahrscheinlich bloß wenn man Pixel weglässt
    so in der Richtung da nimmt er (praktisch) 4 mal so große Pixel

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>

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

    Opt("GUIOnEventMode", 1)

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

    $Form1 = GUICreate("lokster's Mandelbrot Set example", 500, 500)
    GUISetState(@SW_SHOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Bye")

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

    $user32 = DllOpen("user32.dll")
    $gdi32 = DllOpen("gdi32.dll")

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

    Mandelbrot()

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

    While 1
    Sleep(100)
    WEnd

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

    Func Bye()
    Exit
    EndFunc ;==>Bye

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

    Func pix($dc, $x, $y, $color)

    DllCall($gdi32, "long", "SetPixel", "long", $dc, "long", $x, "long", $y, "long", $color)
    $x += 1
    DllCall($gdi32, "long", "SetPixel", "long", $dc, "long", $x, "long", $y, "long", $color)
    $y += 1
    DllCall($gdi32, "long", "SetPixel", "long", $dc, "long", $x, "long", $y, "long", $color)
    $x -= 1
    DllCall($gdi32, "long", "SetPixel", "long", $dc, "long", $x, "long", $y, "long", $color)
    EndFunc ;==>pix

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

    Func GetDC($handle)
    $dc = DllCall($user32, "int", "GetDC", "hwnd", $handle)
    Return $dc[0]
    EndFunc ;==>GetDC

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

    Func Mandelbrot()
    $begin = TimerInit()
    $dc = GetDC(WinGetHandle($Form1))

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

    $width = 500
    $height = 500
    $maxiteration = 80 ; Die Schärfe

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

    For $py = 0 To $height Step 2
    For $px = 0 To $width Step 2
    $x0 = (4 / $width) * $px - 2
    $y0 = (4 / $height) * $py - 2
    $x = $x0
    $y = $y0
    $iteration = 0

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

    While (($x * $x + $y * $y) < 4 And $iteration < $maxiteration)
    $xtemp = $x * $x - $y * $y + $x0
    $y = 2 * $x * $y + $y0
    $x = $xtemp
    $iteration += 1
    WEnd
    pix($dc, $px , $py, ($iteration / $maxiteration) * 0xFF) ; I did't had time to implement some fancy colouring
    Next
    Next
    $dif = TimerDiff($begin)
    MsgBox(0,"Time Difference",$dif)
    EndFunc ;==>Mandelbrot

    [/autoit]

    Einmal editiert, zuletzt von mehrsolala (21. Januar 2009 um 16:38)

  • Oder du berechnest bloß den gezoomten Ausschnitt

    Edith nach Bugfixing:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>

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

    Opt("GUIOnEventMode", 1)

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

    $Form1 = GUICreate("lokster's Mandelbrot Set example", 800, 800)
    GUISetState(@SW_SHOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Bye")

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

    $user32 = DllOpen("user32.dll")
    $gdi32 = DllOpen("gdi32.dll")

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

    $scale = 5 ; x-fache Vergrößerung
    $startx = 200 ; [optional] Start des Ausschnitt auf der X-Achse (in Pixeln)
    $endx = 400 ; [optional] Ende des Ausschnitt auf der X-Achse (in Pixeln)
    $starty = 200 ; [optional] Start des Ausschnitt auf der Y-Achse (in Pixeln)
    $endy = 400 ; [optional] Ende des Ausschnitt auf der Y-Achse (in Pixeln)
    Mandelbrot($scale, $startx, $endx, $starty, $endy)

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

    While 1
    Sleep(100)
    WEnd

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

    Func Bye()
    Exit
    EndFunc ;==>Bye

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

    Func pix($dc, $x, $y, $color)
    DllCall($gdi32, "long", "SetPixel", "long", $dc, "long", $x, "long", $y, "long", $color)
    EndFunc ;==>pix

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

    Func GetDC($handle)
    $dc = DllCall($user32, "int", "GetDC", "hwnd", $handle)
    Return $dc[0]
    EndFunc ;==>GetDC

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

    Func Mandelbrot($mscale, $selectionstartx = 0, $selectionendx = Default, $selectionstarty = 0, $selectionendy = Default)
    $begin = TimerInit()
    $dc = GetDC(WinGetHandle($Form1))
    $width = 100*$mscale
    $height = 100*$mscale
    $maxiteration = 80 ; Die Schärfe
    If $selectionendx = Default Then $selectionendx = 100*$mscale
    If $selectionendy = Default Then $selectionendy = 100*$mscale
    For $py = $selectionstarty To $selectionendy Step 1
    For $px = $selectionstartx To $selectionendx Step 1
    $x0 = (4 / $width) * $px - 2
    $y0 = (4 / $height) * $py - 2
    $x = $x0
    $y = $y0
    $iteration = 0

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

    While (($x * $x + $y * $y) < 4 And $iteration < $maxiteration)
    $xtemp = $x * $x - $y * $y + $x0
    $y = 2 * $x * $y + $y0
    $x = $xtemp
    $iteration += 1
    WEnd
    $spx = $px - $selectionstartx
    $spy = $py - $selectionstarty
    pix($dc, $spx , $spy, ($iteration / $maxiteration) * 0xFF) ; I did't had time to implement some fancy colouring
    Next
    Next
    $dif = TimerDiff($begin)
    MsgBox(0,"Time Difference",$dif)
    EndFunc ;==>Mandelbrot

    [/autoit]

    2 Mal editiert, zuletzt von mehrsolala (21. Januar 2009 um 16:37)

  • Danke für deine Hilfe Mehrsolala :thumbup:

    Hier für diejenigen die es nicht ausprobieren möchten^^ :

    [Blockierte Grafik: http://download.lima-city.de/deepred/Bilder/133925055909335436.jpg]


    So aber wenn ich darüber mit einem Fenster fahre dann werden die meisten Stellen "wegradiert" :

    [Blockierte Grafik: http://download.lima-city.de/deepred/Bilder/670717264641336921.jpg]

  • und wenn du zu nem anderen fenster und wieder zurückwechselst isses ganz weg :)
    (liegt aber nicht an meinem Code ^^ )

    Hab mal statt der GDI.dll GUICreateGraphic genommen das geht genauso (vielleicht sogar schneller) ist dafür aber blau statt rot (scheint die Farbe nicht richtig zu übernehmen)
    Selection hab ich nicht getestet geht aber wahrscheinlich auch.

    EDITH: DAS BROT KOMMT WENNS FERTIG IST
    und die Mausallergie ist auch weg

    [autoit]

    #include <GUIConstants.au3>

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

    Opt("GUIOnEventMode", 1)

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

    $Form1 = GUICreate("lokster's Mandelbrot Set example", 800, 800)
    $graphic = GUICtrlCreateGraphic ( 0, 0 , 700 , 700)
    ;GUICtrlSetBkColor(-1, 0xa0ffa0)
    GUISetState(@SW_SHOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Bye")

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

    $user32 = DllOpen("user32.dll")
    $gdi32 = DllOpen("gdi32.dll")

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

    $scale = 3 ; x-fache Vergrößerung
    ; $startx = 1000 ; [optional] Start des Ausschnitt auf der X-Achse (in Pixeln)
    ; $endx = 1500 ; [optional] Ende des Ausschnitt auf der X-Achse (in Pixeln)
    ; $starty = 1000 ; [optional] Start des Ausschnitt auf der Y-Achse (in Pixeln)
    ; $endy = 1500 ; [optional] Ende des Ausschnitt auf der Y-Achse (in Pixeln)
    ; Mandelbrot($scale, $startx, $endx, $starty, $endy)
    Mandelbrot($scale)
    ;GUISetState(@SW_SHOW)
    While 1
    Sleep(100)
    WEnd

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

    Func Bye()
    Exit
    EndFunc ;==>Bye

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

    Func pix($dc, $x, $y, $color)
    GUICtrlSetGraphic($graphic, $GUI_GR_COLOR, $color)
    GUICtrlSetGraphic($graphic, $GUI_GR_DOT, $x, $y)
    ;DllCall($gdi32, "long", "SetPixel", "long", $dc, "long", $x, "long", $y, "long", $color)
    EndFunc ;==>pix

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

    Func GetDC($handle)
    $dc = DllCall($user32, "int", "GetDC", "hwnd", $handle)
    Return $dc[0]
    EndFunc ;==>GetDC

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

    Func Mandelbrot($mscale, $selectionstartx = 0, $selectionendx = Default, $selectionstarty = 0, $selectionendy = Default)
    $begin = TimerInit()
    $dc = GetDC(WinGetHandle($Form1))
    $width = 100*$mscale
    $height = 100*$mscale
    $maxiteration = 80 ; Die Schärfe
    If $selectionendx = Default Then $selectionendx = 100*$mscale
    If $selectionendy = Default Then $selectionendy = 100*$mscale
    For $py = $selectionstarty To $selectionendy Step 1
    For $px = $selectionstartx To $selectionendx Step 1
    $x0 = (4 / $width) * $px - 2
    $y0 = (4 / $height) * $py - 2
    $x = $x0
    $y = $y0
    $iteration = 0

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

    While (($x * $x + $y * $y) < 4 And $iteration < $maxiteration)
    $xtemp = $x * $x - $y * $y + $x0
    $y = 2 * $x * $y + $y0
    $x = $xtemp
    $iteration += 1
    WEnd
    $spx = $px - $selectionstartx
    $spy = $py - $selectionstarty
    pix($dc, $spx , $spy, ($iteration / $maxiteration) * 0xFF) ; I did't had time to implement some fancy colouring
    Next
    Next

    $dif = TimerDiff($begin)
    GUICtrlSetGraphic($graphic, $GUI_GR_REFRESH)
    MsgBox(0,"Time Difference",$dif)
    EndFunc ;==>Mandelbrot

    [/autoit]

    Einmal editiert, zuletzt von mehrsolala (21. Januar 2009 um 17:38)

  • Hm schon möglich mit sehr hoher Skalierung, dem richtigen Bildausschnitt und kannenweise Kaffee geht das denk ich. Allerdings müste man das 'fancy colouring', das der Herr von dem der Code ursprünglich ist, schon weggelassen hat, noch hinzufügen.

    LoL n 33 MB-Bild und ich wundere mich was mit der Leitung los bzw. was bplaced fürn lahmer Hoster ist. :pinch:

  • Und das in nur 1285852 msec :sleeping: (Hatte mich da aber auch mit den Selections vertan und bissl Zeug berechnet was ni dargestellt werden konnte weil außerhalb der GUI/Graphic-Zone)
    beim zweiten Versuch warens dann bloß noch 426243
    Code dazu

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <Array.au3>

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

    Opt("GUIOnEventMode", 1)

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

    $Form1 = GUICreate("lokster's Mandelbrot Set example", 1280, 900)
    $graphic = GUICtrlCreateGraphic ( 0, 0 , 1280 , 900)
    ;GUICtrlSetBkColor(-1, 0xa0ffa0)
    GUISetState(@SW_SHOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Bye")

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

    $user32 = DllOpen("user32.dll")
    $gdi32 = DllOpen("gdi32.dll")

    #cs
    $scale = 60 ; x-fache Vergrößerung
    $startx = 2220 ; [optional] Start des Ausschnitt auf der X-Achse (in Pixeln)
    $endx = 3600 ; [optional] Ende des Ausschnitt auf der X-Achse (in Pixeln)
    $starty = 1000 ; [optional] Start des Ausschnitt auf der Y-Achse (in Pixeln)
    $endy = 1900 ; [optional] Ende des Ausschnitt auf der Y-Achse (in Pixeln)
    #ce
    $scale = 100 ; x-fache Vergrößerung
    $startx = 4000 ; [optional] Start des Ausschnitt auf der X-Achse (in Pixeln)
    $endx = 5280 ; [optional] Ende des Ausschnitt auf der X-Achse (in Pixeln)
    $starty = 2170 ; [optional] Start des Ausschnitt auf der Y-Achse (in Pixeln)
    $endy = 3070 ; [optional] Ende des Ausschnitt auf der Y-Achse (in Pixeln)
    $i = 0
    Global $colourr[100]
    $colourr[0] = 'lala'
    Mandelbrot($scale, $startx, $endx, $starty, $endy)
    ; Mandelbrot($scale)
    GUISetState(@SW_SHOW)
    While 1
    Sleep(100)
    WEnd

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

    Func Bye()
    Exit
    EndFunc ;==>Bye

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

    Func pix($dc, $x, $y, $color)
    GUICtrlSetGraphic($graphic, $GUI_GR_COLOR, $color)
    GUICtrlSetGraphic($graphic, $GUI_GR_DOT, $x, $y)
    #cs
    For $y1 = $y To $y + 9 Step 1
    For $x1 = $x To $x + 9 Step 1
    GUICtrlSetGraphic($graphic, $GUI_GR_DOT, $x1, $y1)
    Next
    Next
    #ce
    ;DllCall($gdi32, "long", "SetPixel", "long", $dc, "long", $x, "long", $y, "long", $color)
    EndFunc ;==>pix

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

    Func GetDC($handle)
    $dc = DllCall($user32, "int", "GetDC", "hwnd", $handle)
    Return $dc[0]
    EndFunc ;==>GetDC

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

    Func Mandelbrot($mscale, $selectionstartx = 0, $selectionendx = Default, $selectionstarty = 0, $selectionendy = Default)
    $begin = TimerInit()
    $dc = GetDC(WinGetHandle($Form1))
    $Zeile = 1
    $width = 100*$mscale
    $height = 100*$mscale
    $maxiteration = 200 ; Die Schärfe
    If $selectionendx = Default Then $selectionendx = 100*$mscale
    If $selectionendy = Default Then $selectionendy = 100*$mscale
    #cs
    For $py = $selectionstarty To $selectionendy Step 10
    For $px = $selectionstartx To $selectionendx Step 10
    #ce
    For $py = $selectionstarty To $selectionendy Step 1
    For $px = $selectionstartx To $selectionendx Step 1
    $x0 = (4 / $width) * $px - 2
    $y0 = (4 / $height) * $py - 2
    $x = $x0
    $y = $y0
    $iteration = 0

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

    While (($x * $x + $y * $y) < 4 And $iteration < $maxiteration)
    $xtemp = $x * $x - $y * $y + $x0
    $y = 2 * $x * $y + $y0
    $x = $xtemp
    $iteration += 1
    WEnd
    $spx = $px - $selectionstartx
    $spy = $py - $selectionstarty
    $colour = ($iteration / $maxiteration) * 0xFFFF
    pix($dc, $spx , $spy, $colour) ; I did't had time to implement some fancy colouring
    ;if $Zeile > 39 AND $spx > 590 AND $spx < 610 Then
    ; $colourr[$i] = ($iteration / $maxiteration) * 0xFF
    ; $i = $i + 1
    ; ;MsgBox(0,"Time Difference",'')
    ;EndIf
    Next
    $Zeile += 1
    if $Zeile > 20 Then
    GUICtrlSetGraphic($graphic, $GUI_GR_REFRESH)
    $Zeile = 1
    EndIf
    Next

    $dif = TimerDiff($begin)
    GUICtrlSetGraphic($graphic, $GUI_GR_REFRESH)
    ;_ArrayDisplay($colourr)
    MsgBox(0,"Time Difference",$dif)
    EndFunc ;==>Mandelbrot

    [/autoit]


    autoit.de/wcf/attachment/3724/

    2 Mal editiert, zuletzt von mehrsolala (21. Januar 2009 um 22:45)

  • na das ist ja mal ne richtig nette idee!
    da muss ich mich auchmal dran versuchen :)

    ps: respekt an euch und den urheber ;)

    edit:

    also da mir das echt zu lange dauert 10 minuten auf das bild zu warten ^^
    hier bissle geändert
    dauert jetzt bei mir nurnoch 5 min bei gleicher scalierung

    Spoiler anzeigen
    [autoit]

    #cs ----------------------------------------------------------------------------

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

    AutoIt Version: 3.2.12.1
    Author: myName

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

    Script Function:
    Template AutoIt script.

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

    #ce ----------------------------------------------------------------------------

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

    ; Script Start - Add your code below here

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

    #include <GUIConstants.au3>
    #include <Array.au3>

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

    Opt("GUIOnEventMode", 1)

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

    $Form1 = GUICreate("lokster's Mandelbrot Set example", 1280, 900)
    $graphic = GUICtrlCreateGraphic ( 0, 0 , 1280 , 900)
    ;GUICtrlSetBkColor(-1, 0xa0ffa0)
    ;GUISetState(@SW_SHOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Bye")

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

    $user32 = DllOpen("user32.dll")
    $gdi32 = DllOpen("gdi32.dll")

    #cs
    $scale = 60 ; x-fache Vergrößerung
    $startx = 2220 ; [optional] Start des Ausschnitt auf der X-Achse (in Pixeln)
    $endx = 3600 ; [optional] Ende des Ausschnitt auf der X-Achse (in Pixeln)
    $starty = 1000 ; [optional] Start des Ausschnitt auf der Y-Achse (in Pixeln)
    $endy = 1900 ; [optional] Ende des Ausschnitt auf der Y-Achse (in Pixeln)
    #ce
    $scale = 100 ; x-fache Vergrößerung
    $startx = 4000 ; [optional] Start des Ausschnitt auf der X-Achse (in Pixeln)
    $endx = 5280 ; [optional] Ende des Ausschnitt auf der X-Achse (in Pixeln)
    $starty = 2170 ; [optional] Start des Ausschnitt auf der Y-Achse (in Pixeln)
    $endy = 3070 ; [optional] Ende des Ausschnitt auf der Y-Achse (in Pixeln)
    $i = 0
    Global $colourr[100]
    $colourr[0] = 'lala'
    Mandelbrot($scale, $startx, $endx, $starty, $endy)
    ; Mandelbrot($scale)

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

    While 1
    Sleep(100)
    WEnd

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

    Func Bye()
    Exit
    EndFunc ;==>Bye

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

    Func pix($dc, $x, $y, $color)
    GUICtrlSetGraphic($graphic, $GUI_GR_COLOR, $color)
    GUICtrlSetGraphic($graphic, $GUI_GR_DOT, $x, $y)
    #cs
    For $y1 = $y To $y + 9 Step 1
    For $x1 = $x To $x + 9 Step 1
    GUICtrlSetGraphic($graphic, $GUI_GR_DOT, $x1, $y1)
    Next
    Next
    #ce
    ;DllCall($gdi32, "long", "SetPixel", "long", $dc, "long", $x, "long", $y, "long", $color)
    EndFunc ;==>pix

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

    Func GetDC($handle)
    $dc = DllCall($user32, "int", "GetDC", "hwnd", $handle)
    Return $dc[0]
    EndFunc ;==>GetDC

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

    Func Mandelbrot($mscale, $selectionstartx = 0, $selectionendx = Default, $selectionstarty = 0, $selectionendy = Default)
    $begin = TimerInit()
    $dc = GetDC(WinGetHandle($Form1))
    $Zeile = 1
    $width = 100*$mscale
    $height = 100*$mscale
    $maxiteration = 200 ; Die Schärfe
    If $selectionendx = Default Then $selectionendx = 100*$mscale
    If $selectionendy = Default Then $selectionendy = 100*$mscale
    #cs
    For $py = $selectionstarty To $selectionendy Step 10
    For $px = $selectionstartx To $selectionendx Step 10
    #ce
    For $py = $selectionstarty To $selectionendy Step 1
    For $px = $selectionstartx To $selectionendx Step 1
    $x0 = (4 / $width) * $px - 2
    $y0 = (4 / $height) * $py - 2
    $x = $x0
    $y = $y0
    $iteration = 0

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

    While (($x * $x + $y * $y) < 4 And $iteration < $maxiteration)
    $xtemp = $x * $x - $y * $y + $x0
    $y = 2 * $x * $y + $y0
    $x = $xtemp
    $iteration += 1
    WEnd
    $spx = $px - $selectionstartx
    $spy = $py - $selectionstarty
    $colour = ($iteration / $maxiteration) * 0x00ff00
    pix($dc, $spx , $spy, $colour) ; I did't had time to implement some fancy colouring
    ;if $Zeile > 39 AND $spx > 590 AND $spx < 610 Then
    ; $colourr[$i] = ($iteration / $maxiteration) * 0xFF
    ; $i = $i + 1
    ; ;MsgBox(0,"Time Difference",'')
    ;EndIf
    Next
    ; $Zeile += 1
    ; if $Zeile > 500 Then
    ; GUICtrlSetGraphic($graphic, $GUI_GR_REFRESH)
    ; $Zeile = 1
    ;EndIf
    Next

    $dif = TimerDiff($begin)
    GUISetState(@SW_SHOW)
    GUICtrlSetGraphic($graphic, $GUI_GR_REFRESH)
    ;_ArrayDisplay($colourr)
    MsgBox(0,"Time Difference",$dif)
    EndFunc ;==>Mandelbrot

    [/autoit]

    Einmal editiert, zuletzt von azunai (22. Januar 2009 um 00:10)

  • Moin,

    Sehr cool !!!

    [offtopic]
    So ein Programm habe ich mal aus einer Zeitschrit abgetippt, das war ca. 1988 (Die Zeitschrift war von 1985, glaube ich).
    Sprache: Turbo Basic XL
    System: Atari 800XL

    Auf einem 36 cm Fernseher (SW) hat es mit 4 Farben ca 36 Stunden gedauert bis es fertig war, je nachdem wie tief man eingedrungen ist.
    [/offtopic]


    Gruß
    Greenhorn


  • Moin Leuts,

    ich habe heute schon derbe geflucht, weil sämtliche 15-25 Jahre alten Disketten mit meinem MANDEL.BAS unlesbar waren. In grauer Vorzeit habe ich mit Turbo- oder Powerbasic einen feinen 4,77 Mhz IBM-PC mit 8088 und 8087 (Numerischer CoProzessor :rock: ) programmiert. Basic war für die Oberfläche, das Numbercruncen hat dann ein Inline-Assemblercode übernommen. Das Programm wurde nach der Anzahl der Takte/Schleifendurchgang optimiert. Ich weiß genau, daß die "innere" Schleife vollständig im 16 Byte-Stack des CoPro lief, d.h. Prozessor und Copro liefen Parallel^^...btw..die Platte hatte 10MB (nicht Gig^^) und Grafik war CGA (320x200x4), später EGA(640x480x16) . BS war soweit ich weiß Novell-DOS. In irgendeinem Schrank fliegt der Rechner noch rum, werde morgen mal suchen, vielleicht startet das Monster ja noch^^

    @topic
    Was in Autoit garkeinen Spass macht, ist auf das Setzen der Pixel zu warten :D

    Habe mal bissl gebastelt und das Programm erweitert, man kann nun mit Slidern während der Berechnung die Schrittweite der Pixel (nur jedes 2. oder 3. usw) und die Iterationstiefe einstellen.
    Damit man schnell "zoomen" kann wird bei einem Mausklick in die Grafik (auch während der Berechnung) eine 4-fache Vergrößerung an der Mausposition gestartet.
    Wenn man nun eine "schöne" Stelle gefunden hat, kann man diese mit voller Iterationstiefe und Schrittweite von 1 durchrechnen lassen.
    Dauert aber...^^

    Ggf. hat ja wer von den "Profis" lust, eine DLL (vielleicht in C) für die Schleife zu basteln, und so nebenbei das pixelsetzen zu beschleunigen. Habe beim googeln das da gefunden, aber von "pointern" wollte ich schon früher nix wissen^^

    ciao
    .Andy

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <Misc.au3>
    #include <GuiSlider.au3>

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

    Opt("GUIOnEventMode", 1)
    opt("MouseCoordMode",0)

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

    Global $width, $height, $dc , $centerx, $centery, $start, $btnstartpressed, $cx,$cy,$centerx1,$centery1,$st,$st1,$start1
    global $step, $mousepressed, $maxiteration
    $user32 = DllOpen("user32.dll")
    $gdi32 = DllOpen("gdi32.dll")

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

    $width = 800
    $height = 600

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

    ;Startparameter
    $maxiteration = 25 ; für 1. durchlauf, dann slider bis zu 1000
    $centerx=2
    $centery=2
    $start=4
    $step=2

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

    ;Gui
    $Form1 = GUICreate("Apfelmännchen", $width+100,$height)
    $Farbe=pixelgetcolor(30,30)
    $Label=GuiCtrlCreateLabel("",0, 0, $width+10, $height)
    $dc = GetDC(WinGetHandle($Form1))
    guictrlcreatelabel("Steps: ",$width+20,15,60)
    $stepslider=GUICtrlCreateslider($width+10,30,80,40,BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUICtrlSetLimit( -1,5,1)
    GuiCtrlSetData($stepslider, $step)
    guictrlcreatelabel("Iterationen: ",$width+20,100,60)
    $maxitslider=GUICtrlCreateslider($width+10,115,80,40,BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS, $TBS_ENABLESELRANGE))
    GUICtrlSetLimit( -1,1000,$maxiteration)
    GuiCtrlSetData($maxitslider, 25)

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

    GUISetState(@SW_SHOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Bye")
    GUISetOnEvent($GUI_EVENT_PRIMARYUP,"_mousepressed") ;beim UP der linken Maustaste die func aufrufen

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

    while 1
    $mousepressed=0
    $begin=timerinit()
    ;Mandelbrot()
    ;$paintpixel=1 ;das bild ist am entstehen
    For $py = 0 To $height Step $step
    For $px = 0 To $width Step $step
    if $Mousepressed=1 then ExitLoop ;Maustaste wurde gedrückt, marker setzen und Berechnung verlassen
    $x0 = ( $start / $width) * $px - $centerx ;die eigentliche Berechnung der Farbe des Pixels....
    $y0 = ( $start / $height) * $py - $centery
    $x = $x0
    $y = $y0
    $iteration = 0
    While (($x * $x + $y * $y) < 4 And $iteration < $maxiteration)
    $xtemp = $x * $x - $y * $y + $x0
    $y = 2 * $x * $y + $y0
    $x = $xtemp
    $iteration += 1
    WEnd

    pix($dc, $px, $py,0xFFFFFF/$maxiteration* ($maxiteration-$iteration+1) ) ;...und die Farbe an die Koordinaten....
    Next
    If $mousepressed=1 then exitloop ;Berechnung verlassen
    Next

    WinSetTitle($form1,"","Apfelmännchen :"&int(timerdiff($begin)/1000&" Sekunden ")) ;Zeit in der Titelleiste anzeigen
    If $mousepressed=0 then ;die Grafik wurde ohne Unterbrechung fertig
    ;$paintpixel=0
    while $mousepressed=0 ;solange warten, bis linke mMustaste gedrückt
    sleep (100)
    WEnd
    endif
    GuiCtrlSetBkColor($label, $farbe)

    WEnd

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

    func _mousepressed()
    $mousepressed=0 ;
    $pos = MouseGetPos() ;Koordinaten der Maus
    ;If $paintpixel=1 then ;Maustaste wurde innerhalb for/to gedrückt
    If $pos[0]<$width and $pos[1]<$height then ;wenn mauspos innerhalb Grafik dann
    $Mousepressed=1 ;Flag setzen
    $centerx=$centerx-$start*$pos[0]/$width ;neuer Anfang der Berechnung an der Mausposition für x...
    $centery=$centery-$start*($pos[1]-20)/$height ;...und y- Koordinate
    $start=$start/4 ;neue Fenstergröße willkürlich auf 1/4 des ursprünglichen Bildes
    else ;wenn Mauspos innerhalb der Gui aber nicht innerhalb der Grafik
    $Step=guictrlread($stepslider) ;steps von Slider übernehmen
    $maxiteration=guictrlread($maxitslider) ;und Maxiteration
    endif

    ;msgbox(0,"start",$centerx&@crlf&$centery&@crlf&$start)
    EndFunc

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

    Func pix($dc, $x, $y, $color) ;pixel mit farbe an koordinaten setzen
    DllCall($gdi32, "long", "SetPixel", "long", $dc, "long", $x, "long", $y, "long", $color)
    EndFunc ;==>pix

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

    Func GetDC($handle)
    $dc = DllCall($user32, "int", "GetDC", "hwnd", $handle)
    Return $dc[0]
    EndFunc ;==>GetDC

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

    Func Bye()
    Exit
    EndFunc ;==>Bye

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