Fraktale Apfelmännchen

Übersicht BlitzMax, BlitzMax NG Codearchiv & Module

Neue Antwort erstellen

rema

Betreff: Fraktale Apfelmännchen

BeitragDo, Jan 12, 2006 16:04
Antworten mit Zitat
Benutzer-Profile anzeigen
Der Code ist eigentlich selbsterklärend. Viel Spass beim spielen mit dem Code...

Den Code habe ich von hier: http://www.jjam.de/Java/Applet...nchen.html

Schwarz-Weiss-Version:
Code: [AUSKLAPPEN]

Type Appleman


   Method init()
      SetClsColor(255,255,255) ' Hintergrundfrabe setzten
      SetColor(0,129,190) ' Zeichenfarbe setzen
   End Method
   

    ' C-Werte checken nach Zn+1 = Zn^2 + C, Zo = 0. 30 Iterationen.

   Method checkC( reC:Float, imC:Float )
      Local reZ:Float, imZ:Float, reZ_minus1:Float, imZ_minus1:Float
      Local i:Int
      For i=0 To 30
         imZ = 2*reZ_minus1*imZ_minus1+imC
         reZ = reZ_minus1*reZ_minus1-imZ_minus1*imZ_minus1+reC
         If (reZ*reZ+imZ*imZ>4) Return i
         reZ_minus1 = reZ
         imZ_minus1 = imZ
      Next
      Return i
   End Method

    ' Punkte berechnen und setzen.
   Method paint()
      Local reC:Float, imC:Float, zelle:Float=0.00625 ' Ein Pixel = 0.00625
      Local x:Int,y:Int
      
      imC=-1.1 ' oberer Rand
      For y=0 To 350
         reC = -2.1 ' linker Rand
         For x=0 To 440
            If (checkC(reC,imC) > 30)
               Plot (x,y)
            EndIf
            reC=reC+zelle; ' nächste Spalte
         Next
         imC=imC+zelle; ' nächste Zeile
      Next
   End Method


End Type

'--------------------------------------------------------

Graphics 440,350,0

Local ts:Int = MilliSecs()

Local apple:Appleman = New Appleman

apple.init()
apple.paint()


Print "ok: " + (MilliSecs() -ts )
Flip

WaitKey()



Farb-Version:
Code: [AUSKLAPPEN]

Type Appleman


   Method init()
      SetClsColor(255,255,255) ' Hintergrundfrabe setzten
      SetColor(0,129,190) ' Zeichenfarbe setzen

   End Method
   

    ' C-Werte checken nach Zn+1 = Zn^2 + C, Zo = 0. 30 Iterationen.

   Method checkC( reC:Float, imC:Float )
      Local reZ:Float, imZ:Float, reZ_minus1:Float, imZ_minus1:Float
      Local i:Int
      For i=0 To 30
         imZ = 2*reZ_minus1*imZ_minus1+imC
         reZ = reZ_minus1*reZ_minus1-imZ_minus1*imZ_minus1+reC
         If (reZ*reZ+imZ*imZ>4) Return i
         reZ_minus1 = reZ
         imZ_minus1 = imZ
      Next
      Return i
   End Method

    ' Punkte berechnen und setzen.

   Method paint()
      Local reC:Float, imC:Float, zelle:Float=0.00625 ' Ein Pixel = 0.00625

      Local x:Int,y:Int
      
      imC=-1.1 ' oberer Rand

      For y=0 To 350
         reC = -2.1 ' linker Rand

         For x=0 To 440
            Local result:Float = checkC(reC,imC)
            reC=reC+zelle; ' n0chste Spalte
            If result < 10
               Continue
            ElseIf result < 20
               SetColor(0,200,0)
            ElseIf result < 30
               SetColor(0,0,200)
            Else
               SetColor(200,0,0)
            EndIf
            Plot (x,y)
         Next
         
         imC=imC+zelle; ' n‰chste Zeile
      Next
   End Method


End Type

'--------------------------------------------------------

      
Graphics 440,350,0

Local ts:Int = MilliSecs()

Local apple:Appleman = New Appleman

apple.init()
apple.paint()


Print "ok: " + (MilliSecs() -ts )
Flip

WaitKey()
  • Zuletzt bearbeitet von rema am Fr, Jan 13, 2006 9:04, insgesamt 2-mal bearbeitet

Hummelpups

BeitragDo, Jan 12, 2006 20:31
Antworten mit Zitat
Benutzer-Profile anzeigen
hehe, super ;D
blucode - webdesign - Ressource - NetzwerkSim
BlitzBasic 2D - BlitzMax - MaxGUI - Monkey - BlitzPlus

Neue Antwort erstellen


Übersicht BlitzMax, BlitzMax NG Codearchiv & Module

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group