View Single Post
Old 24 October 2010, 05:47   #21
Registered User
Join Date: Nov 2009
Location: UK
Posts: 497
Here's the code included with AMOS CRAFT to draw a Mandelbrot fractal in AMOS BASIC. It also demonstrates how CRAFT's built-in Mandelbrot generator works.
It should be easily portable to other forms of BASIC too.
Remember # indicates a floating point type variable, while $AA ($0AA) is a hexadecimal constant. The palette is 16 shades of turquoise:

' The slow mandelbrot by Hannu Rummukainen
' This program has been made to demonstrate the amazing effectiveness
' of the algorithms used in the CRAFT extension. The program calculates
' a picture of the Mandelbrot set in AMOS. It does the same trick as 
' the following CRAFT instructions:
' Fr Window 0
' Fr Position -16000,12800 
' Fr Step 100
' Fr Mandelbrot 16 
Screen Open 0,320,256,16,Lowres
Curs Off : Flash Off : Cls 0
Palette 0,$11,$22,$33,$44,$55,$66,$77,$88,$99,$AA,$BB,$CC,$DD,$EE,$FF
For Y=0 To 255
   For X=0 To 319
         Inc N
      Until ZR#*ZR#+ZI#*ZI#>4 or N=16
      Plot X,Y,N
   Next X
Next Y
On testing in WinUAE, the CRAFT extension instructions do give a slightly different result to the BASIC code, however:
Attached Thumbnails
Click image for larger version

Name:	AMOS_BASIC_Mandelbrot.png
Views:	131
Size:	56.2 KB
ID:	26798   Click image for larger version

Name:	AMOS_CRAFT_Mandelbrot.png
Views:	139
Size:	53.7 KB
ID:	26799  

Last edited by Mequa; 24 October 2010 at 06:16.
Mequa is offline  
AdSense AdSense  
Page generated in 0.04023 seconds with 11 queries