Ajuda del LibreOffice 25.2
El LibreLogo és un entorn de programació similar al Logo, simple i traduït, amb imatges vectorials de tortuga per ensenyar programació i processament de text, DTP i creació d'imatges. Visiteu http://www.numbertext.org/logo/librelogo.pdf.
La barra d'eines del LibreLogo () conté icones per a moure la tortuga, executar i parar el programa, anar a l'inici i netejar la pantalla, realçar i traduir la sintaxi; a més d'una barra d'entrada (línia d'ordes).
Són equivalents a les ordes del Logo “AVANÇA 10”, “RETROCEDEIX 10”, “ESQUERRA 15”, “DRETA 15”. Fer clic a una de les icones, també també posarà el focus sobre la forma de la tortuga i desplaçarà la pàgina fins a la seua posició.
Feu clic a la icona «Inicia el programa Logo» per executar tot el text (o només el text seleccionat) del document del Writer com un programa del LibreLogo. En un document buit, s'inserirà i executarà un programa d'exemple.
Feu clic a la icona «Atura» per a aturar l'execució del programa.
Feu clic a la icona «Inici» per a restablir la posició i la configuració de la tortuga.
Feu clic la icona «Neteja la pantalla» per a suprimir els objectes dibuixats del document.
The “magic wand” icon sets 2-page layout for program editing, expands and converts to uppercase the abbreviated, lowercase Logo commands in the Writer document. Change the language of the document () and click on this icon to translate the Logo program to the selected language.
Premeu «Retorn» a la línia d'ordes per executar-ne el contingut. Per aturar el programa utilitzeu la icona «Atura».
Manteniu premuda la tecla «Retorn» per repetir la línia d'ordes, per exemple, en la seqüència d'ordes següent:
AVANÇA 200 ESQUERRA 89
To reset the command line triple-click it or press CommandCtrl+A to select the previous commands, and type the new commands.
Turtle shape of LibreLogo is a normal fixed size drawing object. You can position and rotate it on standard way, too, using the mouse and the Rotate icon of the Drawing Object Properties toolbar. Modify Line Thickness, Line Color and Area Color settings of the turtle shape to set PENSIZE, PENCOLOR and FILLCOLOR attributes of LibreLogo.
Els dibuixos i els programes del LibreLogo utilitzen el mateix document del Writer. El llenç del LibreLogo se situa a la primera pàgina del document del Writer. Amb la icona «Vareta màgica» podeu crear una disposició de dues pàgines per a programar còmodament: s'inserirà un salt de pàgina abans dels programes del LibreLogo i es configurarà l'escala de visualització per a veure dues pàgines alhora. Així tindreu el llenç a la primera pàgina i el codi a la segona.
LibreLogo és un llenguatge de programació similar al Logo, fàcilment traduïble, disponible en diversos llengües gràcies a comunitats natives del LibreOffice. Per exemple, és compatible cap arrere amb els sistemes Logo antics per al cas de programes Logo senzill usats en àmbit educatiu.
FINS.A triangle :mida
REPETEIX 3 [
AVANÇA :mida
ESQUERRA 120
]
FINAL
triangle 10 triangle 100 triangle 200
Els membres de la llista se separen amb comes: POSICIÓ [0, 0]
Els blocs de programa i les llistes són diferents
Program blocks need space or new line at parenthesization: REPEAT 10 [ FORWARD 10 LEFT 36 ]
Les llistes requereixen els parèntesis sense espai: POSICIÓ[0, 0], i no pas POSICIÓ [ 0, 0 ]
No s'admeten les declaracions de funcions en una única línia (FINS.A i FINAL necessiten línies noves).
Els dos punts són opcionals abans del nom de les variables.
FINS A triangle mida
REPETEIX 3 [ AVANÇA mida ESQUERRA 120 ]
FINAL
La notació de les cadenes també permet sintaxi ortogràfica i la de Python.
IMPRIMEIX "paraula ; sintaxi original del llenguatge Logo
IMPRIMEIX “Text arbitrari.” ; ortografia, Writer
IMPRIMEIX 'Text arbitrari.' ; sintaxi del llenguatge Python
Llista Python i gestió de cadenes
IMPRIMEIX “text”[2] ; imprimeix “x”
IMPRIMEIX “text”[1:3] ; imprimeix “ex”
Bucle PER.A similar al Python
Declaració de variables similar al Python:
x = 15
IMPRIMEIX x
No hi ha funcions de consulta addicionals:
PRINT FILLCOLOR
p = POSITION
PRINT p
REPEAT 10 [ POSITION ANY POSITION p ]
Sintaxi alternativa en la invocació de funcions amb paràmetres
TO star size color
FILLCOLOR color
REPEAT 5 [ LEFT 72 FORWARD size RIGHT 144 FORWARD size ]
FILL
END
star 100 “red”
star(100, “green”)
star(100, “blue”)
Les ordes i constants de color no distingeixen entre majúscules i minúscules:
IMPRIMEIX “Hola, món!”
imprimeix “Hola, món, altra vegada!”
Els noms de variable sí distingeixen entre majúscules i minúscules:
a = 5
A = 7
IMPRIMEIX a
IMPRIMEIX A
Lines of a LibreLogo program are paragraphs in the Writer document. A program line can contain multiple commands:
IMPRIMEIX “Hola, món!” IMPRIMEIX “LibreLogo”
Les línies o parts de línies són comentaris des d'un punt i coma fins al final de la línia (paràgraf):
; alguns comentaris
IMPRIMEIX 5 * 5 ; alguns comentaris
És possible partir una línia del programa en diversos paràgrafs afegint una titlla (~) a la fi de la línia:
IMPRIMEIX “Este és un missatge d'avís” + ~
“molt llarg”
FORWARD 10 ; move forward 10pt (1pt = 1/72 inch)
FORWARD 10pt ; see above
FORWARD 0.5in ; move forward 0.5 inch (1 inch = 2.54 cm)
FORWARD 1" ; see above
FD 1mm
FD 1cm
RETROCEDEIX 10 ; mou arrere 10 punts
ESQUERRA 90 ; gira 90 graus en sentit antihorari
ESQUERRA 90° ; vegeu amunt
GE 3h ; vegeu amunt (posició del rellotge)
GD qualsevol ; gira a una posició aleatòria
DRETA 90 ; gira 90 graus en sentit horari
AIXECA.LLAPIS ; la tortuga es mourà sense dibuixar
BAIXA.LLAPIS ; la tortuga es mourà dibuixant
POSITION [0, 0] ; turn and move to the top-left corner
POSITION PAGESIZE ; turn and move to the bottom-right corner
POSITION [PAGESIZE[0], 0] ; turn and move to the top-right corner
POSITION ANY ; turn and move to a random position
HEADING 0 ; turn north
HEADING 12h ; see above
HEADING [0, 0] ; turn to the top-left corner
HEADING ANY ; turn to a random direction
AMAGA.TORTUGA ; amaga la tortuga (fins l'orde mostra.tortuga)
MOSTRA.TORTUGA ; mostra la tortuga
INICI ; reinicialitza la configuració i posició de la tortuga
NETEJA.DIBUIX ; suprimeix tots els objectes dibuixats del document
FILL ; close and fill the actual line shape or points
CLOSE ; close the actual line shape or join the actual points
Exemple: emplenament d'un triangle equilàter:
AVANÇA 50 ESQUERRA 120 AVANÇA 50 OMPLE
Exemple: dibuix d'un triangle equilàter:
AVANÇA 50 ESQUERRA 120 AVANÇA 50 TANCA
PENSIZE 100 ; line thickness is 100 points
PENSIZE ANY ; equivalent of PENSIZE RANDOM 10
PENCOLOR “red” ; set red pen color (by color name, see color constants)
PENCOLOR [255, 255, 0] ; set yellow color (RGB list)
PENCOLOR 0xffff00 ; set yellow color (hexa code)
PENCOLOR 0 ; set black color (0x000000)
PENCOLOR ANY ; random color
PENCOLOR [5] ; set red color (by color identifier, see color constants)
PENCOLOR “invisible” ; invisible pen color for shapes without visible outline
PENCOLOR “~red” ; set random red color
PENTRANSPARENCY 80 ; set the transparency of the actual pen color to 80%
PENCAP “none” ; without extra line end (default)
PENCAP “round” ; rounded line end
PENCAP “square” ; square line end
PENJOINT “rounded” ; rounded line joint (default)
PENJOINT “miter” ; sharp line joint
PENJOINT “bevel” ; bevel line joint
PENJOINT “none” ; without line joint
PENSTYLE “solid” ; solid line (default)
PENSTYLE “dotted” ; dotted line
PENSTYLE “dashed” ; dashed line
; custom dot–dash pattern specified by a list with the following arguments:
; – number of the neighbouring dots
; – length of a dot
; – number of the neighbouring dashes
; – length of a dash
; – distance of the dots/dashes
; – type (optional):
; 0 = dots are rectangles (default)
; 2 = dots are squares (lengths and distances are relative to the pensize)
PENSTYLE [3, 1mm, 2, 4mm, 2mm, 2] ; ...––...––...––
FILLCOLOR “blue” ; fill with blue color, see also PENCOLOR
FILLCOLOR “invisible” CIRCLE 10 ; unfilled circle
FILLCOLOR [“blue”, “red”] ; gradient between red and blue
FILLCOLOR [[255, 255, 255], [255, 128, 0]] ; between white and orange
FILLCOLOR [“blue”, “red”, 1, 0, 0] ; set axial gradient (with the required rotation and border settings), possible values: 0-5 = linear, axial, radial, elliptical, square and rectangle gradients
FILLCOLOR [“red”, “blue”, 0, 90, 20] ; linear with 20% border, rotated with 90 degrees from the actual heading of the turtle
FILLCOLOR [“red”, “blue”, 0, 90, 20, 0, 0, 200, 50] ; from 200% to 50% intensity
FILLCOLOR [ANY, ANY, 2, 0, 0, 50, 50] ; radial gradient with random colors and 50-50% horizontal and vertical positions of the center
FILLTRANSPARENCY 80 ; set the transparency of the actual fill color to 80%
FILLTRANSPARENCY [80] ; set linear transparency gradient from 80% to 0%
FILLTRANSPARENCY [80, 20] ; set linear transparency gradient from 80% to 20%
FILLTRANSPARENCY [80, 20, 1, 90] ; set axial transparency gradient rotated with 90 degrees from the actual heading of the turtle
FILLTRANSPARENCY [80, 20, 2, 0, 20, 50, 50] ; set radial transparency gradient from outer 80% to inner 20% transparency with 20% border and with 50-50% horizontal and vertical positions of the center
FILLSTYLE 0 ; fill without hatches (default)
FILLSTYLE 1 ; black single hatches (horizontal)
FILLSTYLE 2 ; black single hatches (45 degrees)
FILLSTYLE 3 ; black single hatches (-45 degrees)
FILLSTYLE 4 ; black single hatches (vertical)
FILLSTYLE 5 ; red crossed hatches (45 degrees)
FILLSTYLE 6 ; red crossed hatches (0 degrees)
FILLSTYLE 7 ; blue crossed hatches (45 degrees)
FILLSTYLE 8 ; blue crossed hatches (0 degrees)
FILLSTYLE 9 ; blue triple crossed
FILLSTYLE 10 ; black wide single hatches (45 degrees)
; custom hatches specified by a list with the following arguments:
; – style (1 = single, 2 = double, 3 = triple hatching)
; – color
; – distance
; – degree
FILLSTYLE [2, “green”, 3pt, 15°] ; green crossed hatches (15 degrees)
CERCLE 100 ; dibuixa un cercle (amb un diàmetre de100 punts)
ELLIPSE [50, 100] ; draw an ellipse with 50 and 100 diameters
ELLIPSE [50, 100, 2h, 12h] ; draw an elliptical sector (from 2h clock position to 12h)
ELLIPSE [50, 100, 2h, 12h, 2] ; draw an elliptical segment
ELLIPSE [50, 100, 2h, 12h, 3] ; draw an elliptical arc
QUADRAT 100 ; dibuixa un quadrat (amb costat de mida 100 punts)
RECTANGLE [50, 100] ; draw a rectangle shape (50×100pt)
RECTANGLE [50, 100, 10] ; draw a rectangle with rounded corners
POINT ; draw a point with size and color of the pen
CLOSE can join the last points, FILL can fill the shape defined by points. For example, it’s easy to draw a “flat” star starting from its center:
PENUP
REPEAT 5 [
FORWARD 80
POINT
BACK 80
RIGHT 36
FORWARD 50
POINT
BACK 50
RIGHT 120
] FILL
LABEL “text” ; print text in the turtle position
LABEL 'text' ; see above
LABEL "text ; see above (only for single words)
CERCLE 10 TEXT “text” ; defineix el text de l'objecte de dibuix actual
COLOR.LLETRA "verd" ; estableix el color de la lletra
FAMÍLIA.LLETRA “Linux Libertine G” ; defineix el tipus de lletra (família)
FAMÍLIA.LLETRA "Linux Libertine G:smcp=1” ; estableix també la funció del tipus de lletra (majúscules petites)
FAMÍLIA.LLETRA “Linux Libertine G:smcp=1&onum=1” ; majúscules petites + figures antigues
MIDA.LLETRA 12 ; estableix 12 punts
PES.LLETRA “negreta” ; estableix el tipus de lletra a negreta
PES.LLETRA “normal” ; estableix el pes de lletra normal
ESTIL.LLETRA “cursiva” ; estableix la variant cursiva
ESTIL.LLETRA “normal” ; estableix la variant normal
PICTURE is for
agrupar formes;
començar formes de línies noves;
guardar imatges SVG i animacions SVG/SMIL;
keeping the consistency of positions and line shapes at the left border.
; PICTURE [ LibreLogo_commands ]
PICTURE [ FORWARD 100 CIRCLE 100 ] ; tree-like grouped shape
See also “Group” in LibreOffice Writer Help.
TO tree location
PENUP POSITION location HEADING 0 PENDOWN
PICTURE [ FORWARD 100 CIRCLE 100 ] ; tree-like grouped shape
END
PICTURE [ tree [230, 400] tree [300, 400] ] ; grouped shapes in a grouped shape
PICTURE ; start a new line shape
FORWARD 10 PICTURE FORWARD 10 ; two line shapes
PICTURE “example.svg” [ CIRCLE 5 ] ; save the picture as an SVG image file in the user folder
PICTURE “Desktop/example.svg” [ FORWARD 100 CIRCLE 5 ] ; as above, with a relative path
PICTURE “/home/user/example.svg” [ CIRCLE 5 ] ; absolute path for Unix/Linux
PICTURE “C:\example.svg” [ CIRCLE 5 ] ; absolute path for Windows
PICTURE “animation.svg” [ CIRCLE 5 SLEEP 1000 CIRCLE 99 ] ; save as an SVG/SMIL animation (see also SLEEP)
PICTURE “animation2.svg” [ CIRCLE 5 SLEEP 1000 CIRCLE 99 SLEEP 2000 ] ; as above, but using SLEEP after the last object will result looping: after 2 seconds the SVG animation restarts in SMIL-conformant browsers
Use PICTURE to keep the consistency of positions and line shapes at the left border of Writer:
PICTURE [ CIRCLE 20 POSITION [-100, 100] CIRCLE 20 ]
; REPETEIX nombre [ ordes ]
REPETEIX 10 [ AVANÇA 10 ESQUERRA 45 CERCLE 10 ] ; repeteix 10 vegades
; number is optional
REPEAT [ POSITION ANY ] ; endless loop
Variable del bucle (també per als bucles PER.A i MENTRE).
REPEAT 100 [ FORWARD REPCOUNT LEFT 90 ]
Bucle per als elements de llista:
FOR i IN [1, 5, 7, 9, 11] [
FORWARD i
LEFT 90
]
Loop for the characters of a character sequence:
FOR i IN “text” [
LABEL i
FORWARD 10
]
WHILE TRUE [ POSITION ANY ] ; endless loop
WHILE REPCOUNT <= 10 [ FORWARD 50 LEFT 36 ] ; as REPEAT 10 [ ... ]
Atura el bucle.
REPEAT [ ; endless loop
POSITION ANY
IF REPCOUNT = 100 [ BREAK ] ; equivalent of the REPEAT 100 [ ... ]
]
Va la següent iteració del bucle.
REPEAT 100 [
POSITION ANY
IF REPCOUNT % 2 = 0 [ CONTINUE ]
CIRCLE 10 ; draw circles on every 2nd positions
]
; IF condition [ true block ]
; IF condition [ true block ] [ false block ]
IF a < 10 [ PRINT “Small” ]
IF a < 10 [ PRINT “Small” ] [ PRINT “Big” ]
Operadors lògics.
IF a < 10 AND NOT a = 5 [ PRINT “0, 1, 2, 3, 4, 6, 7, 8 or 9” ]
IF a < 10 AND a != 5 [ PRINT “0, 1, 2, 3, 4, 6, 7, 8 or 9” ] ; as above
New word (or procedure).
TO triangle
REPEAT 2 [ FORWARD 100 RIGHT 120 ] FILL
END
REPEAT 10 [ triangle PENUP POSITION ANY PENDOWN ]
Retorna el valor de la funció.
TO randomletter
OUTPUT RANDOM “qwertzuiopasdfghjklyxcvbnm”
END
PRINT randomletter + randomletter + randomletter ; print 3-letter random character sequence
Return from the procedure.
TO example number
IF number < 0 [ STOP ]
PRINT SQRT number ; print square root
]
example 100
example -1 ; without output and error
example 25
Valor aleatori per defecte dels colors, etc.
COLOR.LLAPIS QUALSEVOL; color del llapis aleatori
Valor lògic.
WHILE TRUE [ POSITION ANY ] ; endless loop
PRINT TRUE ; print true
Valor lògic.
WHILE NOT FALSE [ POSITION ANY ] ; endless loop
PRINT FALSE ; print false
IMPRIMEIX MIDA.PÀGINA ; impremeix la llista de mides de pàgina en punts, p. ex. [595.30, 841.89]
IMPRIMEIX PI ; imprimeix 3.14159265359
PRINT “text” ; print “text” in a dialog box
PRINT 5 + 10 ; print 15
PRINT INPUT “Input value?” ; ask and print a string by a query dialog box
PRINT FLOAT (INPUT “First number?”) + FLOAT (INPUT “Second number?”) ; simple calculator
ESPERA 1000 ; espera durant 1000 ms (1 segon)
Defineix les variables globals utilitzades als procediments.
GLOBAL about
about = “LibreLogo”
TO example
PRINT about
GLOBAL about ; when we want to add a new value
about = “new value for the global variable”
END
example
PRINT about
IMPRIMEIX ALEATORI 100 ; nombre decimal aleatori (0 <= x < 100)
IMPRIMEIX ALEATORI "text” ; lletra aleatòria de “text”
IMPRIMEIX ALEATORI [1, 2] ; element aelatòri de la llista (1 o 2)
(Productes lt;sala1gt;[sala2][] 3.8 ; imprimeix la part 3 a" de 3.8)
[<identificador (el valor KE Irssi 100 ; multiplica un nombre enter (0 (0<= x < 100)
(l'objecte INT alemany) INT de -1 per a convertir el paràmetre de cadena
; convert the string parameter to float number
PRINT 2 * FLOAT “5.5” ; print 11.0
; convert the number parameter to string
PRINT “Result: ” + STR 5 ; print “Result: 5”
PRINT 10 * STR 5 ; print 5555555555
IMPRIMEIX ARRELQ 100 ; impreix 10, l'arrel quadra de 100
IMPRIMEIX SIN 90 * PI/180 ; imprimeix 1.0 (el sinus de 90° en radians)
IMPRIMEIX COS 0 * PI/180 ; imprimeix 1.0 (el cosinus de 0° en radians)
PRINT LOG10 100 ; print 2.0 (common logarithm of 100)
PRINT ROUND 3.8 ; print 4 (rounding 3.8)
PRINT ROUND RANDOM 100 ; random integer number (0 <= x <= 100)
IMPRIMEIX ABS -10 ; imprimeix 10, el valor absolut de -10
IMPRIMEIX COMPTA "text" ; imprimeix 4, el nombre de caràcters de «text»
IMPRIMEIX COMPTA [1, 2, 3] ; imprimeix 3, mida de la llista
; Convert list to Python set
PRINT SET [4, 5, 6, 6] ; print {4, 5, 6}
PRINT SET [4, 5, 6, 6] | SET [4, 1, 9] ; print {1, 4, 5, 6, 9}, union
PRINT SET [4, 5, 6, 6] & SET [4, 1, 9] ; print {4}, intersection
PRINT SET ([4, 5, 6, 6]) - SET [4, 1, 9] ; print {5, 6}, difference
PRINT SET [4, 5, 6, 6] ^ SET [4, 1, 9] ; print {1, 5, 6, 9}, symmetric difference
; Python-like list generation
PRINT LIST RANGE 10 ; print [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
PRINT LIST RANGE 3 10 ; print [3, 4, 5, 6, 7, 8, 9]
PRINT LIST RANGE 3 10 3 ; print [3, 6, 9]
FOR i IN RANGE 10 50 10 [ ; loop for [10, 20, 30, 40]
FORWARD i
LEFT 90
]
; remove the repeating elements of a list using set and list conversion
PRINT LIST (SET [1, 3, 5, 5, 2, 1]) ; print [1, 3, 5, 2]
Conversió a tupla de Python (llista no modificable)
PRINT TUPLE [4, 5]
It returns with a sorted list.
PRINT SORTED [5, 1, 3, 4] ; print [1, 3, 4, 5]
Substitute character sequences using regex (regular expression) patterns.
PRINT SUB (“t”, “T”, “text”) ; print “Text”, replacing “t” with “T”
PRINT SUB (“(.)”, “\\1\\1”, “text”) ; print “tteexxtt”, doubling every characters
Busca seqüències de caràcters usant expressions regulars.
IF SEARCH (“\w”, "word") [ PRINT “Letter in the word.” ]
Troba totes les seqüències de caràcters al text d'entrada que corresponguin amb el patró de l'expressió regular donat.
PRINT FINDALL(“\w+”, “Dogs, cats.”) ; print [“Dogs”, “cats”], the list of the words.
PRINT MIN [1, 2, 3] ; print 1, the lowest element of the list
PRINT MAX [1, 2, 3] ; print 3, the greatest element of the list
PENCOLOR “PLATA” ; definit pel nom
PENCOLOR [1] ; definit per identificadors
PENCOLOR “~PLATA” ; color plata aleatori
| Identificador | Nom | 
|---|---|
| 0 | NEGRE | 
| 1 | PLANTA|ARGENT | 
| 2 | GRIS | 
| 3 | BLANC | 
| 4 | GRANAT/GRANA | 
| 5 | VERMELL|ROIG | 
| 6 | PORPRE/PÚRPURA | 
| 7 | FÚCSIA/MAGENTA | 
| 8 | VERD | 
| 9 | LLIMA/VERD.LLIMA | 
| 10 | OLIVA/VERD.OLIVA | 
| 11 | GROC | 
| 12 | MARÍ/BLAU.MARÍ | 
| 13 | BLAU | 
| 14 | JADE | 
| 15 | CIAN | 
| 16 | ROSA | 
| 17 | TOMÀQUET/TOMATA | 
| 18 | TARONJA | 
| 19 | OR | 
| 20 | VIOLAT/VIOLETA | 
| 21 | CEL/BLAU.CEL | 
| 22 | XOCOLATA | 
| 23 | MARRÓ | 
| 24 | INVISIBLE |