9
\$\begingroup\$

Logo is a programming language that was designed back in 1967 that has great potential for creating graphics in relatively few bytes compared to other languages.

Logo is an educational programming language that utilizes Turtle Graphics.

There are multiple interesting implementations of Logo including:

In addition, multiple Logo interpreters can be found online.

This page is intended to be a hub for code golf regarding any implementation of the Logo programming language.

enter image description here

Source: The Great Logo Adventure (1998) by Jim Muller

\$\endgroup\$
3
\$\begingroup\$

LibreLogo

Shorten Color Definitions:

It is documented that colors can be defined by name, identifier, RGB value, or HEX code.

In the majority of cases, if you have the opportunity to use an identifier for a color constant, that is typically the shortest option.

On the other hand, a little known fact is that you can also use the decimal value to define a color, and you can occasionally save bytes.

Color Chart:

+------------------------------------------------------------------------+   +-------------+
| Name                | Identifier | RGB           | HEX      | Decimal  |   | Best Option |
|------------------------------------------------------------------------|   |-------------|
| "BLACK"             | [0]        | [0,0,0]       | 0x000000 | 0        |   | 0           |
| "SILVER"            | [1]        | [192,192,192] | 0xc0c0c0 | 12632256 |   | [1]         |
| "GRAY"/"GREY"       | [2]        | [128,128,128] | 0x808080 | 8421504  |   | [2]         |
| "WHITE"             | [3]        | [255,255,255] | 0xffffff | 16777215 |   | [3]         |
| "MAROON"            | [4]        | [128,0,0]     | 0x800000 | 8388608  |   | [4]         |
| "RED"               | [5]        | [255,0,0]     | 0xff0000 | 16711680 |   | [5]         |
| "PURPLE"            | [6]        | [128,0,128]   | 0x800080 | 8388736  |   | [6]         |
| "FUCHSIA"/"MAGENTA" | [7]        | [255,0,255]   | 0xff00ff | 16711935 |   | [7]         |
| "GREEN"             | [8]        | [0,128,0]     | 0x008000 | 32768    |   | [8]         |
| "LIME"              | [9]        | [0,255,0]     | 0x00ff00 | 65280    |   | [9]         |
| "OLIVE"             | [10]       | [128,128,0]   | 0x808000 | 8421376  |   | [10]        |
| "YELLOW"            | [11]       | [255,255,0]   | 0xffff00 | 16776960 |   | [11]        |
| "NAVY"              | [12]       | [0,0,128]     | 0x000080 | 128      |   | 128         |
| "BLUE"              | [13]       | [0,0,255]     | 0x0000ff | 255      |   | 255         |
| "TEAL"              | [14]       | [0,128,128]   | 0x008080 | 32896    |   | [14]        |
| "AQUA"              | [15]       | [0,255,255]   | 0x00ffff | 65535    |   | [15]        |
| "PINK"              | [16]       | [255,192,203] | 0xffc0cb | 16761035 |   | [16]        |
| "TOMATO"            | [17]       | [255,99,71]   | 0xff6347 | 16737095 |   | [17]        |
| "ORANGE"            | [18]       | [255,165,0]   | 0xffa500 | 16753920 |   | [18]        |
| "GOLD"              | [19]       | [255,215,0]   | 0xffd700 | 16766720 |   | [19]        |
| "VIOLET"            | [20]       | [148,0,211]   | 0x9400d3 | 9699539  |   | [20]        |
| "SKYBLUE"           | [21]       | [135,206,235] | 0x87ceeb | 8900331  |   | [21]        |
| "CHOCOLATE"         | [22]       | [210,105,30]  | 0xd2691e | 13789470 |   | [22]        |
| "BROWN"             | [23]       | [165,42,42]   | 0xa52a2a | 10824234 |   | [23]        |
| "INVISIBLE"         | [24]       | N/A           | N/A      | N/A      |   | [24]        |
+------------------------------------------------------------------------+   +-------------+
\$\endgroup\$
2
\$\begingroup\$

LibreLogo

Use Abbreviated Commands:

Abbreviated commands, also called "short names," are used across most implementations of Logo.

Here is the full list of abbreviated commands for LibreLogo.

+-----------------------------------------------+
| Full Command    | Short Command | Bytes Saved |
|-----------------------------------------------|
| forward 10      | fd 10         | 5           |
| back 10         | bk 10         | 2           |
| left 90         | lt 90         | 2           |
| right 90        | rt 90         | 3           |
| penup           | pu            | 3           |
| pendown         | pd            | 5           |
| position 0      | pos 0         | 5           |
| heading 0       | seth 0        | 3           |
| hideturtle      | ht            | 8           |
| showturtle      | st            | 8           |
| clearscreen     | cs            | 9           |
| pensize 10      | ps 10         | 5           |
| pencolor 0      | pc 0          | 6           |
| fillcolor 0     | fc 0          | 7           |
| picture [ ... ] | pic [ ... ]   | 4           |
+-----------------------------------------------+
\$\endgroup\$
0
\$\begingroup\$

LibreLogo

Random Numbers:

Use any instead of random when possible.

Random Integer (0 - 9):

x = int random 10     ; 17 bytes
x = int(ps any)       ; 15 bytes

Random Floating-Point Number (0 - 9):

x = random 10         ; 13 bytes
x = (ps any)          ; 12 bytes

Directly Assigned to Setting:

pensize random 10     ; 17 bytes
ps random 10          ; 12 bytes
ps any                ; 6 bytes
\$\endgroup\$
0
\$\begingroup\$

LibreLogo

Use PAGESIZE to your Advantage:

PAGESIZE is a variable that is dependent on the Paper Format in LibreOffice Writer and returns an array containing the [width, height] of the page in points (pt).

This could be useful for a variety of situations, but I personally found it useful for generating a number without using the digits [0-9].

https://help.libreoffice.org/Writer/LibreLogo_Toolbar#PAGESIZE

enter image description here


Value Chart:

+-------------------------------------------------------------------+
| Paper Format           | PAGESIZE                                 |
|-------------------------------------------------------------------|
| A6                     | [297.35433070866145, 419.75433070866137] |
| A5                     | [419.75433070866137, 595.4456692913386]  |
| A4                     | [595.4456692913386, 841.6913385826772]   |
| A3                     | [841.6913385826772, 1190.8913385826772]  |
| B6 (ISO)               | [354.2456692913386, 498.95433070866136]  |
| B5 (ISO)               | [498.95433070866136, 708.4913385826771]  |
| B4 (ISO)               | [708.4913385826771, 1000.8]              |
| Letter                 | [612.0, 792.0]                           |
| Legal                  | [612.0, 1008.0]                          |
| Long Bond              | [612.0, 936.0]                           |
| Tabloid                | [792.0, 1224.0]                          |
| B6 (JIS)               | [362.8913385826771, 516.2456692913386]   |
| B5 (JIS)               | [516.2456692913386, 728.6456692913387]   |
| B4 (JIS)               | [728.6456692913387, 1031.7543307086614]  |
| 16 Kai                 | [521.2913385826771, 737.2913385826771]   |
| 32 Kai                 | [368.64566929133855, 521.2913385826771]  |
| Big 32 Kai             | [396.7086614173228, 575.2913385826771]   |
| User                   | CURRENT PAGE SIZE                        | ← Current Paper Format
| DL Envelope            | [311.7543307086614, 623.5086614173229]   |
| C6 Envelope            | [323.29133858267716, 459.3543307086614]  |
| C6/5 Envelope          | [323.29133858267716, 649.4456692913386]  |
| C5 Envelope            | [459.3543307086614, 649.4456692913386]   |
| C4 Envelope            | [649.4456692913386, 918.7086614173228]   |
| #6¾ Envelope           | [261.35433070866145, 468.0]              |
| #7¾ (Monarch) Envelope | [279.35433070866145, 540.0]              |
| #9 Envelope            | [279.35433070866145, 639.3543307086613]  |
| #10 Envelope           | [297.35433070866145, 684.0]              |
| #11 Envelope           | [324.0, 747.3543307086613]               |
| #12 Envelope           | [342.0, 792.0]                           |
| Japanese Postcard      | [283.69133858267713, 419.75433070866137] |
+-------------------------------------------------------------------+
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.