• Ich hab hier im Forum schon einige Fraktal-Scripts gesehen, und da wollte ich es einmal selbst versuchen. :)
    Diese 4 Programme sind dabei herausgekommen, ich würde mich über Rückmeldungen freuen ;).
    Für jedes Script wird die GDIP.au3 benötigt, da ich es für blödsinnig hielt so viele Funktionen manuell in jedes Script zu kopieren. (Falls ihr je gedacht habt, dass die standard UDF GDIPlus.au3 unvollständig scheint, werdet ihr den Download nicht bereuen ^^.)

    Drachenkurve

    http://de.wikipedia.org/wiki/Drachenkurve

    [autoit]

    #include <GDIP.au3>

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

    $iWidth = 1000
    $iHeight = 1000
    $iDistance = 50
    $iIterations = 13 ;Bitte vorsichtig erhöhen, da ALLE Koordinaten des Fraktals zum selben Zeitpunkt im Speicher sind.

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

    $hWnd = GUICreate("GDI+ Dragon-Curve | Iterations: " & $iIterations, $iWidth, $iHeight)
    GUISetState()

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

    _GDIPlus_Startup()

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

    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
    $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
    _GDIPlus_GraphicsClear($hGraphics, 0xFFFFFFFF)

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

    $hPen = _GDIPlus_PenCreate(0xFF000000, 1)
    $hPath = _GDIPlus_PathCreate()

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

    _GDIPlus_PathAddLine($hPath, 1, 0, 0, 0)
    _GDIPlus_PathAddLine($hPath, 0, 0, 0, 1)
    _GDIPlus_PathAddLine($hPath, 0, 1, 1, 1)
    _GDIPlus_PathAddLine($hPath, 1, 1, 1, 2)

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

    For $iI = 1 To $iIterations
    $aPoint = _GDIPlus_PathGetLastPoint($hPath)
    $hPathBuffer = _GDIPlus_PathClone($hPath)

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

    $hMatrix_R = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix_R, $aPoint[0], $aPoint[1])
    _GDIPlus_MatrixRotate($hMatrix_R, 90)
    _GDIPlus_MatrixTranslate($hMatrix_R, -$aPoint[0], -$aPoint[1])

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

    _GDIPlus_PathTransform($hPathBuffer, $hMatrix_R)
    _GDIPlus_PathReverse($hPathBuffer)
    _GDIPlus_PathAddPath($hPath, $hPathBuffer, False)

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

    _GDIPlus_PathDispose($hPathBuffer)
    _GDIPlus_MatrixDispose($hMatrix_R)
    Next

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

    Do
    $aBounds = _GDIPlus_PathGetWorldBounds($hPath, 0, $hPen)
    If $aBounds[2] > $aBounds[3] Then
    $nScale = ($iWidth - $iDistance * 2) / $aBounds[2]
    Else
    $nScale = ($iHeight - $iDistance * 2) / $aBounds[3]
    EndIf

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

    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixScale($hMatrix, $nScale, $nScale)
    _GDIPlus_PathTransform($hPath, $hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)

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

    $aBounds = _GDIPlus_PathGetWorldBounds($hPath, 0, $hPen)
    Until Abs(($iWidth - $iDistance * 2) - $aBounds[2]) <= 10 Or Abs(($iHeight - $iDistance * 2) - $aBounds[3]) <= 10

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

    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, -$aBounds[0] + $iWidth / 2 - $aBounds[2] / 2, -$aBounds[1] + $iHeight / 2 - $aBounds[3] / 2)
    _GDIPlus_PathTransform($hPath, $hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)

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

    _GDIPlus_GraphicsDrawPath($hBuffer, $hPath, $hPen)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight)

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

    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_GraphicsDispose($hBuffer)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_Shutdown()

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

    While GUIGetMsg() <> -3
    WEnd

    [/autoit]
    Koch-Kurve

    http://de.wikipedia.org/wiki/Koch-Kurve

    [autoit]

    #include <GDIP.au3>

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

    $iWidth = 800
    $iHeight = 300
    $iDistance = 10

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

    $nAngle = 60
    $iIterations = 8 ;Bitte vorsichtig erhöhen, da ALLE Koordinaten des Fraktals zum selben Zeitpunkt im Speicher sind.

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

    $hWnd = GUICreate("GDI+ Koch-Curve | Iterations: " & $iIterations, $iWidth, $iHeight)
    GUISetState()

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

    _GDIPlus_Startup()

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

    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
    $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
    _GDIPlus_GraphicsClear($hGraphics, 0xFFFFFFFF)

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

    $hPen = _GDIPlus_PenCreate(0xFF000000, 1)
    $hPath = _GDIPlus_PathCreate()

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

    ;~ _GDIPlus_PathStartFigure($hPath)
    _GDIPlus_PathAddLine($hPath, 0, 0, 1, 0)

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

    For $iI = 1 To $iIterations
    $hPathBuffer = _GDIPlus_PathClone($hPath)

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

    $aPoint = _GDIPlus_PathGetLastPoint($hPath)
    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, $aPoint[0], $aPoint[1])
    _GDIPlus_MatrixRotate($hMatrix, -$nAngle)

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

    _GDIPlus_PathTransform($hPathBuffer, $hMatrix)
    _GDIPlus_PathAddPath($hPath, $hPathBuffer, True)
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_PathDispose($hPathBuffer)

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

    $hPathBuffer = _GDIPlus_PathClone($hPath)
    _GDIPlus_PathReverse($hPathBuffer)

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

    $aPoint = _GDIPlus_PathGetLastPoint($hPath)
    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixSetElements($hMatrix, -1, 0, 0, 1, $aPoint[0] * 2, 0)

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

    _GDIPlus_PathTransform($hPathBuffer, $hMatrix)
    _GDIPlus_PathAddPath($hPath, $hPathBuffer, True)
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_PathDispose($hPathBuffer)
    Next

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

    ;~ _GDIPlus_PathCloseFigure($hPath)

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

    Do
    $aBounds = _GDIPlus_PathGetWorldBounds($hPath, 0, $hPen)
    If $aBounds[2] > $aBounds[3] Then
    $nScale = ($iWidth - $iDistance * 2) / $aBounds[2]
    Else
    $nScale = ($iHeight - $iDistance * 2) / $aBounds[3]
    EndIf

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

    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixScale($hMatrix, $nScale, $nScale)
    _GDIPlus_PathTransform($hPath, $hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)

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

    $aBounds = _GDIPlus_PathGetWorldBounds($hPath, 0, $hPen)
    Until Abs(($iWidth - $iDistance * 2) - $aBounds[2]) <= 10 Or Abs(($iHeight - $iDistance * 2) - $aBounds[3]) <= 10

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

    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, -$aBounds[0] + $iWidth / 2 - $aBounds[2] / 2, -$aBounds[1] + $iHeight / 2 - $aBounds[3] / 2)
    _GDIPlus_PathTransform($hPath, $hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)

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

    _GDIPlus_GraphicsDrawPath($hBuffer, $hPath, $hPen)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight)

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

    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_GraphicsDispose($hBuffer)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_Shutdown()

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

    While GUIGetMsg() <> -3
    WEnd

    [/autoit]
    Sierpinski-Dreieck

    http://de.wikipedia.org/wiki/Sierpinski-Dreieck

    [autoit]

    #include <GDIP.au3>
    #include <Array.au3>

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

    $iWidth = 800
    $iHeight = 800

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

    $iIterations = 8 ;Bitte vorsichtig erhöhen, da ALLE Koordinaten des Fraktals zum selben Zeitpunkt im Speicher sind.

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

    $hWnd = GUICreate("GDI+ Sierpinski-Triangle | Iterations: " & $iIterations, $iWidth, $iHeight)
    GUISetState()

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

    _GDIPlus_Startup()

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

    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
    $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
    _GDIPlus_GraphicsSetPixelOffsetMode($hGraphics, 2)
    _GDIPlus_GraphicsClear($hBuffer, 0xFFFFFFFF)

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

    $hBrush = _GDIPlus_BrushCreateSolid()

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

    Global $aCoord[3 ^ ($iIterations + 1) + 1][2] = [[3]]
    $aCoord[1][0] = 0
    $aCoord[1][1] = 0
    $aCoord[2][0] = $iWidth
    $aCoord[2][1] = 0
    $aCoord[3][0] = $iWidth / 2
    $aCoord[3][1] = Sqrt($iWidth ^ 2 - ($iWidth / 2) ^ 2)

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

    For $iI = 1 To $iIterations
    $aOld = $aCoord
    $aCoord[0][0] = 0
    For $i = 1 To $aOld[0][0] Step 3
    $nTriBX = $aOld[$i + 2][0] - $aOld[$i][0]
    $nTriCX = ($aOld[$i + 2][0] - $aOld[$i][0]) / 2
    $nTriCY = ($aOld[$i + 2][1] - $aOld[$i][1]) / 2

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

    $aCoord[0][0] += 1
    $aCoord[$aCoord[0][0]][0] = $aOld[$i][0]
    $aCoord[$aCoord[0][0]][1] = $aOld[$i][1]

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

    $aCoord[0][0] += 1
    $aCoord[$aCoord[0][0]][0] = $aOld[$i][0] + $nTriBX
    $aCoord[$aCoord[0][0]][1] = $aOld[$i][1]

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

    $aCoord[0][0] += 1
    $aCoord[$aCoord[0][0]][0] = $aOld[$i][0] + $nTriCX
    $aCoord[$aCoord[0][0]][1] = $aOld[$i][1] + $nTriCY

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

    $aCoord[0][0] += 1
    $aCoord[$aCoord[0][0]][0] = $aOld[$i][0] + $nTriBX
    $aCoord[$aCoord[0][0]][1] = $aOld[$i][1]

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

    $aCoord[0][0] += 1
    $aCoord[$aCoord[0][0]][0] = $aOld[$i + 1][0]
    $aCoord[$aCoord[0][0]][1] = $aOld[$i][1]

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

    $aCoord[0][0] += 1
    $aCoord[$aCoord[0][0]][0] = $aOld[$i][0] + $nTriBX + $nTriCX
    $aCoord[$aCoord[0][0]][1] = $aOld[$i][1] + $nTriCY

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

    $aCoord[0][0] += 1
    $aCoord[$aCoord[0][0]][0] = $aOld[$i][0] + $nTriCX
    $aCoord[$aCoord[0][0]][1] = $aOld[$i][1] + $nTriCY

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

    $aCoord[0][0] += 1
    $aCoord[$aCoord[0][0]][0] = $aOld[$i][0] + $nTriBX + $nTriCX
    $aCoord[$aCoord[0][0]][1] = $aOld[$i][1] + $nTriCY

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

    $aCoord[0][0] += 1
    $aCoord[$aCoord[0][0]][0] = $aOld[$i + 2][0]
    $aCoord[$aCoord[0][0]][1] = $aOld[$i + 2][1]
    Next
    Next

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

    Dim $aTmp[4][2] = [[3]]
    For $i = 1 To $aCoord[0][0] Step 3
    $aTmp[1][0] = $aCoord[$i][0]
    $aTmp[1][1] = $iHeight - $aCoord[$i][1]
    $aTmp[2][0] = $aCoord[$i + 1][0]
    $aTmp[2][1] = $iHeight - $aCoord[$i + 1][1]
    $aTmp[3][0] = $aCoord[$i + 2][0]
    $aTmp[3][1] = $iHeight - $aCoord[$i + 2][1]
    _GDIPlus_GraphicsFillPolygon($hBuffer, $aTmp, $hBrush)
    Next

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

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $iWidth, $iHeight)

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

    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_GraphicsDispose($hBuffer)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_Shutdown()

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

    While GUIGetMsg() <> -3
    WEnd

    [/autoit]
    Sierpinski-Dreieck v2.0

    Diese Version basiert auf der verarbeitung von Bitmaps in einem IFS. D.h. es können auch Bilder oder Ellipsen als Grundobjekt zur Konstruktion des Fraktals verwendet werden (dazu muss lediglich eine Zeile im Code verändert werden). Die entsprechende Stelle findet ihr in Zeile 22-24.

    [autoit]

    #include <GDIP.au3>

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

    $iWidth = 1150
    $iHeight = Sqrt($iWidth ^ 2 - ($iWidth / 2) ^ 2)
    $iIterations = 5 ;Bitte vorsichtig erhöhen, da ALLE Koordinaten des Fraktals zum selben Zeitpunkt im Speicher sind.

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

    $hWnd = GUICreate("GDI+ Sierpinski-Triangle | Iterations: " & $iIterations, $iWidth, $iHeight)
    GUISetState()

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

    _GDIPlus_Startup()

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

    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    $hBitmap1 = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
    $hBitmap2 = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
    $hBuffer1 = _GDIPlus_ImageGetGraphicsContext($hBitmap1)
    $hBuffer2 = _GDIPlus_ImageGetGraphicsContext($hBitmap2)
    _GDIPlus_GraphicsSetSmoothingMode($hBuffer1, 2)
    _GDIPlus_GraphicsSetInterpolationMode($hBuffer1, 2)
    _GDIPlus_GraphicsSetInterpolationMode($hBuffer2, 2)
    _GDIPlus_GraphicsClear($hGraphics, 0xFFFFFFFF)

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

    ;~ Dim $aPoints[4][2] = [[3],[0, 0],[$iWidth, 0],[$iWidth / 2, $iHeight]]
    ;~ _GDIPlus_GraphicsFillPolygon($hBuffer1, $aPoints)
    _GDIPlus_GraphicsFillEllipse($hBuffer1, $iWidth / 2 - $iHeight / 2, 0, $iHeight, $iHeight) ;Durch beliebige geometrische Figur ersetzen. Bilder sind auch möglich.

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

    For $iI = 1 To $iIterations
    If Mod($iI, 2) Then
    $hBuffer = $hBuffer2
    $hBitmap = $hBitmap1
    Else
    $hBuffer = $hBuffer1
    $hBitmap = $hBitmap2
    EndIf
    _GDIPlus_GraphicsClear($hBuffer, 0)
    _GDIPlus_GraphicsDrawImageRect($hBuffer, $hBitmap, 0, 0, $iWidth / 2, $iHeight / 2)
    _GDIPlus_GraphicsDrawImageRect($hBuffer, $hBitmap, $iWidth / 2, 0, $iWidth / 2, $iHeight / 2)
    _GDIPlus_GraphicsDrawImageRect($hBuffer, $hBitmap, $iWidth / 4, $iHeight / 2, $iWidth / 2, $iHeight / 2)
    Next

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

    If Mod($iIterations + 1, 2) Then
    $hBuffer = $hBuffer2
    $hBitmap = $hBitmap1
    Else
    $hBuffer = $hBuffer1
    $hBitmap = $hBitmap2
    EndIf
    _GDIPlus_GraphicsTranslateTransform($hGraphics, $iWidth / 2, $iHeight / 2)
    _GDIPlus_GraphicsRotateTransform($hGraphics, 180)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, -$iWidth / 2, -$iHeight / 2, $iWidth, $iHeight)

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

    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_GraphicsDispose($hBuffer1)
    _GDIPlus_GraphicsDispose($hBuffer2)
    _GDIPlus_BitmapDispose($hBitmap1)
    _GDIPlus_BitmapDispose($hBitmap2)
    _GDIPlus_Shutdown()

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

    While GUIGetMsg() <> -3
    WEnd

    [/autoit]


    Jedes dieser Fraktale wird nach dem IFS Prinzip generiert. (Das Grundobjekt wird durch eine endliche Anzahl von Funktionen, die aus einer Matrix und einem Verschiebungsvektor bestehen jeweils kopiert, dann verkleinert, rotiert und verschoben. Dieser Vorgang wird je nach gewünschter Iterationstiefe beliebig oft wiederholt.) Dabei macht man sich die Selbstähnlichkeit der Fraktale zunutze.

  • Farktale finde ich immer nice anzuschauen :).

    Andy hat mir ein Schnitzel gebacken aber da war ein Raupi drauf und bevor Oscar das Bugfixen konnte kam Alina und gab mir ein AspirinJunkie.

  • Sehr nice,
    aber der Speicherverbrauch ist gewaltig, sobald man die Iterationen etwas erhöht.
    Imho hat UEZ da auch mal Beispiele gemacht, allerdings sieht man bei ihm das "Zeichnen". Habe jetzt keine Ahnung was schneller ist, aber die Path-Funktionen sind jedenfalls sehr einfach anzuwenden!

  • Zitat von name22

    Dann leg mal los ;).


    Warum ich wenns jeder machen kann ;) Ich hab mal ein kleines Prog. zum erstellen von L-System-(Fraktalen?) gebastelt.

    Aufgebaut werden die (Fraktale?) mit dem Turtle Prinzip.

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <Array.au3>

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

    Opt("GUIOnEventMode", 1)

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

    Global $nWidth = 500
    Global $nHeight = 700

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

    $hWnd = GUICreate("Fraktal", $nWidth, $nHeight)
    GUISetOnEvent(-3, "_Exit", $hWnd)
    GUISetState()

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

    _GDIPlus_Startup()
    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($nWidth, $nHeight, $hGraphics)
    $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hBackbuffer, 2)

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

    ;; FRAKTAL MALEN!!!
    _GDIPlus_GraphicsClear($hBackbuffer, 0xFFFFFFFF)

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

    _Fraktal($hBackbuffer, "F[+F[+F]-F][-F[+F]-F]", 10, 60, 5)

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

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $nWidth, $nHeight)
    While Sleep(300)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $nWidth, $nHeight)
    WEnd

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

    Func _Exit()
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

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

    Func _Fraktal($Graphic, $action, $d, $delta, $n = 1)
    Local $pi = 3.14159265358979
    Local $Turtle_X = 250
    Local $Turtle_Y = 350
    Local $Turtle_Rot = -90

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

    Dim $aTurtleStack[1][3]
    ;; [n][0] = X
    ;; [n][1] = Y
    ;; [n][2] = Rot

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

    $tempAction = $action
    For $i = 1 To $n - 1
    $action = StringReplace($action, "F", $tempAction, 0, 1)
    Next

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

    $aActions = StringSplit($action, "", 2)

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

    For $i = 0 To UBound($aActions) - 1
    ;; Unterschiedliche Aktionen bei anderen Zeichen

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

    ;####F######
    If $aActions[$i] == "F" Then ;; <- Geht um die Länge d in Richtung $Turtle_Rot und zieht EINEN Strich
    $tempX = $Turtle_X
    $tempY = $Turtle_Y
    $Turtle_X += (Cos($Turtle_Rot * $pi / 180) * $d)
    $Turtle_Y += (Sin($Turtle_Rot * $pi / 180) * $d)
    _GDIPlus_GraphicsDrawLine($Graphic, $tempX, $tempY, $Turtle_X, $Turtle_Y)
    EndIf
    ;####f######
    If $aActions[$i] == "f" Then ;; <- Geht um dei Länge d in Richtung $Turtle_Rot und zieht KEINEN Strich
    $Turtle_X += (Cos($Turtle_Rot * $pi / 180) * $d)
    $Turtle_Y += (Sin($Turtle_Rot * $pi / 180) * $d)
    EndIf
    ;####+######
    If $aActions[$i] == "+" Then ;; <- Linksdrehung um den Winkel Delta
    $Turtle_Rot -= $delta
    EndIf
    ;####-######
    If $aActions[$i] == "-" Then ;; <- Rechtsdrehung um den Winkel Delta
    $Turtle_Rot += $delta
    EndIf
    ;####[######
    If $aActions[$i] == "[" Then ;; <- Legt den Turtle-Zustand (Position+Rotation) auf den "Stack"
    ReDim $aTurtleStack[UBound($aTurtleStack) + 1][3]
    $tempN = UBound($aTurtleStack) - 1
    $aTurtleStack[$tempN][0] = $Turtle_X
    $aTurtleStack[$tempN][1] = $Turtle_Y
    $aTurtleStack[$tempN][2] = $Turtle_Rot
    EndIf
    ;####]######
    If $aActions[$i] == "]" Then ;; <- Nimmt den Turtle-Zustand (Position+Rotation) vom "Stack"
    $tempN = UBound($aTurtleStack) - 1
    $Turtle_X = $aTurtleStack[$tempN][0]
    $Turtle_Y = $aTurtleStack[$tempN][1]
    $Turtle_Rot = $aTurtleStack[$tempN][2]
    ReDim $aTurtleStack[$tempN][3] ;; <- Löscht den letzten "Stack"-Eintrag von oben
    EndIf
    Next
    EndFunc ;==>_Fraktal

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

    In der Funktion _Fraktal (Obwohl ich jetzt lieber (Fraktal?) genommen hätte :D) könnt ihr die Einstellungen übergeben.
    Mit F geht die Turtle in die Blickrichtung und zeichnet ihren Weg. Mit f tut sie das selbe, zeichnet ihren Weg aber nicht.
    Mit + wird die Schildkröte um DELTA nach LINKS bewegt, bei - nach RECHTS.
    Durch die Klammern [ und ] wird der Status der Turtle gespeichert ([) oder wieder abgerufen (])

    Das Beispiel was ich im Moment drin hab ist nicht sonderlich schön, aber vllt könnte ihr ja was schönes draus machen und dann mit Parameterangabe hier posten ;)

    Viel Spaß damit und frohes Coden.
    BB

    PS: Wer sich fragt warum ich Fraktale immer in Klammer geschrieben hab:
    Ich bin mir nicht sicher ob man das als Fraktal bezeichnet, muss die Definition noch nachschauen ^^

    mfg BB

    "IF YOU'RE GOING TO KILL IT
    OPEN SOURCE IT!"

    by Phillip Torrone

    Zitat von Shoutbox

    [Heute, 11:16] Andy: ....böseböseböseböse....da erinnere ich mich daran, dass man den Puschelschwanz eines KaRnickels auch "Blume" nennt....ob da eins zum anderen passt? :rofl: :rofl: :rofl: :rofl:

    https://autoit.de/index.php?page…leIt#post251138

    Neon Snake

  • name22 - Ja, BB & Ich hatten mal Mandelbrot gemacht ... naja, er hat mir die Theorie erklärt, ich die Praxis gemacht (aber nur Schwarz-Nichts) und er hat das am ende noch verfeinert (Farben)
    Aber -> Super :)

    Es gibt sehr viele Leute, die glauben. Aber aus Aberglauben.
    - Blaise Pascal