Ejemplo n.º 1
0
from shapes import Paper, Triangle, Rectangle, Oval

paper = Paper()

rect1 = Rectangle()
rect1.set_width(200)
rect1.set_height(100)
rect1.set_color("blue")

rect1.draw()

rect2 = Rectangle()
rect2.set_x(50)
rect2.set_y(30)
rect2.set_width(200)
rect2.set_height(100)
rect2.set_color("orange")

rect2.draw()

paper.display()
Ejemplo n.º 2
0
from shapes import Paper, Triangle, Rectangle, Oval

paper = Paper()

rect1 = Rectangle()
rect1.set_width(200)
rect1.set_width(100)
rect1.set_color("blue")

rect1.draw()

rect2 = Rectangle()
rect2.set_x(100)
rect2.set_y(100)
rect2.set_width(100)
rect2.set_width(50)
rect2.set_color("red")

rect2.draw()

oval = Oval()
oval.randomize()

oval.draw()

triangle = Triangle(5, 5, 100, 100, 200, 100)
triangle.set_x(150)
triangle.set_y(250)
triangle.set_color("green")

triangle.draw()
Ejemplo n.º 3
0
from shapes import Triangle, Rectangle, Oval

class MyGUI:
    def __init__(self, master):
        self.master = master
        master.title("A simple GUI")

        self.label = Label(master, text="This is the Root Window")
        self.label.pack()

        self.close_button = Button(master, text="Close", command=master.quit)
        self.close_button.pack()

rectangle1 = Rectangle()

rectangle1.set_width(200)
rectangle1.set_height(100)
rectangle1.set_color("blue")
rectangle1.set_x(50)
rectangle1.set_y(250)

triangle1 = Triangle()
# triangle1.randomise()
triangle1.set_color("red")
triangle1.x=150
triangle1.y=150
triangle1.x2=150
triangle1.y2=200
triangle1.x3=200
triangle1.y3=150
Ejemplo n.º 4
0
from shapes import Triangle, Rectangle, Oval
import random

for i in range(100):
    r = Rectangle()
    r.set_width(random.randint(10, 100))
    r.set_height(random.randint(10, 100))
    r.set_x(random.randint(10, 500))
    r.set_y(random.randint(10, 500))
    col = random.randint(1, 6)
    if col == 1:
        r.set_color("red")
    elif col == 2:
        r.set_color("blue")
    elif col == 3:
        r.set_color("green")
    elif col == 4:
        r.set_color("purple")
    elif col == 5:
        r.set_color("orange")
    else:
        r.set_color("yellow")
    r.draw()
Ejemplo n.º 5
0
from shapes import Triangle, Rectangle, Oval

rect = Rectangle()
rect.set_width(200)
rect.set_height(100)
rect.set_color('blue')
rect.draw()


square = Rectangle()
square.set_width(50)
square.set_height(50)
square.set_color('yellow')
square.set_x(120)
square.set_y(120)
square.draw()

tri = Triangle(5, 5, 100, 5, 100, 200)
tri.set_color('red')
tri.draw()
Ejemplo n.º 6
0
from shapes import Triangle, Rectangle, Oval, Paper

sky = Rectangle()
sky.set_x(100)
sky.set_y(100)
sky.set_width(400)
sky.set_height(200)
sky.set_color("lightblue")
sky.draw()

sun = Oval()
sun.set_width(75)
sun.set_height(75)
sun.set_x(400)
sun.set_y(125)
sun.set_color("yellow")
sun.draw()

grass = Rectangle()
grass.set_x(100)
grass.set_y(300)
grass.set_width(400)
grass.set_height(200)
grass.set_color("green")
grass.draw()

wall = Rectangle()
wall.set_x(150)
wall.set_y(250)
wall.set_width(300)
wall.set_height(175)
Ejemplo n.º 7
0
from shapes import Paper, Rectangle

paper = Paper()

rect = Rectangle()
rect.set_color('yellow')
rect.set_height(50)
rect.set_width(150)
rect.draw()
rect.set_x(0)
rect.set_y(0)

rect2 = Rectangle()
rect2.set_color('blue')
rect2.set_height(10)
rect2.set_width(10)
rect2.draw()
rect2.set_x(150)
rect2.set_y(200)

paper.display()
# RENNIE THE ROBOT
# FUTURELEARN, SEPTEMBER 03,2017
# Ashmead ALI

from shapes import Triangle, Rectangle, Oval

mouth = Rectangle()
mouth.set_width(200)
mouth.set_height(100)
mouth.set_color('blue')
mouth.set_x(200)
mouth.set_y(450)
mouth.draw()

nose = Oval()
nose.set_width(100)
nose.set_height(100)
nose.set_color('red')
nose.set_x(250)
nose.set_y(250)
nose.draw()

left_eye = Rectangle()
left_eye.set_width(100)
left_eye.set_height(100)
left_eye.set_color('blue')
left_eye.set_x(100)
left_eye.set_y(100)
left_eye.draw()

left_pupil = Oval()
Ejemplo n.º 9
0
from shapes import Triangle, Rectangle, Oval

rect1 = Rectangle()

rect1.set_width(200)
rect1.set_height(100)
rect1.set_color("blue")
rect1.draw()

rec2 = Rectangle()

rec2.set_width(50)
rec2.set_height(150)
rec2.set_color("yellow")
rec2.draw()
rec2.set_x(100)
rec2.set_y(100)

ov1 = Oval()

ov1.randomize(20)
ov1.draw()

tri1 = Triangle(5, 10, 100, 5, 100, 200)
tri1.draw()
Ejemplo n.º 10
0
from shapes import Oval, Rectangle, Triangle, Paper
canvas = Paper()

rect1 = Rectangle()
rect1.set_width(10)
rect1.set_height(10)
rect1.set_color('red')
rect1.set_x(100)
rect1.set_y(100)

rect1.draw()

rect2 = Rectangle()
rect2.set_width(10)
rect2.set_height(10)
rect2.set_color('red')
rect2.set_x(200)
rect2.set_y(100)

tri = Triangle(160, 160, 170, 170, 150, 170)
tri.set_color('green')
tri.set_x(150)
tri.set_y(150)

rect3 = Rectangle()
rect3.set_width(100)
rect3.set_height(10)
rect3.set_color('red')
rect3.set_x(100)
rect3.set_y(200)
Ejemplo n.º 11
0
from shapes import Triangle, Oval, Rectangle
from random import randint


rect1 = Rectangle()
rect1.set_width(200)
rect1.set_height(100)
rect1.set_color("blue")

rect2 = Rectangle()
rect2.set_width(randint(10,150))
rect2.set_height(randint(10,150))
rect2.set_color("red")
rect2.set_x(randint(0,400))
rect2.set_y(randint (0,400))

ovl1=Oval()
ovl1.randomize()

tri1 = Triangle()
tri1.randomize()
Ejemplo n.º 12
0
from shapes import Triangle, Rectangle, Oval

r1 = Rectangle()
r1.set_width(200)
r1.set_height(100)
r1.set_color("blue")
r1.draw()

r2 = Rectangle()
r2.set_width(50)
r2.set_height(150)
r2.set_color("yellow")
r2.set_x(100)
r2.set_y(100)
r2.draw()