Implementation of Turtle Graphics for Android

Written by amrdeveloper | Published 2022/08/15
Tech Story Tags: turtle | android | kotlin | interpreter | turtle-graphics | android-app-development | android-development | android-tutorial

TLDRThe project idea is totally inspired by the Turtle Graphics 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) The Python version is available on Google Play and the source code on Github on Github. The Android version of the Python version will be available now and the code is available in Google Play. The result will be like this: Rainbow Benzene in Python and Lilo.via the TL;DR App

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 fromWikipedia.


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 provides a clean error and warns messages with line and column numbers so you can easily correct your script.

If you are interested 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 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 package with some extra metadata.

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 a demo video for the turtle app that converts many python examples to lilo check it from here.

Enjoy Programming 😋.


Also Published Here


Written by amrdeveloper | Software Engineer interested in Android Development and Programming language design
Published by HackerNoon on 2022/08/15