With the support of the FSF.hu Foundation, I have successfully implemented some long-planned LibreLogo improvements. This has made LibreLogo more reliable in LibreOffice, helping more and more people to discover the beauty of programming with LibreLogo, like German schoolchildren or Italian kindergarten teachers. My developments:

- Adding LibreOffice unit tests for LibreLogo program execution and compiling. Based on this automated testing, Red Hat developer Stephan Bergmann has already found an interesting regex change in Python 3.7 (LibreLogo was written in Python programming language), and he has fixed LibreLogo, too.
- Compiling Logo expressions to Python, i.e. adding parentheses at the right places uses a parser instead of the former heuristic method. Thus, you can write arbitrarily complex expressions, either in combination with Python lists, and calling own Logo functions with more than one argument without parentheses. Note: In LibreLogo expressions you can use Logo and Python syntaxes at one time. To avoid conflict, now parenthesis directly following the function name, eg. in
*“**sin(x) * 2”*denotes Python syntax, (meaning*2·sin(x)*), while the space separated version, eg.*“**sin (x) * 2”*, denotes Logo syntax (meaning “sin(2·x)”, as the simpler Logo expression*“sin x * 2”*). - Function definitions and Logo-like function calls can be in any order, resulting for example completely Logo-like dragon curve drawing Logo program (see on the attached screenshot).
- Fix of the “magic wand” icon enables a two-sided view, keeping also the debug function “jump text cursor to the wrong LibreLogo program line at compiling”.
- We can write ASCII and typographical apostrophes in character strings.
- The running program stops immediately by clicking the Cancel button on the dialog window of the commands INPUT and PRINT (no need to wait starting a new loop in cycles).
- One of the goals of the planned future LibreLogo developments is to provide a more detailed documentation of LibreLogo’s Python source code. As you can see, I have already tried to do this in the current patches.

These developments will appear soon in the next preliminary version of LibreOffice 6.2.

]]>- Shipped LibreLogo package of Ubuntu and other Linux distributions has got localization support from LibreOffice 5.4.4.
- LibreLogo works on more (all) macOS versions.
- Recent LibreLogo regression (“drying ink”: drawing shorter lines as the path of the turtle) of the LibreOffice development code has been solved during the conference.

- Brazil: Gilvan Vilarim has continued his LibreLogo curse at the digital inclusion conference SEMID, also he wrote a LibreLogo manual in Portuguese.
- Germany: Mirek Hančl has included several LibreLogo worksheet templates in his upcoming grade 5/6 exercise book, published by Cornelsen Verlag in February, 2019.
- Hungary: LibreLogo is used in several elementary and middle schools. Looking for a method by Péter Kecskeméti to add an immutable background image, for example, a graph paper behind the Logo turtle, I suggested a solution (usage of GDI image format) to create exciting worksheet templates for Logo exercises.

- Research of University of Florence has been proven LibreLogo’s exceptional abilities in the education of computer programming. LibreLogo supports the concept “low floor, high ceiling”, which was first formulated in the 1970s by Seymour
*Papert*, co-inventor of the Logo programming language: learning programming is a child’s play with LibreLogo, while it’s still very easy to learn more abstract programming principles with it. (A. R. Formiconi & F. Mancini:*A step back into the future*, draft, University of Florence, 2017) - As part of the research project of the university, Andreas Formiconi initiated the LibreLogo usage in eTwinning educational platform of EU, at eTwinning conferences and by leading online seminars.

Thanks for the great help of all LibreLogo contributors!

]]>CIRCLE 150 PENUP FORWARD 75 POINT BACK 75 RIGHT 60 FORWARD 75 POINT CLOSE

or drawing a “flat” star:

PENUP REPEAT 5 [ FORWARD 100 POINT BACK 100 RIGHT 360/10 FORWARD 70 POINT BACK 70 RIGHT 360/10 ] FILLCOLOR “GOLD” FILL

and drawing nice sheriff badges:

TO star n m PENUP PENSIZE n/m REPEAT m [ FORWARD n PENCOLOR “GOLD” POINT BACK n RIGHT 360/m/2 FORWARD n*0.6 PENCOLOR “INVISIBLE” POINT BACK n*0.6 RIGHT 360/m/2 ] PENCOLOR “INVISIBLE” FILLCOLOR “GOLD” FILL PENSIZE n/m/3 FILLCOLOR “INVISIBLE” PENCOLOR “WHITE” PENDOWN CIRCLE 2*n*0.6-n/m/3 PENUP FONTSIZE n/4 FONTCOLOR “WHITE” FONTFAMILY “Western” TEXT “SHERIFF” END CLEARSCREEN HOME HIDETURTLE PENUP POSITION [130, 200] HEADING 0 REPEAT 9 [ PICTURE [ star 70 2+REPCOUNT ] RIGHT 90 FORWARD 160 LEFT 90 IF REPCOUNT % 3 = 0 [ BACK 160 RIGHT 90 BACK 160*3 LEFT 90 ] ]]]>

]]>

Wikipedia page Power symbol mistakenly showed the astronomical symbol of the moon (see right) instead of the IEEE 1621 standard crescent moon symbol. This standardized symbol, called “Sleep” refers to the Sleep mode (also Stand By or Suspend), the low power mode for electronic devices.

The easily accessible consultant report of the standard is a little bit cryptic about the form and size of the proposed symbol (Appendix VI.3.):

Fortunately, abstract of the referred standard IEC 40630 revealed the size of the square, too: exactly 75 mm. Using this data and a ruler, it was possible to measure the diameter of the outer circle, too: it is 6 cm. The standard specifies the ratio of the outer curve of the moon shape: a half circle; the width of the shape: 1/4 diameter of the circle (1.5 cm); and “tilt” of the moon: just for fun, it is equal to the earth’s angle of inclination (at the time of writing of the standard, it was 23.45 degrees). The only question was the specification of the inner curve of the moon shape. After some investigation it was found that it is arc of a circle, not an ellipse. We can calculate its radius (

Radius of the first circle (

PENUP LEFT 23.45° FILLCOLOR “BLACK” CIRCLE 6cm RIGHT 90 FORWARD 2.25cm FILLCOLOR “WHITE” CIRCLE 7.5cm

For a better cropping in the SVG version, we can draw only a black semicircle, and – using the law of sines for the calculation – only the requested white circular segment of the second circle:

PICTURE “power_sleep_black_cropped.svg” [ PENUP LEFT 23.45° FILLCOLOR “BLACK” ELLIPSE [6cm, 6cm, 6h, 12h] RIGHT 90 FORWARD 2.25cm LEFT 90 FILLCOLOR “WHITE” ELLIPSE [7.5cm, 7.5cm, 6h+36.8°, 12h-36.8°, 2] ]

Apply the following steps to convert the black and white circular segments to a single moon shape:

1. Open the exported SVG file in LibreOffice Draw.

2. Select and remove the bad black background rectangle.

3. Press Ctrl-A to select the black and white circular segments.

4. Select **Modify » Shapes » Subtract** to subtract the white circular segment from the black semicircle.

5. Export as SVG.

Drawing white (empty) sleep symbols is a little bit trickier. We have to draw the circular segments with the (double of the) requested line width for the inner moon shape (see the screenshot), (moreover, in enlarged version to reduce the rounding errors of the Draw canvas and the following clipboard operation), and subtract this smaller moon shape from the big one. Steps:

1. Change the Writer paper size to 100×100 cm, and run the following LibreLogo code:

TO moon color bgcolor HOME LEFT 23.45° PENCOLOR color PENSIZE 4cm FILLCOLOR bgcolor ELLIPSE [60cm, 60cm, 6h, 12h] PENUP RIGHT 90 FORWARD 22.5cm LEFT 90 PENDOWN FILLCOLOR “WHITE” ELLIPSE [75cm, 75cm, 6h+36.8°, 12h-36.8°, 2] END PICTURE [ moon “INVISIBLE” “BLACK” moon “ORANGE” “INVISIBLE” ]

2. Copy the picture to a 100×100 cm Draw canvas, select **Modify » Ungroup** and **Modify » Shapes » Subtract** to create the inner moon shape.

3. Press Ctrl-C to copy the inner moon shape to the clipboard, and press Ctrl-Z to restore the image.

4. Remove the two shapes with orange outlines.

Press Ctrl-V to insert the inner moon shape (you can change its filling color to check it, see on the attached screenshot).

5. Press Ctrl-A and select **Modify » Shapes » Subtract** to create the empty moon shape.

6. Resize it with Format » Position and Size…, move it to the left upper corner, resize the canvas (or copy the moon shape to the previous, but empty SVG file), and export it as a new SVG file.

IEC 40630 has got two preferred line widths, 2 mm and 4 mm, also the filled moon is an official version of the symbol, and sometimes it is useful to use not only the fully cropped versions of these symbols, but the versions cropped only to the 6 cm (invisible) circle, that is why Wikimedia Commons has got six new sleep symbols (see the image gallery of one of them).

…because the picture is the illustrated version of the sentence “VAKÁCIÓ!”, the obligate, usually colourful and imaginatively designed text on the blackboards of the Hungarian elementary schools before the long Summer vacation (zoom). The animated SVG version of the picture shows how the text is longer day by day, started with the exclamation mark.

Interestingly, the coloured chalk was invented 200 years ago, according to the resources of Wikipedia (see blackboard): James Pillans Scottish classical scholar and educational reformer created it from ground chalk, dyes and porridge in 1814 for teaching geography.

]]>*The Boy Who Loved Math: The Improbable Life of Paul Erdős* is a funny children book about the legendary Hungarian mathematician. Author of the book, Deborah Heiligman has got the help of Erdős’s friends and colleagues, also the illustrator of the book, Le Uyen Pham has traveled to Budapest to create great illustrations about the place of birth and childhood of the world wanderer Paul Erdős. According to the New York Times’s review (Nate Silver: Beautiful Minds), this book “should make excellent reading for nerds of all ages.” It contains also several interesting mathematical problems, including the illustrated one: how can we tile a square using other squares whose sizes are all different and have integer lengths. The squaring on the picture is the simplest one, and it was discovered by A. J. W. Duijvestijn in 1978, see its interesting history on Squaring.net.

The LibreLogo source code of the illustration uses the mapping and grid drawing procedures of the tangram drawing example of the previous post, also the new procedure *box* for drawing a square with random filling color with 50% transparency (using the new FILLTRANSPARENCY command of LibreOffice 4.3) and a title showing the actual size:

TO place x y POSITION [50+x*4, 500-y*4] END TO line x y x2 y2 PENUP place x y PENDOWN place x2 y2 END TO grid x y x2 y2 REPEAT y2-y+1 [ line x y+REPCOUNT-1 x2 y+REPCOUNT-1 ] REPEAT x2-x+1 [ line x+REPCOUNT-1 y x+REPCOUNT-1 y2 ] END TO box x y s PENUP place x+s/2 y+s/2 HEADING 0 FILLCOLOR ANY FILLTRANSPARENCY 50 PENDOWN SQUARE s*4 FONTSIZE MAX (2*4, s*2.5) TEXT s END PICTURE “squaredsquare.svg” [ PENSIZE 0.5 HIDETURTLE PENCAP “ROUND” PENCOLOR “SILVER” FONTFAMILY “Nimbus Sans L” grid 0 0 112 112 PENSIZE 1 PENCOLOR “BLACK” box 0 0 33 box 29 33 4 box 33 0 37 box 0 33 29 box 0 33+29 50 box 29 33+4 25 box 29+25 37 16 box 29+25 37+16 9 box 29+25+9 37+16 7 box 29+25+9 37+16+7 2 box 50 37+25 15 box 50 37+25+15 35 box 33+37 0 42 box 33+37 42 18 box 50+15 37+16+7 17 box 50+15+17 18+42 6 box 50+15+17 18+42+6 11 box 50+35 18+42+17 8 box 29+25+16+18 42 24 box 50+35+8 42+24 19 box 50+35 42+24+19 27 ]]]>

Saving animated SVG pictures needs to use only the SLEEP command within the PICTURE block. If the PICTURE block ends also with a SLEEP command, the result will be a looping SVG animation, as in this example.

TO place x y POSITION [200+x*40, 400-y*40] END TO line x y x2 y2 PENUP place x y PENDOWN place x2 y2 END TO grid x y x2 y2 REPEAT y2-y+1 [ line x y+REPCOUNT-1 x2 y+REPCOUNT-1 ] REPEAT x2-x+1 [ line x+REPCOUNT-1 y x+REPCOUNT-1 y2 ] END PICTURE “drawtangram.svg” [ PENSIZE 2 HIDETURTLE PENCAP “ROUND” PENCOLOR “SILVER” grid 0 0 4 4 SLEEP 1000 PENCOLOR “BLACK” line 0 4 4 0 SLEEP 1000 line 2 4 4 2 SLEEP 1000 line 1 3 2 4 SLEEP 1000 line 0 0 3 3 SLEEP 1000 line 3 3 3 1 SLEEP 1000 FILLCOLOR “RED” line 0 0 0 4 place 2 2 FILL FILLCOLOR “BLUE” line 0 0 4 0 place 2 2 FILL FILLCOLOR “GREEN” line 0 4 2 4 place 1 3 FILL FILLCOLOR “PURPLE” line 2 4 4 4 place 4 2 FILL FILLCOLOR “LIME” line 3 1 2 2 place 3 3 FILL FILLCOLOR “FUCHSIA” line 2 4 1 3 place 2 2 place 3 3 FILL FILLCOLOR “YELLOW” line 3 1 3 3 place 4 2 place 4 0 FILL SLEEP 2000 ]

Note: this code shows an example to use arbitrary Cartesian coordinate system with LibreLogo: the procedure *place* moves the turtle to the given coordinate, mapping it to the PostScript like coordinate system of LibreOffice. Procedure *line* calls *place* two times to draw a line. With combining *line* with *place* calls it’s possible to draw the filled tangram shapes using simple Cartesian coordinates.

The tangram is a popular dissection puzzle (see the LibreLogo turtle). Chinese mathematicians Fu Traing Wang and Chuan-Chih Hsiung proofed in 1942, that there are only 13 convex polygons can be formed by the tangram. Solving them is a good play (especially with a real tangram set):

[The solution (with an extended LibreLogo source code moving the origin of the Cartesian coordinate system to draw multiple shapes with simple Cartesian coordinates): convex tangram shapes (SVG).]

Next pictures are related to the equilateral triangle: angles of the regular triangle (in SVG), extreme points of an equilateral triangle with rounded corners (in SVG) and the impossible object Reutersvärd triangle (in SVG).

We can draw an equilateral triangle repeating FORWARD and RIGHT commands:

REPEAT 3 [ FORWARD 100 RIGHT 120 ]

More automatization could create the series of regular polygons, also with angles and other annotation, see the gallery and attached LibreLogo source code of the Wikipedia illustration:

Next triangle is the result of the SVG transition of a mathematical illustration (the original picture was in the Wikimedia Commons category *Top 200 images that should use vector graphics by usage*).

The program of the picture draws 1 inch width outline with rounded corners, and in a second turn, narrow arcs with the appropriate radius.

HIDETURTLE PICTURE “Extreme points.svg” [ FILLCOLOR “SKYBLUE” PENCOLOR “SKYBLUE” PENSIZE 72 RIGHT 30 FORWARD 100 RIGHT 120 FORWARD 100 FILL PENCOLOR “RED” PENSIZE 2 REPEAT 3 [ CIRCLE [70, 70, 9h, 1h, 3] PENUP RIGHT 120 FORWARD 100 PENDOWN ] ]

Note: this illustration helped to find a rare SVG export problem, see the enlarged line end on the right picture and the LibreOffice bug report.

One of the best optical illusions, created by the Swedish artist, Oscar Reutersvärd at the age of 18, in 1934. The next program draws the left picture. To get the optical illusion, open the SVG file in LibreOffice Draw, and place two shapes (bottom sides of the first cube) to foreground manually (for example, by Ctrl-Shift-+).

TO tile LEFT 60 REPEAT 2 [ FORWARD 40 RIGHT 120 FORWARD 40 RIGHT 60 ] FILL RIGHT 60 END TO cube colors = [“GOLD”, “TEAL”, “TOMATO”] REPEAT 3 [ PENCOLOR colors[REPCOUNT-1] FILLCOLOR colors[REPCOUNT-1] tile RIGHT 120 ] END PICTURE “Reutersvärd triangle.svg” [ HIDETURTLE PENSIZE 0.1 RIGHT 30 REPEAT 3 [ REPEAT 3 [ PENUP FORWARD 60 PENDOWN d = HEADING HEADING 30 cube HEADING d ] RIGHT 120 ] ]

Note: Using narrow outlines (instead of “invisible” PENCOLOR) limits the SVG rendering problems in low resolution.

]]>Cyprus, the Czech Republic, Estonia, Hungary, Latvia, Lithuania, Malta, Poland, Slovakia, and Slovenia joined the European Union on 1 May 2004. The picture of the week is related to the 10th anniversary (and the upcoming Europe Day), also because LibreLogo is a development of the Hungarian E-Governmental Free Software Competence Centre, too, a project that has been supported by the European Union.

The flag of the European Union was part of the Wikipedia, but its official variants, the blue (1), and black monochrome (2), moreover the white-bordered versions of the three printing variants (3, 4, 5) were created recently by LibreLogo.

White-bordered flags are for reproduction on a coloured background. This LibreLogo program draws the blue-yellow flag with the requested border size (1/25th of the height of the flag):

; go to a vertex and store its coordinate TO vertex vertices n FORWARD n where = POSITION vertices += [where] BACK n END TO star n golden_ratio = (1 + SQRT 5)/2 vertices = [] HEADING 0 REPEAT 5 [ vertex vertices n RIGHT 360/10 vertex vertices n - n / golden_ratio RIGHT 360/10 ] ; join vertices (from the 2nd vertex) FOR i IN vertices [ POSITION i PENDOWN ] FILL PENUP END PICTURE “Flag_of_Europe_with_border.svg” [ HIDETURTLE FILLCOLOR “WHITE” PENCOLOR “INVISIBLE” RECTANGLE [15cm+2*10cm/25, 10cm+2*10cm/25] FILLCOLOR 0x003399 RECTANGLE [15cm, 10cm] FILLCOLOR 0xffcc00 REPEAT 12 [ PENUP HEADING 360/12 * (REPCOUNT - 1) FORWARD 10cm*2/6 star 10cm/18 HOME ] ]

The following picture shows the route of the turtle:

Drawing a star consists of two steps here. Firstly, the turtle goes to the vertices (always from the center of the star), storing their coordinates in a list. The second step is a cycle on the list of coordinates, drawing and filling the outline of the star. Convex (outer) vertices of the star are situated on the circumference of an invisible circle whose radius is equal to 1/18th of the height of the flag. This radius (*r*) is the input parameter of the procedure „star”. Concave (inner) vertices of the star have a similar circle with smaller radius. This radius (*r*₂) has been calculated using the golden ratio, because the ratio of the difference of the two radii and the smaller radius is the same as the ratio of their sum (the larger radius) to the larger of the two quantities (the difference of the two radii): (*r*–*r*₂)/*r*₂ = *r*/(*r*–*r*₂) = (1 + √5)/2, the golden ratio (≈ 1.618).