Jump to content

Mandelbrot set: Difference between revisions

Added MSX Basic and True BASIC
m (Final fix: the interpolation parameter is now between 0 and 1, thickness is now a constant)
(Added MSX Basic and True BASIC)
Line 2,488:
180 GOTO 180
</syntaxhighlight>
 
==={{header|MSX Basic}}===
{{works with|MSX BASIC|any}}
{{trans|Microsoft Super Extended Color BASIC}}
<syntaxhighlight lang="qbasic">100 SCREEN 2
110 CLS
120 x1 = 256 : y1 = 192
130 i1 = -1 : i2 = 1
140 r1 = -2 : r2 = 1
150 s1 = (r2-r1)/x1 : s2 = (i2-i1)/y1
160 FOR y = 0 TO y1
170 i3 = i1+s2*y
180 FOR x = 0 TO x1
190 r3 = r1+s1*x
200 z1 = r3 : z2 = i3
210 FOR n = 0 TO 30
220 a = z1*z1 : b = z2*z2
230 IF a+b > 4 GOTO 270
240 z2 = 2*z1*z2+i3
250 z1 = a-b+r3
260 NEXT n
270 PSET (x,y),n-16*INT(n/16)
280 NEXT x
290 NEXT y
300 GOTO 300</syntaxhighlight>
{{out}}
[[File:Mandelbrot-MS-BASIC.png]]
 
==={{header|Nascom BASIC}}===
Line 2,890 ⟶ 2,917:
Pt-On(real(C),imag(C),N
End
End</syntaxhighlight>
End
 
</syntaxhighlight>
==={{header|True BASIC}}===
{{trans|Microsoft Super Extended Color BASIC}}
<syntaxhighlight lang="qbasic">SET WINDOW 0, 256, 0, 192
 
LET x1 = 256/2
LET y1 = 192/2
LET i1 = -1
LET i2 = 1
LET r1 = -2
LET r2 = 1
LET s1 = (r2-r1) / x1
LET s2 = (i2-i1) / y1
 
FOR y = 0 TO y1 STEP .05
LET i3 = i1 + s2 * y
FOR x = 0 TO x1 STEP .05
LET r3 = r1 + s1 * x
LET z1 = r3
LET z2 = i3
FOR n = 0 TO 30
LET a = z1 * z1
LET b = z2 * z2
IF a+b > 4 THEN EXIT FOR
LET z2 = 2 * z1 * z2 + i3
LET z1 = a - b + r3
NEXT n
SET COLOR n - 16*INT(n/16)
PLOT POINTS: x,y
NEXT x
NEXT y
END</syntaxhighlight>
 
==={{header|Visual BASIC for Applications on Excel}}===
{{works with|Excel 2013}}
Based on the BBC BASIC version. Create a spreadsheet with -2 to 2 in row 1 and -2 to 2 in the A column (in steps of your choosing). In the cell B2, call the function with =mandel(B$1,$A2) and copy the cell to all others in the range. Conditionally format the cells to make the colours pleasing (eg based on values, 3-color scale, min value 2 [colour red], midpoint number 10 [green] and highest value black. Then format the cells with the custom type "";"";"" to remove the numbers.
<syntaxhighlight lang="vba">Function mandel(xi As Double, yi As Double)
Function mandel(xi As Double, yi As Double)
 
maxiter = 256
Line 2,911 ⟶ 2,968:
mandel = i
End Function</syntaxhighlight>
</syntaxhighlight>
[[File:vbamandel.png]]
Edit: I don't seem to be able to upload the screenshot, so I've shared it here: https://goo.gl/photos/LkezpuQziJPAtdnd9
2,143

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.