Turtle Graphics implementation for Android
Tags: android, java, kotlin, turtle
Published: 2022-07-15 10:36:29

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](https://en.wikipedia.org/wiki/Logo_(programming_language)).

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v09v5cijofbx8ohbq580.png)

The Lilo version.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n507p2n0ktgd8c3mhwpb.png)

The result will be like this


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/razy2t8inl2rvbr58bks.png)

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

2 — Writing An Interpreter In Go by Thorsten Ball

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](https://github.com/AmrDeveloper/CodeView) library to provide highlighter, auto complete, snippets, error and warn highlighter and for the diagnostics messages, I used [TreeView](https://github.com/AmrDeveloper/treeview) library so you an expand or collapse errors, warns or both easily.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qqj83felftmbptfl11hu.png)

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.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mudlc3c8k0334yozdpiz.png)


After that I implemented a documentations expanding list easily by generating it using [EasyAdapter](https://github.com/AmrDeveloper/easyadapter) library and also I implemented save, update, search, and delete your lilo scripts as a lilo packages with some extra meta data.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zoas6a54xlmhqa70f0cq.png)

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](https://play.google.com/store/apps/details?id=com.amrdeveloper.turtle)

Github: [AmrDeveloper/turtle](https://github.com/AmrDeveloper/Turtle)

Here is demo video for turtle app that convert many python examples to lilo check it from [here](https://www.youtube.com/watch?v=eWui7nFYia0).

Enjoy Programming 😋.