Advertisement
g0thy

Circle_Rectangle

Nov 27th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. from turtle import Turtle
  2.  
  3. luna = Turtle()
  4.  
  5. def draw_circle(t_name, r, col, Xdir, Ydir):
  6.     t_name.penup()
  7.     t_name.goto(Xdir, Ydir)
  8.     t_name.color(col)
  9.     t_name.dot(r*2)
  10.  
  11. def draw_rectangle(t_name, col, xLoc, yLoc, xDim, yDim ):
  12.     #input coloUr and corner co-ordinates ^^^
  13.  
  14.  #Draw the rectangle
  15.     t_name.color(col)
  16.     t_name.penup()
  17.     t_name.goto(xLoc,yLoc)
  18.     t_name.fillcolor(col)
  19.     t_name.begin_fill()
  20.     t_name.pendown()
  21.     t_name.forward(xDim)
  22.     t_name.right(90)
  23.     t_name.forward(yDim)
  24.     t_name.right(90)
  25.     t_name.forward(xDim)
  26.     t_name.right(90)
  27.     t_name.forward(yDim)
  28.     t_name.end_fill()
  29.  
  30. #call up some circles    
  31. draw_circle(luna, 150, "blue", -110, -20)
  32. draw_circle(luna, 100, "red", 180, 100)
  33. draw_circle(luna, 50, "yellow", 200, -202)
  34.  
  35. #now do some rectangles
  36. draw_rectangle(luna, "green", -350, 360, 100, 150)
  37. draw_rectangle(luna, "teal", 220, 100, 35, 159)
  38. draw_rectangle(luna, "magenta", 350, -182, 65, 15)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement