Page 1 of 1

Dragon curve animation

Posted: Sat Aug 19, 2017 1:34 pm
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 1545 times
image2.PNG
image2.PNG (63.56 KiB) Viewed 1545 times
image3.PNG
image3.PNG (189.63 KiB) Viewed 1545 times

Re: Dragon curve animation

Posted: Mon Aug 21, 2017 5:39 pm
by rbytes
I selected and copied the code from the Forum using MS Edge and pasted it into the SPL editor. It pasted with no line feeds!
No line feeds
No line feeds
Capturenolf.PNG (68.82 KiB) Viewed 1520 times
I had to go to the Windows Store and try a couple of notepad apps until I found one that would restore the line feeds. It is called My Notes. But it may have inserted some other hidden character that is causing a syntax error. I can't see any error.
Syntax eror
Syntax eror
Capturedragon.PNG (84.17 KiB) Viewed 1515 times
Definitely something to look into, as it is a nuisance to have to copy and paste the code twice to get line feeds, and it still won't work.

Re: Dragon curve animation

Posted: Mon Aug 21, 2017 6:43 pm
by Mr. Kibernetik
Thank you for your information.
I will fix the error with absence of line feeds when pasting from the Forum.
I think that #.and function is newly added and it is absent in the published version. New functions are added practically every day, so the version in the Store is always a bit outdated.
I will publish current version ASAP, and dragon curve should run with it. Also new versions of SPL usually have more example programs, so you can restore example files in Options to get them.