xxxxxxxxxx
6
1
begin
2
using Markdown
3
using Luxor
4
using Colors
5
using PlutoUI
6
end
xxxxxxxxxx
1
1
f((x,y)) = (cos(y)^5*3^x, x^3+y) .|> p -> mod(p,1);
xxxxxxxxxx
3
1
g((x,y)) = let a=2.1, b=5.9
2
(sin(x*y/b)*y + cos(a*x - y), x + sin(y)/b) .|> p -> mod(p,1)
3
end;
xxxxxxxxxx
1
1
arnold((x,y)) = (2x + y, x + y) .% 1;
xxxxxxxxxx
9
1
function compose(f, n)
2
function (x)
3
val = x
4
for _ in 1:n
5
val = f(val)
6
end
7
return val
8
end
9
end;
xxxxxxxxxx
1
1
Base.:^(f::Function, n::Integer) = compose(f,n);
xxxxxxxxxx
1
1
dist((x1,x2),(y1,y2)) = sqrt((x1-y1)^2 + (x2-y2)^2);
xxxxxxxxxx
9
1
function dyndist(x,y,f,n)
2
d = dist(x,y)
3
for _ in 1:n
4
x = f(x)
5
y = f(y)
6
d = max(d, dist(x,y))
7
end
8
d
9
end;
800
xxxxxxxxxx
1
1
Np = 800
xxxxxxxxxx
1
1
cut Slider(0:0.01:1)
xxxxxxxxxx
1
1
n Slider(0:1:20)
xxxxxxxxxx
1
1
p = (.671,.81);
xxxxxxxxxx
1
1
fun = f;
xxxxxxxxxx
19
1
let s = 800
2
Drawing(s, s, "my-drawing.png")
3
background("antiquewhite")
4
for x in 0:(1/Np):1, y in 0:(1/Np):1
5
x = rand() # * .01 + p[1] - .005
6
y = rand() # * .01 + p[2] - .005
7
let (tx,ty) = (fun^n)((x,y))
8
setcolor(HSV(360tx,.5ty,dyndist((x,y),p,fun,n)))
9
end
10
if dyndist((x,y),p,fun,n) < cut
11
setcolor("black")
12
end
13
circle(Point(s .* (x, y)), sqrt(s)*0.026, :fill) # .+ (.005,.005) .- p
14
end
15
setcolor("red")
16
circle(s .* Point(p), 5, :fill) # Point(.5,.5)
17
finish()
18
preview()
19
end