Skip to content

Instantly share code, notes, and snippets.

@Oiselenjakhian
Created January 19, 2020 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Oiselenjakhian/b5dd7049b257d3476b3428abbe1b2481 to your computer and use it in GitHub Desktop.
Save Oiselenjakhian/b5dd7049b257d3476b3428abbe1b2481 to your computer and use it in GitHub Desktop.
Drawing Adinkra symbols using Python Template
import turtle
import math
# Square
def drawSquare(length):
turtle.penup()
turtle.setposition(-length/2.0, length/2.0)
turtle.pendown()
for i in range(0, 4):
turtle.forward(length)
turtle.right(90)
turtle.penup()
turtle.home()
# Horizontal lines
def drawHorizontalLine(length, division):
pixelSpace = int(length / division)
half = int(length / 2)
for j in range((-half + pixelSpace), half, pixelSpace):
turtle.penup()
turtle.setposition(-half, j)
turtle.pendown()
turtle.forward(length)
turtle.penup()
turtle.home()
# Vertical lines
def drawVerticalLine(length, division):
pixelSpace = int(length / division)
half = int(length / 2)
turtle.right(90)
for k in range((-half + pixelSpace), half, pixelSpace):
turtle.penup()
turtle.setposition(k, half)
turtle.pendown()
turtle.forward(length)
turtle.penup()
turtle.home()
# Draw the grid
turtle.speed(1000000)
drawSquare(400)
drawHorizontalLine(400, 40)
drawVerticalLine(400, 40)
# Change the colour mode
turtle.colormode(255)
# Change the pencolor to red
turtle.pencolor(255, 0, 0)
# Draw the horizontal centre line
turtle.setposition(-200, 0)
turtle.pendown()
turtle.forward(400)
turtle.penup()
# Draw the vertical centre line
turtle.setposition(0, 200)
turtle.setheading(270)
turtle.pendown()
turtle.forward(400)
# Reset all the properties
turtle.home()
turtle.pencolor(0, 0, 0)
# Place code here
# End the program
turtle.done()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment