A reproduction of the symbol for Star Wars' Galactic Republic using Python Turtle. The image uses concentric circles, bars, and "invisible" boxes. Code correction: In def gap(z), it is "4 sides of an invisible box" rather than "4 invisible boxes." My apologies :)
Feel free to copy the basic Python Turtle code that is given below. Don't hesitate to ask questions about the code if you have any. Enjoy! Please comment, like, or subscribe :)
Incidentally, for manually colorable graphics and variations, please visit my author url at https://www.amazon.com/author/basicpy...
(With corrected comment at def gap(z))
import turtle
t = turtle.Turtle() #Definitions and Initializations
screen = turtle.Screen()
t.pensize(4) #Changeable
switch = 0 #Code to identify whether fillcolor of circle is "white" (0) or "black" (1)
graphic_size = 252 #Changeable; Radius of circular graphic
r4 = (11 / 12) * graphic_size #Radii r's for the next circles with algorithmically identified fillcolor
r3 = (10 / 12) * graphic_size
r2 = (9 / 12) * graphic_size
r1 = (4 / 12) * graphic_size
def circle(x): #Procedure for drawing a colorfilled circle with indicated radius x
t.fillcolor()
t.begin_fill()
t.circle(x) #Drawing of circle; Default "black" for pen and fill color for first circle
t.end_fill()
def bar(y): #Procedure for drawing a colorfilled bar that runs across the innermost circle
t.begin_fill()
for i in range(2):
t.forward((4 / 3) * y) #Length of colorfilled bar with y equal to graphic_size
t.left(90)
t.forward((1 / 9) * y) #Width of colorfilled bar
t.left(90)
t.end_fill()
def gap(z): #Procedure for "drawing" an invisible box (with "white" as pen and fill color)
t.begin_fill() #that serves as a gap in the black circular band
for i in range(4): #Loop to "draw" 4 sides of a box with z equal to graphic_size
t.forward((1 / 6) * z)
t.left(90)
t.end_fill()
t.penup() #Python_graphic start of drawing procedure
for radius in [graphic_size, r4, r3, r2, r1]: #Loop to draw 5 variously-sized, overlapping, and concentric circles with
t.forward(radius) #alternating "black" and "white" as fill colors
t.left(90)
t.pendown()
circle(radius) #Function call to draw a colorfilled circle with indicated radius; If first
t.penup() #circle, default "black" for pen and fill color
t.home()
if switch == 0: #Conditional statement to identify current value of variable switch
t.color("white") #Assignment of "white" as pen and fill color of next circle to be drawn if switch = 0
switch = 1
continue
t.color("black") #Assignment of "black" as pen and fill color of next circle to be drawn if switch = 1
switch = 0
t.color("black") #Assignment of "black" as pen and fill color of 4 colorfilled bars
for angle in [0, 45, 90, 135]: #Loop to draw 4 colorfilled bars with indicated orientations in degrees
t.left(angle)
t.backward((2 / 3) * graphic_size)
t.right(90)
t.forward((1 / 18) * graphic_size)
t.left(90)
t.pendown()
bar(graphic_size) #Function call to draw a colorfilled bar that runs across the innermost circle
t.penup()
t.home()
t.color("white") #Assignment of "white" as pen and fill color of (invisible) boxes that serve as gaps
for i in range(8): #Loop to draw 8 white (invisible) boxes that serve as gaps in the black circular band
t.right(90)
t.forward((1 / 12) * graphic_size)
t.left(90)
t.forward((178.5 / 252) * graphic_size)
t.pendown()
gap(graphic_size) #Function call to draw a white (invisible) box that serves as a gap in circular band
t.penup()
t.home()
t.left((1 + i) * 45) #Turtle rotation to draw next white (invisible) box
t.hideturtle()
screen.exitonclick()