def cross(side, x, y): #makes the cross everytime
for i in range(0, 4):
thor.left(90)
thor.forward(side)
thor.left(180)
thor.forward(side)
import turtle
wn = turtle.Screen()
wn.bgcolor("black")
thor = turtle.Turtle()
thor.pensize(5)
thor.speed(0)
thor.color("darkblue")
halfSide = 250
sideLength = 500 #length of the biggest square
x = -250
y = 250
thor.penup() #positions the cursor so the square will be centered
thor.left(90)
thor.forward(halfSide)
thor.left(90)
thor.forward(halfSide)
thor.left(90)
thor.pendown()
thor.forward(sideLength) #makes the biggest square only once
thor.left(90)
thor.forward(sideLength)
thor.left(90)
thor.forward(sideLength)
thor.left(90)
thor.forward(sideLength)
thor.left(90) #repositions the cross to the center once it's done one cross
thor.penup()
thor.setpos(0, 0)
thor.pendown()
cross(250, 0, 0) #length of cross side, x and y coordinates
for i in range(0, 4): #creates second set of crosses
thor.pensize(4)
thor.color("RoyalBlue")
thor.forward(halfSide/2)
thor.left(90)
thor.forward(halfSide/2)
cross(halfSide/2, x+halfSide/2, y+halfSide/2)
thor.penup()
thor.setpos(0, 0)
thor.pendown()
halfSide=halfSide/2
for j in range(0, 16): #creates 3rd set of crosses
thor.pensize(3)
thor.color("lightblue")
thor.penup()
if j < 4: #to reposition the crosses
thor.setpos(125, 125)
elif j < 8:
thor.setpos(-125, 125)
elif j < 12:
thor.setpos(-125, -125)
else:
thor.setpos(125, -125)
thor.pendown()
thor.forward(halfSide/2)
thor.left(90)
thor.forward(halfSide/2)
cross(halfSide/2, x+halfSide/2, y+halfSide/2)
for j in range(0, 32): #creates 4th set of crosses
thor.pensize(2)
thor.color("azure")
thor.penup()
if j < 4: #to reposition the crosses
thor.setpos(62.5, 62.5)
elif j < 8:
thor.setpos(187.5, 62.5)
elif j < 12:
thor.setpos(187.5, 187.5)
elif j < 16:
thor.setpos(62.5, 187.5)
elif j < 20: #to reposition the crosses
thor.setpos(-187.5, 62.5)
elif j < 24:
thor.setpos(-62.5, 62.5)
elif j < 28:
thor.setpos(-62.5, 187.5)
elif j < 32: #to reposition the crosses
thor.setpos(-187.5, 187.5)
thor.pendown()
thor.forward(halfSide/4)
thor.left(90)
thor.forward(halfSide/4)
cross(halfSide/4, x+halfSide/4, y+halfSide/4)
wn.exitonclick()
This post has been edited by macosxnerd101: 07 November 2014 - 04:04 PM
Reason for edit:: Please remember to use code tags when posting code.

New Topic/Question
Reply



MultiQuote


|