5.0 Data Handling and Aesthetics
5.0 Data Handling and Aesthetics
5.1 String Processing
Logo can work with strings, which are sequences of alpha-numeric characters. The source provides an example procedure for calculating string length that utilizes several string-related commands:
- emptyp: Checks if a string is empty.
- first: Returns the first character of a string.
- butfirst: Returns the string with the first character removed.
- sentence: Combines words and lists into a single list.
5.2 Color Control
Logo’s color system is based on the RGB (Red, Green, Blue) model, where each color component is represented by a number from 0 to 255. This allows for over 16 million possible colors (24-bit color).
- Color Components: Black is represented as [0 0 0], while Red is [255 0 0], Green is [0 255 0], Blue is [0 0 255], and White is [255 255 255].
- Color Commands:
| Command | Purpose |
| setpencolor [r g b] (setpc) | Sets the color of the turtle’s pen. |
| setfloodcolor [r g b] (setfc) | Sets the color used by the fill command. |
| setscreencolor [r g b] (setsc) | Sets the background color of the Drawing Window. |
| show pencolor | Reports the current RGB value of the pen color. |
| fill | Fills an enclosed area with the current floodcolor. |