Turtle Graphics implementation for Android

Amr Hesham
ITNEXT
Published in
3 min readJul 8, 2022

--

Hello everyone, in this article I want to introduce my last side project which is called Turtle, the project idea is totally inspired by the Turtle Graphics Project.

What is the Turtle Graphics project?

Today you may know Turtle graphics from the turtle implementation in the standard library in Python that allows you to control one or more turtles in a two-dimensional space, but the original one first appeared in the late 1960s as a key feature of the programming language called Logo which designed in 1967 by Wally Feurzeig, Seymour Papert, and Cynthia Solomon, you can read more information about Logo and some modern derivatives from wikipedia.

After I played with the turtle module in python and loved it, I searched on google play for Android Version with the same idea so I can have instructions, variables, control flow, data structures…etc, and I didn’t find any app with those features, so I decided to implement one as a side project.

The first step is to have a programming language easy to write and understand the syntax so i created a small one with syntax like python and I called it Lilo (the name is from Lilo and Stitch animation and like logo), so we can have functions, if, loops, variables, constants and a set of instructions for drawing and control the colors but for now you can only control one turtle so here is one example to draw Rainbow Benzene in Python and Lilo.

The Python version

The Lilo version.

The result will be like this

Lilo also provide a clean error and warns messages with line and column numbers so you can easily correct your script.

If you are interesting in a created programming language like Lilo you can start with those two amazing books

1 — Crafting Interpreters by Robert Nystrom from here

2 — Writing An Interpreter In Go by Thorsten Ball from here

The next step after I created the programming language was to create a code editor for it and a preview screen, for the code editor I used the CodeView library to provide highlighter, auto complete, snippets, error and warn highlighter and for the diagnostics messages, I used TreeView library so you an expand or collapse errors, warns or both easily.

for the preview screen I have created a simple custom view that can take the Lilo executor and draw the result you can check the code from here.

After that I implemented a documentations expanding list easily by generating it using EasyAdapter library and also I implemented save, update, search, and delete your lilo scripts as a lilo packages with some extra meta data.

Turtle Android App is available now on Google Play and the source code on Github so you are welcome to suggest features, report bugs, and contribute.

Google play: Turtle Graphics App

Github: AmrDeveloper/turtle

Here is demo video for turtle app that convert many python examples to lilo check it from here.

You can find me on: GitHub, LinkedIn, Twitter.

Enjoy Programming 😋.

--

--