SHARE
TWEET

Untitled

a guest Oct 20th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import turtle
  2.  
  3. def drawChessboard(startX, startY, width = 250, height = 250):
  4.     turtle.speed(0)
  5.     turtle.penup()
  6.     turtle.goto(startX, startY)
  7.     turtle.pendown()
  8.     # Draw the red outline of the chessboard.
  9.     turtle.color("red")
  10.     for i in range(2):
  11.         turtle.forward(width)
  12.         turtle.left(90)
  13.         turtle.forward(height)
  14.         turtle.left(90)
  15.         turtle.color("black")
  16.     #draw first set of black squares.
  17.     drawAllRectangles(width, height, startX, startY)
  18.     for k in range(4):
  19.         secondBlackSpace()
  20.         startY += (spaceHeight * 2)
  21.         turtle.goto(startX, startY)
  22.  
  23.  
  24. def drawAllRectangles(width, height, startX, startY):
  25. # Draw first set of squares
  26.     for n in range(4):
  27.         turtle.pendown()
  28.         drawRectangle(width, height)
  29.         turtle.penup()
  30.         turtle.forward(width / 4)
  31.         turtle.pendown()
  32.     # Reposition the turtle to draw second set of squares
  33.     turtle.penup()
  34.     newstartY = startY + (spaceHeight * 2)
  35.     turtle.goto(startX, newstartY)
  36.     # Draw second set of squares
  37.     for n in range(4):
  38.         for i in range(4):
  39.             turtle.penup()
  40.             turtle.forward(spaceWidth)
  41.             turtle.pendown()
  42.             drawRectangle(width, height)
  43.             secondstartY += spaceHeight
  44.             turtle.goto(startX, secondstartY)
  45.  
  46. # Draw individual rectangles
  47. def drawRectangle(width, height):
  48.     turtle.fillcolor("black")
  49.     turtle.begin_fill()
  50.     for i in range(2):
  51.         turtle.forward(width / 8)
  52.         turtle.left(90)
  53.         turtle.forward(height / 8)
  54.         turtle.left(90)
  55.         turtle.end_fill()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top