Advertisement
johnpentyrch

ShadesofPiet

Apr 28th, 2020
574
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. from random import randint
  2. from turtle import Turtle
  3.  
  4.  
  5. tut=Turtle()
  6. tut.getscreen().bgcolor('#cccccc')
  7. tut.speed(0)
  8.  
  9. def draw_sq(t,h,w,c,bg,x,y):
  10.     t.pensize(5)
  11.     t.penup()
  12.     t.goto(x,y)
  13.     t.color(c,bg)
  14.     t.begin_fill()
  15.     t.pendown()
  16.     t.setheading(0) #east
  17.     t.forward(w) #to right width w
  18.     t.left(90)
  19.     t.forward(h) #draw up the height h
  20.     t.left(90)
  21.     t.forward(w)
  22.     t.left(90)
  23.     t.forward(h)
  24.     t.end_fill()
  25.  
  26.  
  27. colours=['red','white','blue','yellow']
  28.  
  29. for i in range(200):
  30.     xi=randint(-10,10)
  31.     yi=randint(-10,10)
  32.     ci=randint(0,3)
  33.     x=xi*40-100
  34.     y=yi*60-150
  35.     c=colours[ci]
  36.     draw_sq(tut,150,200,'black',c,x,y)
  37.  
  38. tut.hideturtle()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement