Dragon curve animation

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

Dragon curve animation

Post by Mr. Kibernetik » 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()
.
image1.PNG
image1.PNG (7.94 KiB) Viewed 402 times
image2.PNG
image2.PNG (63.56 KiB) Viewed 402 times
image3.PNG
image3.PNG (189.63 KiB) Viewed 402 times

User avatar
rbytes
Posts: 1963
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone X
iPad 4
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Dragon curve animation

Post by rbytes » Mon Aug 21, 2017 5:39 pm

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 377 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 372 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.
Zzzzz

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

Re: Dragon curve animation

Post by Mr. Kibernetik » Mon Aug 21, 2017 6:43 pm

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.

Post Reply