neolateral

programming, drawing, photograpy etc.

Hi Guys,

Sometimes you know how to trace a line or a box, but you want a tool to do it for you with precision. Of course in any paint program there are tools to do this with line segments and arcs and so on. But it gets tedious if there are too many lines and they have to follow a strict pattern.

This is where computer programs can come to the rescue. Almost everyone who learnt to program as a kid, is familiar with a variant of Turtle programming or Turtle graphics. A long time ago someone invented this tiny programming language called Logo where you get to program a tiny turtle moving across the screen with simple commands like forward, backward, left, right etc. The turtle moves across a 2d screen, and if you send the command pendown to the turtle, it will start drawing a line as it move. This is programming at its simplest.

Here’s a simple fern drawn using a turtle graphics program. (Note: the turtle is usually denoted by a red triangle on the canvas.)

Fern drawn using Turtle Graphics

How was this made? I have built my own Turtle Graphics application. A new version completely rewritten for Windows will be out soon. The program is in a programming language called Lua. Lua is one of the easiest programming languages to learn. You can learn most of lua in 15 mins.

-- fern: function which
-- calls itself recursively
-- till the size is less than 1
-- to draw the fern.

reset()

function fern(size, sign)
    if (size < 1) then
        return
    end

    forward(size)

    right(70 * sign)
    fern(size/2, sign*-1)
    left(70 * sign)

    forward(size)

    left(70 * sign)
    fern(size/2, sign)
    right(70 * sign)

    right(7 * sign)
    fern(size - 2, sign)
    left(7 * sign)

    forward(-size)
    forward(-size)
end

penup()
back(200)

right(90)
back(20)
pencolour(200, 100, 0)
font('Calibri', 36)
filltext('Fern')
forward(20)
left(90)
forward(50)

pencolour(0, 128, 0)
pendown()
fern(25, 1)

Happy arting,

Abhishek (art noob)