Advanced Turtle Graphics – Small Basic Featured Program


Today I will introduce an extended version of Turtle Graphics program written by qwx.  This program is announced as comments in my blog post last week.

Qwx’s program was DMX970.  Updated points from my XVK119-3 were:

  • Shortened commands
  • Colors
  • Main repeat loop must be in the first line
  • Command S)caling exponential
  • Right click menu
  • Save and load menu
  • Uses ESL and LitDev extensions

And I also updated this version to DMX970-0 as follows:

  • Remove ESL extension object (so only needs LitDev extension)
  • Rewrote clear code for Turtle
  • Changed drive name from I: to F:
 
 
 
 
Thank you qwx for sharing your program and graphics.
Comments (32)

  1. anonymouscommenter says:

    it's fascinanting how nice drawing can be made from such a little cmd-s))

    try to implemet recursion sub calls Nonki

    found some java logo scrpits like:

    def jog [ forward 30 under [ turn 45 ] [ forward 10 ] ]

    def joggle [ under jog reverse reverse ]

    poly 16 [ poly 4 joggle ]

    explanation:

    pen                toggle pen up/down

    mirror        toggle left/right

    reverse        toggle forward/back

    turn X        rotate X degrees

    forward X        translate X units

    scale X        multiply unit size

    repeat N [ ] repeat a plan N times

    poly N [ ]        repeat with implicit turning

    within [ ] [ ] sandwich a plan

    (within a b == a b a)

    inverse [ ]       produce the opposite of a plan

    (inverse a == a-1)

    under [ ] [ ] make a do/undo sandwich

    (under a b == a b a-1)

    flip NAME       switch argument order

    (flip f b a == f a b)

    def NAME [ ] define a subplan

    also makes nice drawings:

    def t [ turn 90 ]

    def f [ forward 60 ]

    def h [ forward 30 ]

    def x [ under [ under t f ] h ]

    def u [ under t f h ]

    def q [ under [ repeat 2 u ] ]

    def w [ under [ repeat 1 u ] ]

    def e [ under [ repeat 0 u ] ]

    poly 4 [ q [

    poly 4 [ w [

    poly 4 [ e [

    x inverse x

    ] ] ] ] ] ]

  2. anonymouscommenter says:

    2 spirales

    def coil [ repeat 300 [ turn 5 forward 5 scale .99 ] ]

    def branch [ flip under [ ] ]

    poly 2 [ branch coil ]

  3. anonymouscommenter says:

    if u master java lang. Nonki,can read following:

    en.literateprograms.org/Turtle_graphics_%28JavaScript%29

  4. anonymouscommenter says:

    logaritmic spyral

    {200

    S 0.99

    F 15

    R 5

    ]

  5. anonymouscommenter says:

    nautilus shell

    {1

    {200 [

    S 1.01

    F 5

    R 5

    ]

    R 90

    S 0.2

    F 147

  6. anonymouscommenter says:

    nice flower

    U

    R 180

    F 100

    R 180

    D

    {18 [

    {17 [

    S 1.05

    F 2

    R 5

    ]

    {17 [

    S 0.98

    F 2

    R 5

    ]

    S 0

    {17 [

    S 1.05

    F 2

    R 5

    ]

    {17 [

    S 0.98

    F 2

    R 5

    ]

    ]

  7. anonymouscommenter says:

    corrected flower))

    U

    R 180

    F 100

    D

    S 0

    {17 [

    S 1.05

    F 2

    R 5

    ]

    {17 [

    S 0.98

    F 2

    R 5

    ]

    {18 [

    {17 [

    S 1.05

    F 2

    R 5

    ]

    {17 [

    S 0.98

    F 2

    R 5

    ]

    S 0

    {17 [

    S 1.05

    F 2

    R 5

    ]

    {17 [

    S 0.98

    F 2

    R 5

    ]

    ]

  8. anonymouscommenter says:

    circular saw

    {14

    {24 [

    S 0.98

    F 3

    R 5

    ]

    S 0

    R 90

    F 30

    R 180

  9. anonymouscommenter says:

    new release!:

    code: LSR830

    includes:

    ————

    new samples

    save & restore position

    divisonal scaling ( syntax: S/1.234 e.g.)

    new future feat:

    -variables

    -proc/functions

    -math func. Sin Cos Tan…

    -recursions: great for fractals))

  10. anonymouscommenter says:

    now VAR n CONSTS in game!

    code:ZLD505

    beware:

    each var assignment initiates a new instance (e.g |aa=5) such as New in VB or VC++

    to reassign a new value to same var use ~ instead of = (e.g. |aa~6

    all referencing to vars must preceed by "|" vertical line 0x7C char, not "I" letter!

    first 3 vars can be used as consts with %1 %2 or %3 referencing, but are treated as replace cmd in C lang. precompiler

    undefined vars can produce unexpected results and behavior!

    enjoy!

  11. anonymouscommenter says:

    example:

    {4

    |X1=0

    |C2=0

    |Cc=1.93

    L 90

    {5 [

    |X1~5

    |C2~15

    {15 [

    F %2

    R |X1

    |X1+%3

    ]

    ]

  12. anonymouscommenter says:

    restrictions:

    in one line only first var reference counts, other are treated as 0!

    all var/const names must have 2 letters only!

    cx=cx+1 is written in form of |cx+1

  13. anonymouscommenter says:

    now text print added!

    import: WDL294

    also can adjust color and pen width in treelistviewform

    sample of txt drawing:

    {1

    S 2

    |x1=0

    |c2=0

    {5 [

    |X1~5

    |C2~15

    U

    {15 [

    F %2

    Wrt *

    R |X1

    |X1+1.93

    ]

    ]

    U can write any text instead of * in Wrt statement

  14. anonymouscommenter says:

    some math updates: ZFW885

    and sine simulation

    {1

    U

    L 90

    F 350

    R 90

    D

    |X1=5

    |C2=25

    {3 [

    |X1~5

    |C2~25

    {10 [

    F |c2

    R %1

    |X1*1.1

    |c2*0.9

    ]

    {11 [

    F |c2

    R %1

    |X1/1.1

    |c2/0.9

    ]

    |X1~5

    |C2~25

    {10 [

    F |c2

    L %1

    |X1*1.1

    |c2*0.9

    ]

    {11 [

    F %2

    L %1

    |X1/1.1

    |c2/0.9

    ]

    ]

  15. That's awesome!

    Love the programs, QWX!

  16. anonymouscommenter says:

    thx))

    KJL399

    added mouse tracing turtle and align grid

    press grid then rec then cls to compact listing

    after recording add a {1 at begin of prgm.list in order to show traced path

  17. anonymouscommenter says:

    def. update: ZSG940

    replace the first def. line with update code for a cool turtle drawing!

  18. anonymouscommenter says:

    now subs in game! code RMB848

    example:

    {1

    |ww=R

    |qq=*

    L 40

    @1

    |qq~/

    $

    R 90

    @1

    &

    L 90

    @1

    &

    R 90

    |ww~L

    @1

    ##

    <Lp1

    {55 [

    %1 91.5

    F 40

    S%2 1.025

    ]

    >

    subs are always after main end signed by ##, enclosed by < >, called by @1..@n by order of appearance.

    note the use of %1 and %2 as const replacer makes it powerful tool, even more powerful than any other prog.language, eliminates elegantly unnecessary IF clauses!

  19. anonymouscommenter says:

    BSB562

    added some debugging utils:

    W# writes to console output:

    %$$ – loop counter

    %$A – turtle angle

    %$C – pen color

    looks exotic: W#%$$

  20. anonymouscommenter says:

    ups forget to mention loops changes

    instead of {2 [ just write {2

    and } or ] for loop end

  21. anonymouscommenter says:

    now some clock functions

    and explanator working, just press Xpln button to get more human readable code))

    imp.code: NZF568

  22. anonymouscommenter says:

    a clock sample

    just displays mins+secs on analog watch))

    {1

    ~FN Calibri

    |aa=0

    |a1=0

    |a2=0

    |dd=0

    |an=0

    |ca=0

    |bn=0

    |cb=0

    {10000

    ~T

    |an~%2

    |an*6

    |ca~360

    |ca+-%5

    |bn~%3

    |bn*6

    |cb~360

    |cb+-%7

    ~H

    U

    R 90

    ~FS 40

    Wrt %1:%2!!:%3!!

    R 90

    F 60

    ~FS 20

    Wrt %4

    ~H

    U

    L 90

    F 100

    D

    A %6

    F 40

    ~H

    U

    L 90

    F 100

    D

    A %8

    F 30

    ~990

    R 180

    D

    P 30

    A %6

    P 40

    U

    ~C

    ]

  23. Thanks qwx for your comments.  I will follow your comments in following Forum thread.

    social.msdn.microsoft.com/…/another-turtle-graphics

  24. anonymouscommenter says:

    QZP213

    new version, introduced IF clause , Skip clause :$, and remark //explanation

  25. anonymouscommenter says:

    example of IF:

    {5

    |X1=0

    |C2=0

    |pp=0

    $

    {2

    |pp+1

    |X1~5

    |C2~15

    U

    &

    D

    {15

    F %2

    IF =2;%3 2

    R %1

    :$2

    //else

    L %1

    |X1+1.93

    }

    }

    U

    &

    U

    F 65

    ##

  26. anonymouscommenter says:

    now w some animation effects too))

    {1

    //animation sample: imp:QPJ207

    {12

    #O>

    R 90

    F 50

    L 120

    F 50

    #O#1

    $

    R 135

    U

    F 1200

    ~15

    #OA %X;%Y;1;1500

    ~150

    &

    D

    }

    ##

  27. anonymouscommenter says:

    new big update for SB1.1 now working!

    {1

    //animation sample: imp:QQF794

    {12

    #O>

    R 90

    F 50

    L 120

    F 50

    #O#1

    $

    R 135

    U

    F 1200

    ~15

    #OA %X;%Y;1;1500

    ~150

    &

    D

    }

    //

    ~H

    U

    F 60

    L 90

    F 40

    #F Calibri;1;1;25

    WRT Logo power!

    ##

  28. anonymouscommenter says:

    flickr pics clock

    works only in SB 1.1 as u know flickr was disabled in SB 1.0

    code: BPN924

    {1

    //pics4flickr BPN924

    U

    R 90

    F 300

    L 90

    {12

    L 30

    F 200

    #I:Sun;%X;%Y;200;150

    ~1250

    }

    ##

  29. anonymouscommenter says:

    a nice turtle clock by animated turtle moving around in secs!

    be aware not to press CLS othervise turtle hides forever

    code:TZJ639

    usage: right press and select Clock and then run…

    enjoy!

  30. anonymouscommenter says:

    a sewing machine doing LOGO flag…

    code WMM047

  31. Qwx, your programs are great!

Skip to main content