The Document Foundation has announced LibreOffice 5.0, bringing new features including the following useful LibreLogo extension: now it’s possible to join arbitrary number of points using the command POINT with CLOSE and FILL in PENUP mode. For example, drawing a chord is quite easy:

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
]
]

The annual LibreOffice conference was held in Bern at the beginning of September. Main topic of the conference presentation “The Big Draw on LibreLogo.org” was about the successful Wikipedia contribution using LibreLogo, see the slides in a hybrid PDF with some extra notes. Thanks to András Tímár for the presentation!

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 (r_{2}) and position based on the following illustration:
Radius of the first circle (r_{1}) is 3 cm. Using the Pythagorean theorem, r_{2}^{2} = (r_{2}–r_{1}/2)^{2}+r_{1}^{2} = (r_{2}–1.5)^{2} + 9 = r_{2}^{2} – 3r_{2} + 2.25 + 9, so r_{2} = 11.25/3 = 3.75. The following LibreLogo program draws the filled moon using a black, 6 cm circle, and a white, 7.5 cm 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: Continue reading The Boy Who Loved Math→

LibreLogo can export SVG animations in the upcoming LibreOffice 4.3. The attached picture is the animated GIF preview of the SVG/SMIL Wikipedia animation about tangram drawing, see the SVG animation in your browser.
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).]

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:

Extreme points

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.

Reutersvärd optical illusion

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. Continue reading Flag of Europe→

SENID 2014 (Digital Inclusion National Seminar) at Passo Fundo University, Brazil, organized also a 4-hour LibreLogo workshop, during the 3-day conference at end of the April. Gilvan Vilarim, lecturer of the workshop, reported that the event had 15 participants, including teachers and some students (one of them was deaf, and she used the assistance of a Libras interpreter – Libras is the Brazilian version of the sign language for deaf people). The participants found the workshop to be very interesting, and they planned to continue using LibreLogo. (Thanks to Gilvan for the pictures, too.)

The 40th anniversary of the Rubik’s cube is being celebrated with the Beyond Rubik’s Cube exhibition at Liberty Science Center in Jersey City: “7,000 sq ft of games, puzzles, history, art and engineering, all inspired by Ernő Rubik’s best-selling masterpiece”.
A few days after the opening of the exhibition, here is the Picture of the week of LibreLogo.org: Continue reading 40th anniversary of the Rubik’s Cube→