Using python to generate LOGO program for drawing a BMP file. This is a modification version of the original img2logo project, which was designed for Apple II LOGO. This version is intended to work on python's turtle graphics module, which is a standard library for creating simple graphics in Python. About modification, refer to the modificaion section bellow.
This project use uv and python 3.14, ensure to have them installed in your system.
With uv, manually install the dependencies is not required, but if you want to install them manually, you can use the following command:
uv syncTo run the img2logo script, use the following command:
uv run src/img2logo/img2logo.py <input_bmp_file>After running the script, it will generate a data file with the same name as the input BMP file, but with a .data.txt
extension. This data file contains the scanlines data that required to draw the BMP image using turtle graphics. The
render logic and the LOGO instructions are implemented in the src/img2logo/reader.py file.
To run the turtle graphics script, use the following command:
uv run src/img2logo/reader.py <data_file>or optionally, provide the x and y offset for the turtle graphics window:
uv run src/img2logo/reader.py <data_file> --off-x <x_offset> --off-y <y_offset>for example the bad apple demo:
uv run src/img2logo/img2logo.py ./bad-apple.bmp
uv run src/img2logo/reader.py ./bad-apple.data.txt --off-x -240 --off-y 180- Use uv as the package manager.
- Use python's turtle graphics module instead of Apple II LOGO.
- Add alternative parsing logic for BMP files with alternative color mode.
- Instead of copy and pasting the generated LOGO code, the script now generates a data file that can be read by the turtle graphics script.
- Original LOGO code use recursion to draw each scanline, which will cause stack overflow for slightly larger images. Here we use a loop instead. Maybe because LOGO did not have issue of stack overflow? I'm not sure.
Released under MIT License, no warranty. Refer to the license.md file for more details.
GeekLogic (WellsWang) for the amazing project and demo on Apple II. Link to the video: Use LOGO language to turn an Apple II Chinese Clone into a drawing wizard! 让中华学习机变成画画仙人!还记得LOGO吗?

