Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
13
Task/Mandelbrot-set/D/mandelbrot-set-1.d
Normal file
13
Task/Mandelbrot-set/D/mandelbrot-set-1.d
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
void main() {
|
||||
import std.stdio, std.complex;
|
||||
|
||||
for (real y = -1.2; y < 1.2; y += 0.05) {
|
||||
for (real x = -2.05; x < 0.55; x += 0.03) {
|
||||
auto z = 0.complex;
|
||||
foreach (_; 0 .. 100)
|
||||
z = z ^^ 2 + complex(x, y);
|
||||
write(z.abs < 2 ? '#' : '.');
|
||||
}
|
||||
writeln;
|
||||
}
|
||||
}
|
||||
8
Task/Mandelbrot-set/D/mandelbrot-set-2.d
Normal file
8
Task/Mandelbrot-set/D/mandelbrot-set-2.d
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
void main() {
|
||||
import std.stdio, std.complex, std.range, std.algorithm;
|
||||
|
||||
foreach (immutable y; iota(-1.2, 1.2, 0.05))
|
||||
iota(-2.05, 0.55, 0.03).map!(x => 0.complex
|
||||
.recurrence!((a, n) => a[n - 1] ^^ 2 + complex(x, y))
|
||||
.drop(100).front.abs < 2 ? '#' : '.').writeln;
|
||||
}
|
||||
27
Task/Mandelbrot-set/D/mandelbrot-set-3.d
Normal file
27
Task/Mandelbrot-set/D/mandelbrot-set-3.d
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import qd;
|
||||
|
||||
double lensqr(cdouble c) { return c.re * c.re + c.im * c.im; }
|
||||
|
||||
const Limit = 150;
|
||||
|
||||
void main() {
|
||||
screen(640, 480);
|
||||
for (int y = 0; y < screen.h; ++y) {
|
||||
flip; events;
|
||||
for (int x = 0; x < screen.w; ++x) {
|
||||
auto
|
||||
c_x = x * 1.0 / screen.w - 0.5,
|
||||
c_y = y * 1.0 / screen.h - 0.5,
|
||||
c = c_y * 2.0i + c_x * 3.0 - 1.0,
|
||||
z = 0.0i + 0.0,
|
||||
i = 0;
|
||||
for (; i < Limit; ++i) {
|
||||
z = z * z + c;
|
||||
if (lensqr(z) > 4) break;
|
||||
}
|
||||
auto value = cast(ubyte) (i * 255.0 / Limit);
|
||||
pset(x, y, rgb(value, value, value));
|
||||
}
|
||||
}
|
||||
while (true) { flip; events; }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue