Advertisement
renix1

drawing a cake...

Jun 23rd, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.36 KB | None | 0 0
  1. # coding:utf-8
  2. """ Draw a cake in screen with python 2.x
  3.    Author: Reni Dantas
  4. """
  5.  
  6. import turtle
  7. import random
  8.  
  9. class Cake(object):
  10.     """ Class to make a cake, riariaria """
  11.     def __init__(self, x=0, y=0, width=50):
  12.         self.x = 0
  13.         self.y = 0
  14.         self.maker = turtle.Turtle()
  15.         self.width = width if width > 20 else 50
  16.  
  17.     def make(self):
  18.         """ Method to make a cake... """
  19.         self.maker.shape('turtle')
  20.         self.maker.penup()
  21.         self.maker.color('pink')
  22.         self.maker.goto(self.x, self.y)
  23.         self.maker.pendown()
  24.         self.maker.begin_fill()
  25.         self.maker.goto(self.x + self.width, self.y)
  26.         self.maker.goto(self.x + self.width, self.y + self.width)
  27.         self.maker.goto(self.x - self.width, self.y + self.width)
  28.         self.maker.goto(self.x - self.width, self.y)
  29.         self.maker.goto(self.y, self.y)
  30.         self.maker.end_fill()
  31.         self.maker.goto(self.x, self.y + self.width)
  32.         self.maker.color('yellow')
  33.         self.maker.goto(self.x, self.y + self.width + 25)
  34.         self.maker.goto(self.x, self.y + self.width + 20)
  35.         self.maker.color('black')
  36.         self.maker.goto(self.x, self.y + self.width)
  37.         self.maker.penup()
  38.         self.maker.goto(self.x, self.y + self.width - 20)
  39.  
  40. x, y = 0, 0
  41. cake = Cake(x, y)
  42. cake.make()
  43. turtle.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement