Анимация кривой дракона
Posted: Sat Aug 19, 2017 1:34 pm
Code: Select all
levels = 16
level = 0
step = 1
>
draw(level)
level += step
? level>levels
step = -1
level += step*2
.
? level=0, step = 1
#.delay(1)
<
draw(level)=
mx,my = #.scrsize()
fs = #.min(mx,my)/2
r = fs/2^((level-1)/2)
x = mx/2+fs*#.sqrt(2)/2
y = my/2+fs/4
a = #.pi/4*(level-2)
#.scroff()
#.scrclear()
#.drawline(x,y,x,y)
ss = 2^level-1
> i, 0..ss
? #.and(#.and(i,-i)*2,i)
a += #.pi/2
!
a -= #.pi/2
.
x += r*#.cos(a)
y += r*#.sin(a)
#.drawcolor(#.hsv2rgb(i/(ss+1)*360,1,1):3)
#.drawline(x,y)
<
#.scr()
.