Mandelbrot set: Difference between revisions

Content added Content deleted
(→‎{{header|Python}}: Version without Numpy added for comparison.)
No edit summary
Line 7,042: Line 7,042:


Original source: [http://seed7.sourceforge.net/algorith/graphic.htm#mandelbr]
Original source: [http://seed7.sourceforge.net/algorith/graphic.htm#mandelbr]

=={{header|SenseTalk}}==
<lang sensetalk>put 0 into oReal # Real origin
put 0 into oImag # Imaginary origin
put 0.5 into mag # Magnification

put oReal - .8 / mag into leftReal
put oImag + .5 / mag into topImag
put 1 / 200 / mag into inc

put [
(0,255,255), # aqua
(0,0,255), # blue
(255,0,255), # fuchsia
(128,128,128), # gray
(0,128,0), # green
(0,255,0), # lime
(128,0,0), # maroon
(0,0,128), # navy
(128,128,0), # olive
(128,0,128), # purple
(255,0,0), # red
(192,192,192), # silver
(0,128,128), # teal
(255,255,255), # white
(255,255,0) # yellow
] into colors

put "mandelbrot.ppm" into myFile

open file myFile for writing
write "P3" & return to file myFile # PPM file magic number
write "320 200" & return to file myFile # Width and height
write "255" & return to file myFile # Max value in color channels

put topImag into cImag
repeat with each item in 1 .. 200
put leftReal into cReal
repeat with each item in 1 .. 320
put 0 into zReal
put 0 into zImag
put 0 into count
repeat at least once until size > 2 or count = 100
put zReal squared + zImag squared * -1 into newZreal
put zReal * zImag + zReal * zImag into newZimag
put newZreal + cReal into zReal
put newZimag + cImag into zImag
put sqrt(zReal squared + zImag squared) into size
add 1 to count
end repeat
if size > 2 then # Outside the set - colorize
put item count mod 15 + 1 of colors into color
write color joined by " " to file myFile
write return to file myFile
else # Inside the set - black
write "0 0 0" & return to file myFile
end if
add inc to cReal
end repeat
subtract inc from cImag
end repeat

close file myFile
</lang>


=={{header|SequenceL}}==
=={{header|SequenceL}}==