Drawing Spirals

A project log for Gcode Playground

Writing my own Gcode generator for pen plotter

Mike SzczysMike Szczys 05/01/2020 at 22:520 Comments

I'm working on some code to generate spiral patterns. So far I'm using Turtle in Python to simulate the pen plotter (you may remember this from the Apple ][)

from turtle import *

stylus = Turtle()
def drawSpiral(turtleObj,limit, steps):

    #0=right, 1=down, 2=left, 3=up
    increment = 0
    counter = 1

    while turtleObj.position()[0] < limit and turtleObj.position()[1] < limit:
        #if odd
        if counter%2 != 0:
            #increase by 10
            if increment < 0:
                increment -= steps
                increment += steps
            #change X
        #if even
            #flip polarity
            increment = increment * -1
            #change Y
        counter += 1

 Which when run using drawSpiral(stylus,191,10) gives us the nice demo below. This isn't spitting out g-code, but it shouldn't be hard to add that in when ready.