2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,3 +1,6 @@
|
|||
;Task:
|
||||
Generate and draw the [[wp:Mandelbrot set|Mandelbrot set]].
|
||||
|
||||
|
||||
Note that there are [http://en.wikibooks.org/wiki/Fractals/Iterations_in_the_complex_plane/Mandelbrot_set many algorithms] to draw Mandelbrot set and there are [http://en.wikibooks.org/wiki/Pictures_of_Julia_and_Mandelbrot_sets many functions] which generate it .
|
||||
<br><br>
|
||||
|
|
|
|||
15
Task/Mandelbrot-set/BASIC/mandelbrot-set-8.basic
Normal file
15
Task/Mandelbrot-set/BASIC/mandelbrot-set-8.basic
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
Function mandel(xi As Double, yi As Double)
|
||||
|
||||
maxiter = 256
|
||||
x = 0
|
||||
y = 0
|
||||
|
||||
For i = 1 To maxiter
|
||||
If ((x * x) + (y * y)) > 4 Then Exit For
|
||||
xt = xi + ((x * x) - (y * y))
|
||||
y = yi + (2 * x * y)
|
||||
x = xt
|
||||
Next
|
||||
|
||||
mandel = i
|
||||
End Function
|
||||
145
Task/Mandelbrot-set/Brainf---/mandelbrot-set.bf
Normal file
145
Task/Mandelbrot-set/Brainf---/mandelbrot-set.bf
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
A mandelbrot set fractal viewer in brainf*ck written by Erik Bosman
|
||||
+++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[
|
||||
>>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+
|
||||
<<<<<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
>+<<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+[>>>>>>[>>>>>>>[-]>>]<<<<<<<<<[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<<<<[<<<<<<<
|
||||
<<]>>>>[-]+>>>>>[>>>>>>>>>]>+<]]+>>>>>>>>[-<<<<<<<<->>>>>>>>]+<<<<<<<<[->>>>>>>>
|
||||
-<<[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+>>>>>>[>>>>>>
|
||||
>>>]>[-]+<]]+>[-<[>>>>>>>>>]<<<<<<<<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>[-]<<<++++
|
||||
+[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>->>>>>>>>>>>>>>>>>>>>>>>>>>>-<<<<<<[<<<<
|
||||
<<<<<]]>>>]
|
||||
51
Task/Mandelbrot-set/COBOL/mandelbrot-set.cobol
Normal file
51
Task/Mandelbrot-set/COBOL/mandelbrot-set.cobol
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. MANDELBROT-SET-PROGRAM.
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 COMPLEX-ARITHMETIC.
|
||||
05 X PIC S9V9(9).
|
||||
05 Y PIC S9V9(9).
|
||||
05 X-A PIC S9V9(6).
|
||||
05 X-B PIC S9V9(6).
|
||||
05 Y-A PIC S9V9(6).
|
||||
05 X-A-SQUARED PIC S9V9(6).
|
||||
05 Y-A-SQUARED PIC S9V9(6).
|
||||
05 SUM-OF-SQUARES PIC S9V9(6).
|
||||
05 ROOT PIC S9V9(6).
|
||||
01 LOOP-COUNTERS.
|
||||
05 I PIC 99.
|
||||
05 J PIC 99.
|
||||
05 K PIC 999.
|
||||
77 PLOT-CHARACTER PIC X.
|
||||
PROCEDURE DIVISION.
|
||||
CONTROL-PARAGRAPH.
|
||||
PERFORM OUTER-LOOP-PARAGRAPH
|
||||
VARYING I FROM 1 BY 1 UNTIL I IS GREATER THAN 24.
|
||||
STOP RUN.
|
||||
OUTER-LOOP-PARAGRAPH.
|
||||
PERFORM INNER-LOOP-PARAGRAPH
|
||||
VARYING J FROM 1 BY 1 UNTIL J IS GREATER THAN 64.
|
||||
DISPLAY ''.
|
||||
INNER-LOOP-PARAGRAPH.
|
||||
MOVE SPACE TO PLOT-CHARACTER.
|
||||
MOVE ZERO TO X-A.
|
||||
MOVE ZERO TO Y-A.
|
||||
MULTIPLY J BY 0.0390625 GIVING X.
|
||||
SUBTRACT 1.5 FROM X.
|
||||
MULTIPLY I BY 0.083333333 GIVING Y.
|
||||
SUBTRACT 1 FROM Y.
|
||||
PERFORM ITERATION-PARAGRAPH VARYING K FROM 1 BY 1
|
||||
UNTIL K IS GREATER THAN 100 OR PLOT-CHARACTER IS EQUAL TO '#'.
|
||||
DISPLAY PLOT-CHARACTER WITH NO ADVANCING.
|
||||
ITERATION-PARAGRAPH.
|
||||
MULTIPLY X-A BY X-A GIVING X-A-SQUARED.
|
||||
MULTIPLY Y-A BY Y-A GIVING Y-A-SQUARED.
|
||||
SUBTRACT Y-A-SQUARED FROM X-A-SQUARED GIVING X-B.
|
||||
ADD X TO X-B.
|
||||
MULTIPLY X-A BY Y-A GIVING Y-A.
|
||||
MULTIPLY Y-A BY 2 GIVING Y-A.
|
||||
SUBTRACT Y FROM Y-A.
|
||||
MOVE X-B TO X-A.
|
||||
ADD X-A-SQUARED TO Y-A-SQUARED GIVING SUM-OF-SQUARES.
|
||||
MOVE FUNCTION SQRT (SUM-OF-SQUARES) TO ROOT.
|
||||
IF ROOT IS GREATER THAN 2 THEN MOVE '#' TO PLOT-CHARACTER.
|
||||
29
Task/Mandelbrot-set/Elixir/mandelbrot-set.elixir
Normal file
29
Task/Mandelbrot-set/Elixir/mandelbrot-set.elixir
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
defmodule Mandelbrot do
|
||||
def set do
|
||||
xsize = 59
|
||||
ysize = 21
|
||||
minIm = -1.0
|
||||
maxIm = 1.0
|
||||
minRe = -2.0
|
||||
maxRe = 1.0
|
||||
stepX = (maxRe - minRe) / xsize
|
||||
stepY = (maxIm - minIm) / ysize
|
||||
Enum.each(0..ysize, fn y ->
|
||||
im = minIm + stepY * y
|
||||
Enum.map(0..xsize, fn x ->
|
||||
re = minRe + stepX * x
|
||||
62 - loop(0, re, im, re, im, re*re+im*im)
|
||||
end) |> IO.puts
|
||||
end)
|
||||
end
|
||||
|
||||
defp loop(n, _, _, _, _, _) when n>=30, do: n
|
||||
defp loop(n, _, _, _, _, v) when v>4.0, do: n-1
|
||||
defp loop(n, re, im, zr, zi, _) do
|
||||
a = zr * zr
|
||||
b = zi * zi
|
||||
loop(n+1, re, im, a-b+re, 2*zr*zi+im, a+b)
|
||||
end
|
||||
end
|
||||
|
||||
Mandelbrot.set
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
DEFINE VARIABLE print_str AS CHAR NO-UNDO INIT ''.
|
||||
DEFINE VARIABLE X1 AS DECIMAL NO-UNDO INIT 50.
|
||||
DEFINE VARIABLE Y1 AS DECIMAL NO-UNDO INIT 21.
|
||||
DEFINE VARIABLE X AS DECIMAL NO-UNDO.
|
||||
DEFINE VARIABLE Y AS DECIMAL NO-UNDO.
|
||||
DEFINE VARIABLE N AS DECIMAL NO-UNDO.
|
||||
DEFINE VARIABLE I3 AS DECIMAL NO-UNDO.
|
||||
DEFINE VARIABLE R3 AS DECIMAL NO-UNDO.
|
||||
DEFINE VARIABLE Z1 AS DECIMAL NO-UNDO.
|
||||
DEFINE VARIABLE Z2 AS DECIMAL NO-UNDO.
|
||||
DEFINE VARIABLE A AS DECIMAL NO-UNDO.
|
||||
DEFINE VARIABLE B AS DECIMAL NO-UNDO.
|
||||
DEFINE VARIABLE I1 AS DECIMAL NO-UNDO INIT -1.0.
|
||||
DEFINE VARIABLE I2 AS DECIMAL NO-UNDO INIT 1.0.
|
||||
DEFINE VARIABLE R1 AS DECIMAL NO-UNDO INIT -2.0.
|
||||
DEFINE VARIABLE R2 AS DECIMAL NO-UNDO INIT 1.0.
|
||||
DEFINE VARIABLE S1 AS DECIMAL NO-UNDO.
|
||||
DEFINE VARIABLE S2 AS DECIMAL NO-UNDO.
|
||||
|
||||
|
||||
S1 = (R2 - R1) / X1.
|
||||
S2 = (I2 - I1) / Y1.
|
||||
DO Y = 0 TO Y1 - 1:
|
||||
I3 = I1 + S2 * Y.
|
||||
DO X = 0 TO X1 - 1:
|
||||
R3 = R1 + S1 * X.
|
||||
Z1 = R3.
|
||||
Z2 = I3.
|
||||
DO N = 0 TO 29:
|
||||
A = Z1 * Z1.
|
||||
B = Z2 * Z2.
|
||||
IF A + B > 4.0 THEN
|
||||
LEAVE.
|
||||
Z2 = 2 * Z1 * Z2 + I3.
|
||||
Z1 = A - B + R3.
|
||||
END.
|
||||
print_str = print_str + CHR(62 - N).
|
||||
END.
|
||||
print_str = print_str + '~n'.
|
||||
END.
|
||||
|
||||
OUTPUT TO "C:\Temp\out.txt".
|
||||
MESSAGE print_str.
|
||||
OUTPUT CLOSE.
|
||||
|
|
@ -1,13 +1,3 @@
|
|||
constant MAX_ITERATIONS = 50;
|
||||
my $width = my $height = +(@*ARGS[0] // 30);
|
||||
|
||||
sub cut(Range $r, Int $n where $n > 1) {
|
||||
$r.min, * + ($r.max - $r.min) / ($n - 1) ... $r.max
|
||||
}
|
||||
|
||||
my @re = cut(-2 .. 1/2, $height);
|
||||
my $im = [ cut( 0 .. 5/4, $width div 2 + 1) X* 1i ];
|
||||
|
||||
constant @color_map = map ~*.comb(/../).map({:16($_)}), <
|
||||
000000 0000fc 4000fc 7c00fc bc00fc fc00fc fc00bc fc007c fc0040 fc0000 fc4000
|
||||
fc7c00 fcbc00 fcfc00 bcfc00 7cfc00 40fc00 00fc00 00fc40 00fc7c 00fcbc 00fcfc
|
||||
|
|
@ -31,27 +21,29 @@ b4fcc4 b4fcd8 b4fce8 b4fcfc b4e8fc b4d8fc b4c4fc 000070 1c0070 380070 540070
|
|||
2c402c 2c4030 2c4034 2c403c 2c4040 2c3c40 2c3440 2c3040
|
||||
>;
|
||||
|
||||
sub mandelbrot( Complex $c ) {
|
||||
my $im2 = $c.im**2;
|
||||
return 0 if ($c.re + 1)**2 + $im2 < 1/16;
|
||||
my $q = ($c.re - 1/4)**2 + $im2;
|
||||
return 0 if $q*($q + ($c.re - 1/4)) < $im2/4;
|
||||
my $z = 0i;
|
||||
for ^MAX_ITERATIONS -> $i {
|
||||
return $i + 1 if $z.re**2 + $z.im**2 > 4;
|
||||
$z = $z * $z + $c;
|
||||
constant MAX_ITERATIONS = 50;
|
||||
my $width = my $height = +(@*ARGS[0] // 31);
|
||||
|
||||
sub cut(Range $r, UInt $n where $n > 1) {
|
||||
$r.min, * + ($r.max - $r.min) / ($n - 1) ... $r.max
|
||||
}
|
||||
|
||||
my @re = cut(-2 .. 1/2, $height);
|
||||
my @im = cut( 0 .. 5/4, $width div 2 + 1) X* 1i;
|
||||
|
||||
sub mandelbrot(Complex $z is copy, Complex $c) {
|
||||
for 1 .. MAX_ITERATIONS {
|
||||
$z = $z*$z + $c;
|
||||
return $_ if $z.abs > 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
my @promises = map -> $re {
|
||||
start { [ mandelbrot($re + $_) for @$im ] }
|
||||
}, @re;
|
||||
|
||||
say "P3";
|
||||
say "$width $height";
|
||||
say "255";
|
||||
|
||||
for @promises».result {
|
||||
say @color_map[(flat .reverse, .[1..*])[^$width]];
|
||||
for @re -> $re {
|
||||
put @color_map[|.reverse, |.[1..*]][^$width] given
|
||||
my @ = map &mandelbrot.assuming(0i, *), $re «+« @im;
|
||||
}
|
||||
|
|
|
|||
20
Task/Mandelbrot-set/PowerShell/mandelbrot-set.psh
Normal file
20
Task/Mandelbrot-set/PowerShell/mandelbrot-set.psh
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
$x = $y = $i = $j = $r = -16
|
||||
$colors = [Enum]::GetValues([System.ConsoleColor])
|
||||
|
||||
while(($y++) -lt 15)
|
||||
{
|
||||
for($x=0; ($x++) -lt 84; Write-Host " " -BackgroundColor ($colors[$k -band 15]) -NoNewline)
|
||||
{
|
||||
$i = $k = $r = 0
|
||||
|
||||
do
|
||||
{
|
||||
$j = $r * $r - $i * $i -2 + $x / 25
|
||||
$i = 2 * $r * $i + $y / 10
|
||||
$r = $j
|
||||
}
|
||||
while (($j * $j + $i * $i) -lt 11 -band ($k++) -lt 111)
|
||||
}
|
||||
|
||||
Write-Host
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*REXX program generates and displays a Mandelbrot set as a character image.*/
|
||||
@ = '>=<;:9876543210/.-,+*)(''&%$#"!' /*characters used in display.*/
|
||||
/*REXX program generates and displays a Mandelbrot set as an ASCII art character image.*/
|
||||
@ = '>=<;:9876543210/.-,+*)(''&%$#"!' /*the characters used in the display. */
|
||||
Xsize = 59; minRE = -2; maxRE = +1; stepX = (maxRE-minRE) / Xsize
|
||||
Ysize = 21; minIM = -1; maxIM = +1; stepY = (maxIM-minIM) / Ysize
|
||||
|
||||
|
|
@ -11,7 +11,7 @@ Ysize = 21; minIM = -1; maxIM = +1; stepY = (maxIM-minIM) / Ysize
|
|||
zi=zr*zi*2 + im; zr=a-b+re
|
||||
end /*n*/
|
||||
|
||||
$=$ || substr(@, n+1, 1) /*append number (as a char) to $ string*/
|
||||
$=$ || substr(@, n+1, 1) /*append number (as a char) to $ string*/
|
||||
end /*x*/
|
||||
say $ /*display a line of character output.*/
|
||||
end /*y*/ /*stick a fork in it, we're all done. */
|
||||
say $ /*display a line of character output.*/
|
||||
end /*y*/ /*stick a fork in it, we're all done. */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*REXX program generates and displays a Mandelbrot set as a character image.*/
|
||||
@ = '█▓▒░@9876543210=.-,+*)(·&%$#"!' /*characters used in display.*/
|
||||
/*REXX program generates and displays a Mandelbrot set as an ASCII art character image.*/
|
||||
@ = '█▓▒░@9876543210=.-,+*)(·&%$#"!' /*the characters used in the display. */
|
||||
Xsize = 59; minRE = -2; maxRE = +1; stepX = (maxRE-minRE) / Xsize
|
||||
Ysize = 21; minIM = -1; maxIM = +1; stepY = (maxIM-minIM) / Ysize
|
||||
|
||||
|
|
@ -11,7 +11,7 @@ Ysize = 21; minIM = -1; maxIM = +1; stepY = (maxIM-minIM) / Ysize
|
|||
zi=zr*zi*2 + im; zr=a-b+re
|
||||
end /*n*/
|
||||
|
||||
$=$ || substr(@, n+1, 1) /*append number (as a char) to $ string*/
|
||||
$=$ || substr(@, n+1, 1) /*append number (as a char) to $ string*/
|
||||
end /*x*/
|
||||
say $ /*display a line of character output.*/
|
||||
end /*y*/ /*stick a fork in it, we're all done. */
|
||||
say $ /*display a line of character output.*/
|
||||
end /*y*/ /*stick a fork in it, we're all done. */
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/*REXX program generates and displays a Mandelbrot set as a character image.*/
|
||||
@ = '█▓▒░@9876543210=.-,+*)(·&%$#"!' /*characters used in display.*/
|
||||
parse arg Xsize Ysize . /*get optional args from C.L.*/
|
||||
if Xsize=='' then Xsize=linesize()-1 /*X: the linesize (less 1).*/
|
||||
if Ysize=='' then Ysize=Xsize%2 + (Xsize//2==1) /*Y: ½linesize (make it even)*/
|
||||
/*REXX program generates and displays a Mandelbrot set as an ASCII art character image.*/
|
||||
@ = '█▓▒░@9876543210=.-,+*)(·&%$#"!' /*the characters used in the display. */
|
||||
parse arg Xsize Ysize . /*obtain optional arguments from the CL*/
|
||||
if Xsize=='' then Xsize=linesize() - 1 /*X: the (usable) linesize (minus 1).*/
|
||||
if Ysize=='' then Ysize=Xsize%2 + (Xsize//2==1) /*Y: half the linesize (make it even).*/
|
||||
minRE = -2; maxRE = +1; stepX = (maxRE-minRE) / Xsize
|
||||
minIM = -1; maxIM = +1; stepY = (maxIM-minIM) / Ysize
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ minIM = -1; maxIM = +1; stepY = (maxIM-minIM) / Ysize
|
|||
zi=zr*zi*2 + im; zr=a-b+re
|
||||
end /*n*/
|
||||
|
||||
$=$ || substr(@, n+1, 1) /*append number (as a char) to $ string*/
|
||||
$=$ || substr(@, n+1, 1) /*append number (as a char) to $ string*/
|
||||
end /*x*/
|
||||
say $ /*display a line of character output.*/
|
||||
end /*y*/ /*stick a fork in it, we're all done. */
|
||||
say $ /*display a line of character output.*/
|
||||
end /*y*/ /*stick a fork in it, we're all done. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue