Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # coding:utf-8
- """ Draw a cake in screen with python 2.x
- Author: Reni Dantas
- """
- import turtle
- import random
- class Cake(object):
- """ Class to make a cake, riariaria """
- def __init__(self, x=0, y=0, width=50):
- self.x = 0
- self.y = 0
- self.maker = turtle.Turtle()
- self.width = width if width > 20 else 50
- def make(self):
- """ Method to make a cake... """
- self.maker.shape('turtle')
- self.maker.penup()
- self.maker.color('pink')
- self.maker.goto(self.x, self.y)
- self.maker.pendown()
- self.maker.begin_fill()
- self.maker.goto(self.x + self.width, self.y)
- self.maker.goto(self.x + self.width, self.y + self.width)
- self.maker.goto(self.x - self.width, self.y + self.width)
- self.maker.goto(self.x - self.width, self.y)
- self.maker.goto(self.y, self.y)
- self.maker.end_fill()
- self.maker.goto(self.x, self.y + self.width)
- self.maker.color('yellow')
- self.maker.goto(self.x, self.y + self.width + 25)
- self.maker.goto(self.x, self.y + self.width + 20)
- self.maker.color('black')
- self.maker.goto(self.x, self.y + self.width)
- self.maker.penup()
- self.maker.goto(self.x, self.y + self.width - 20)
- x, y = 0, 0
- cake = Cake(x, y)
- cake.make()
- turtle.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement