Анимация кривой дракона

Post Reply
User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Анимация кривой дракона

Post by Mr. Kibernetik »

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()
.
image1.PNG
image1.PNG (7.94 KiB) Viewed 3138 times
image2.PNG
image2.PNG (63.56 KiB) Viewed 3138 times
image3.PNG
image3.PNG (189.63 KiB) Viewed 3138 times

Post Reply