neolateral

programming, drawing, photograpy etc.

Articles tagged with turtle

Square Spirals Drawn using New PicoTurtle Lua API

In the last few weeks, I've rewritten the PicoTurtle programming API in a C++ program. Here are the major features/changes of the new implementation:- * The turtle API has Lua bindings. Lua is sufficiently lightweight that the interpreter can be distributed with the new picoturtle program. * The new implementation does not have a client-server design greatly reducing its complexity from the older nodejs/electron based implementation. * The program uses Skia Canvas for the drawing implementation. Skia (developed by google) is also the canvas for google chrome. * Although bindings for other programming languages can be developed, the current version is only …

PicoTurtle Java program to draw a groovy tunnel

I've also added Java support to picoturtle. Here's a program to draw a rather groovy tunnel. Java code follows.

import in.abhishekmishra.picoturtle.Turtle;
import in.abhishekmishra.picoturtle.TurtleState;

public class Tunnel
{
    public static void cuboid(Turtle t, double b, double w, double h) {
        t.forward(b);

        t.right(-45);
        t.forward(h);
        t.back(h);
        t.left(-45);

        t.left(90);
        t.forward(w);

        t.left(-45);
        t.forward(h);
        t.back(h);
        t.right(-45);

        t.left(90);
        t.forward(b);

        t.left(-135);
        t.forward(h);
        t.back(h);
        t.right(-135);

        t.left(90);
        t.forward …
PicoTurtle C# program to draw a wave

Recently I added C# .NET support to picoturtle. I was playing around generating waves... here's an example based on the sine function. And the C# Turtle code follows below.

using System;
using picoturtle;

namespace cspico
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            // Create the turtle before using
            Turtle t = picoturtle.Turtle.CreateTurtle(args);

            if (t != null) {
                // Your code goes here

                t.penup();
                t.setx(0);
                t.sety(250);

                for(double i = 0; i < 500; i+=0.25) {
                    t.setx(i);
                    double sin = Math.Sin(i/15);
                    double y = sin * 100;
                    t.forward(y);
                    t.pendown();
                    int col = Math.Abs …
PicoTurtle released

This week I built the first release of PicoTurtle - a turtle program built on REST/HTTP APIs, allowing programs written in potentially any programming language to draw turtle graphics with it. The desktop editor is built using electron. Download it at PicoTurtle Homepage.

I'll make follow-up posts about how the program works, but here's a dragon curve drawn using picoturtle...

And here's the code... (based on the entry on dragon curve in wikipedia at https://en.wikipedia.org/wiki/Dragon_curve#Code)

from picoturtle import *
create_turtle()

### Your code goes here ###

def dragonCurve(order, length):
    right(order * 45)
    dragonCurveRecursive(order, length, 1 …
Exploring turtle graphics

This week I started exploring turtle graphics with my son as he is very interested in drawing and crafts (he calls his room "art room"). We wrote one program together in python's turtle graphics library. It's here - face.py , and this is what it looks like :)

So this got me reading and exploring a bit more about turtle graphics, especially since the tools and language python were not really easy enough to use for my son. So I decided to create my own turtle environment (currently I'm thinking about doing this in electron so that it's available on all platforms …