Hüpfer – Fraktale

  • Servus :)
    Ich bin auf folgende Seite gestoßen: http://www.mathematische-basteleien.de/huepfer.htm
    Das fand ich so interessant, dass ich gleich eine eigene Implantation in AutoIt schreiben musste.
    Ist nichts dolles, aber es macht Spaß damit herumzuspielen. Versucht es selber mal! ^^

    Spoiler anzeigen
    [autoit]

    ; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +

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

    #include <GDIPlus.au3>
    #include <GUIConstants.au3>

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

    Opt('GUIOnEventMode', 1)

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

    _GDIPlus_Startup()

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

    ; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +

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

    ; > Hier kannst du herumspielen! :)

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

    Global Const $iWidth = 800
    Global Const $iHeight = 600

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

    Global Const $fA = -70
    Global Const $fB = 100
    Global Const $fC = 0
    Global Const $iNum = 150000

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

    Func Term($fA, $fB, $fC, $fX, $fY)
    Return $fY - SIGN($fX) * Abs($fB * $fX - $fC) ^ 0.5
    EndFunc

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

    ; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +

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

    Global Const $fU = $iWidth / 2
    Global Const $fV = $iHeight / 2

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

    Global $hGUI, $hGraphics, $i, $fX, $fY, $fX2, $fY2

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

    ; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +

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

    $hGUI = GUICreate('Hüpfer [Make-Grafik]', $iWidth, $iHeight)
    GUISetOnEvent($GUI_EVENT_CLOSE, GUI_EVENT_CLOSE)
    GUISetState()

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

    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)

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

    _GDIPlus_GraphicsClear($hGraphics, 0xFFFFFFFF)

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

    ; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +

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

    For $i = 1 To $iNum
    _GDIPlus_GraphicsFillRect($hGraphics, $fU + $fX, $fV + $fY, 1, 1)
    $fX2 = Term($fA, $fB, $fC, $fX, $fY)
    $fY2 = $fA - $fX
    $fX = $fX2
    $fY = $fY2
    Next

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

    ConsoleWrite('! Finish' & @CRLF)

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

    While Sleep(1000)
    WEnd

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

    ; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +

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

    Func SIGN($fValue)
    If $fValue < 0 Then
    Return -1
    ElseIf $fValue > 0 Then
    Return 1
    EndIf
    EndFunc

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

    Func GUI_EVENT_CLOSE()
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc

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

    ; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +

    [/autoit]
  • Das Ganze ein bissl bunt:

    Spoiler anzeigen
    [autoit]


    ; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +

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

    #include <GDIPlus.au3>
    #include <GUIConstants.au3>

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

    Opt('GUIOnEventMode', 1)

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

    _GDIPlus_Startup()

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

    ; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +

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

    ; > Hier kannst du herumspielen! :)

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

    Global Const $iWidth = 1024
    Global Const $iHeight = 768

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

    Global Const $fA = -70
    Global Const $fB = 100
    Global Const $fC = -100
    Global Const $iNum = 100000

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

    Func Term($fA, $fB, $fC, $fX, $fY)
    Return $fY - SIGN($fX) * Abs($fB * $fX - $fC) ^ 0.5
    EndFunc

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

    ; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +

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

    Global Const $fU = $iWidth / 2
    Global Const $fV = $iHeight / 2

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

    Global $hGUI, $hGraphics, $i, $fX, $fY, $fX2, $fY2, $iR, $iG, $iB

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

    ; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +

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

    $hGUI = GUICreate('Hüpfer [Make-Grafik]', $iWidth, $iHeight)
    GUISetOnEvent($GUI_EVENT_CLOSE, GUI_EVENT_CLOSE)
    GUISetState()

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

    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBrush = _GDIPlus_BrushCreateSolid(0)

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

    _GDIPlus_GraphicsClear($hGraphics, 0xFF181818)

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

    ; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +

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

    For $i = 1 To $iNum
    _GDIPlus_GraphicsFillRect($hGraphics, $fU + $fX, $fV + $fY, 1, 1, $hBrush)
    $fX2 = Term($fA, $fB, $fC, $fX, $fY)
    $fY2 = $fA - $fX
    $fX = $fX2
    $fY = $fY2
    $iR = 0x10000 * Int(Abs($fY) > 0xFF ? 0xFF : Abs($fY))
    $iG = 0x100 * Int(Abs($fY2) > 0xFF ? 0xFF : Abs($fY2))
    $iB = Int(Abs($fX) > 0xFF ? 0xFF : Abs($fX))
    _GDIPlus_BrushSetSolidColor($hBrush, 0x80000000 + $iR + $iG + $iB)
    Next

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

    ConsoleWrite('! Finish' & @CRLF)

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

    While Sleep(1000)
    WEnd

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

    ; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +

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

    Func SIGN($fValue)
    Return ($fValue < 0 ? -1 : ($fValue > 0) ? 1 : 0)
    EndFunc

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

    Func GUI_EVENT_CLOSE()
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_Shutdown()
    Exit
    EndFunc

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

    ; ++++++++++ +++++++++ ++++++++ +++++++ ++++++ +++++ ++++ +++ ++ +

    [/autoit]

    Danke für's Teilen!

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯