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()
#stylus.setpos(100,100)
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
else:
increment += steps
#change X
turtleObj.setpos(turtleObj.position()[0]+increment,turtleObj.position()[1])
#if even
else:
#flip polarity
increment = increment * -1
#change Y
turtleObj.setpos(turtleObj.position()[0],turtleObj.position()[1]+increment)
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.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.