View Single Post
 24 October 2010, 05:47 #21 Mequa 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: Code: ```' 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 X#=-2.0+X/81.92 Y#=1.6-Y/81.92 N=0 ZR#=0 ZI#=0 Repeat ZR0#=ZR#*ZR#-ZI#*ZI#+X# ZI#=2*ZR#*ZI#+Y# ZR#=ZR0# 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     Last edited by Mequa; 24 October 2010 at 06:16.