Word squares

wordsquare6The LibreLogo program draws checkered word squares in this example (see in SVG format: 6×6, 7×7, 4×4, 9×9).
The 6×6 and 7×7 word squares were found by Douglas McIlroy (see on his home page). He was the head of the research department at Bell Labs at the time of the birth of the Unix operating system, also a famous contributor of Unix (Unix pipes, manual, spell checking etc.), that is why the word “Unix” is in the third word square. Word square article of Wikipedia refers the last, 9×9 example as one of the largest known word square in English. Word squares bővebben…

Logo in LibreOffice 4.2

  • PENCAP (or LINECAP) command. Its text arguments are the default “NONE”, furthermore “ROUND” and “SQUARE”. Source code of the attached picture:
    linecap_demo

    TO twolines
        PENDOWN PENSIZE 20 PENCOLOR “TOMATO”
        FORWARD 200 
        PENSIZE 2 PENCOLOR “BLACK”
        BACK 200
        PENUP RIGHT 90 FORWARD 40 LEFT 90
    END
    
    HIDETURTLE
    PENCAP “NONE”
    twolines
    PENCAP “ROUND”
    twolines
    PENCAP “SQUARE”
    twolines
    

    Unconnected thick lines could seem to be continuous with the new linecap settings, as in this SVG animation (random walk).

  • FORWARD “text” command: the turtle prints the text and moves to the end of the text, so it’s possible to continue the text with a similar command. The code of the attached picture:
    forwardtext

    PENUP
    FONTCOLOR “GREEN”
    FORWARD “LIBRE”
    FONTCOLOR “GRAY”
    FORWARD “LOGO”
    
  • Stable batch generation of cropped SVG images. Examples: Images with LibreLogo source code. The next program generates ten regular polygons from the equilateral triangle to the regular 12-gon:
    batchproc

    TO polygon n
        FILLCOLOR ANY
        REPEAT n [ FORWARD 20 RIGHT 360/n ]
        FILL
    END
    
    REPEAT 10 [
        PICTURE “polygon%s.svg” % REPCOUNT [
            polygon REPCOUNT + 2
        ]
    ]
    
  • Optional looping of SVG animations (it needs only a SLEEP command after the last shape). Source code of the attached random walk illustration:
    random_walk

    PENCAP “ROUND” PENSIZE 5 HIDETURTLE
    PICTURE “random_walk.svg” [
        REPEAT 50 [
            SLEEP 50
            HEADING 90 * INT RANDOM 4
            FORWARD 20
        ]
        SLEEP 50
    ]
    
  • Relative SVG image path of PICTURE is relative to the path of the document (or in the case of a new document without any saving the default path is the root of the user folder).

LibreLogo at FOSDEM 2014

LibreLogo flyer: maze and its source code
Here is the A4 size LibreLogo flyer made for the LibreOffice booth at FOSDEM 2014. It contains a maze and its compact LibreLogo source code. This SVG animation shows its work. The source code of the program:
labirintus_demo

HIDETURTLE PENUP FILLCOLOR “BLACK”
REPEAT [
    RIGHT 90
    REPEAT REPCOUNT [
        z = INT RANDOM 2
        RECTANGLE [3.5+21*z, 3.5+13*(1-z)]
        FORWARD 10
    ]
]

One of the results of the 2-day LibreOffice hackfest after the conference is a small improvement for LibreLogo: now code formatting/translation doesn’t modify the comments of the program (see this and other achievements of the hackfest).