-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.jpl
37 lines (32 loc) · 1.08 KB
/
test.jpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
fn mandlestep({ zx : float, zy : float}, {cx : float, cy : float}): {float,float} {
return { \
(zx * zx) - (zy * zy) + cx, \
(2.0 * zx * zy) + cy \
}
}
fn mandlecount({ zx : float, zy : float}, c : {float,float}, max : int): int {
return if max == 0 \
then 0 \
else if (zx * zx + zy * zy) > 2.0 \
then 0 \
else 1 + mandlecount(mandlestep({zx, zy}, c), c, max - 1)
}
fn colormap(c : float) : float4 {
return if c < 0.5 \
then { 0.0, 0.0, 2.0 * c, 1.0 } \
else { (2.0 * c) - 1.0, (2.0 * c) - 1.0, 1.0, 1.0}
}
fn mandlepixel(c : {float,float}, max : int) : float4 {
let count = mandlecount({0.0, 0.0}, c, max)
let c2 = if count == max then 0.0 else (float(count + 1) / float(max))
return colormap(c2)
}
let iter = 0.2 / 60.0
let {xlo, xhi} = {-1.5, 1.0 - 2.3 * iter}
let {ylo, yhi} = {-1.0 + 0.9 * iter, 1.0 - 0.9 * iter}
let {W, H} = {2000, 1600}
time let mandlebrot = array[i : W, j : H] mandlepixel( \
{ xlo + float(i) / float(W) * (xhi - xlo) \
, ylo + float(j) / float(H) * (yhi - ylo)}, \
100)
write image mandlebrot to "mandlebrot.png"