示例#1
0
def draw_chezrep():
        world=World()
        canvas = world.ca(width=500, height=500, background='white')
	canvas.rectangle([[-150,-100], [150, 100]], outline='black', width=2, fill='white')
	canvas.rectangle([[-150,-100], [150, 15]], outline='black', width=2, fill='red')
        points = [[-150,-100], [-150,100], [0,15]]
        canvas.polygon(points, fill='blue')
        world.mainloop()
示例#2
0
def flag_czech():
	world=World()
	canvas=world.ca(width=1500, height=500, background='white')
	points = [[0,00], [150, -100], [0, -200]]
	canvas.polygon(points, fill='blue4')
	points=[[0,00],[500,00],[500,-100],[150,-100],[0,00]]
	canvas.polygon(points, fill='white', outline='black')
	points=[[150,-100],[500,-100],[500,-200],[0,-200],[150,-100]]
	canvas.polygon(points, fill='red',outline='black')
	world.mainloop()
def draw_circle(cir):
    hello = World()
    e = hello.ca(width=window.width,
                 height=window.height,
                 background=window.color)
    e.circle([cir.point.x, cir.point.y],
             cir.radius,
             outline="green",
             fill="black")
    hello.mainloop()
def czech_flag():
	c=canvas()
	c.w=500
	c.h=500

	r1=rectangle()
	r1.color='red'

	r1.p1=point()
	r1.p1.x=-200
	r1.p1.y=-200

	r1.p2=point()
	r1.p2.x=200
	r1.p2.y=0

	r2=rectangle()
	r2.color='white'
	r2.p1=point()
	r2.p1.x=-200
	r2.p1.y=0

	r2.p2=point()
	r2.p2.x=200
	r2.p2.y=200

	world=World()
	can=world.ca(width=c.w,height=c.h,background='white')

	bbox1=[[r1.p1.x,r1.p1.y],[r1.p2.x,r1.p2.y]]
	can.rectangle(bbox1,outline='black',width=1,fill=r1.color)

	bbox2=[[r2.p1.x,r2.p1.y],[r2.p2.x,r2.p2.y]]
	can.rectangle(bbox2,outline='black',width=1,fill=r2.color)

	points = [[-200,-200], [-200, 200], [0, 0]]
	can.polygon(points, fill='blue')

	world.mainloop()
示例#5
0
def main():
	box = rectangle()
	box.width = 100.0
	box.height = 200.0
	box.ll = point()
	box.ll.x = 10.0
	box.ll.y=10.0
	box.ur = point()
	box.ur.x = 200.0
	box.ur.y=200.0
	box.color='red'
	bbox=[[box.ll.x,box.ll.y],[box.ur.x,box.ur.y]]
	world=World()
	canvas=world.ca(width=500, height=500, background='white')
	draw_rectangle(canvas,box)
	draw_point(canvas,box.ll)
	circle=Circle()
	circle.center=point()
	circle.center.x=100.0
	circle.center.y=100.0
	circle.radius=10.0
	draw_circle(canvas,circle)

	world.mainloop()
示例#6
0
    rect1=Rectangle()
    rect2=Rectangle()
    rect1.color='white'
    rect2.color='red'
    dimensions(rect1,300,100)
    dimensions(rect2,300,100)
    corner(rect1,-150,0)
    corner(rect2,-150,-100)
    print (find_center(rect1))

    circle=Circle()
    center(circle,-25,0)
    circle.radius=70
    circle.color='blue'


    world=World()
    canvas = world.ca(width=500, height=500, background='white')

    draw_point(canvas,point1)
    draw_rectangle(canvas, rect1)
    draw_rectangle(canvas, rect2)
    points=[[-150,-100],[-150,100],[-150+(100*(3**0.5)),0]]
    canvas.polygon(points,fill='blue')

    world.mainloop()



示例#7
0
#!/usr/bin/python

from swampy.World import World
from rectangle import Rectangle, Point

def draw_rectangle(Canvas, Rectangle):
    bbox = [[Rectangle.corner.x, Rectangle.corner.y], 
            [Rectangle.corner.x + Rectangle.width, 
             Rectangle.corner.y + Rectangle.height]]
    Canvas.rectangle(bbox, outline="black", width=2, fill="green4")
    

world = World()

canvas = world.ca(width=500, height=500, background="white")
box = Rectangle()
box.corner = Point()
box.corner.x = 50
box.corner.y = 50
box.width = 100
box.height = 100

draw_rectangle(canvas, box)
world.mainloop()
def main():
    # Create World object
    # print  sys.version_info
    world = World()
    # Create our canvas
    canvas = create_canvas(world, 500, 500, 'grey')
    # canvas = world.ca(width=500, height=500, background='white')
    # Create our rectangle
    my_rect = create_rectangle(100, 200, 'blue')
    # Create a new Point object
    new_point = Point()
    # Put new point at 0,0
    new_point.x = -30
    new_point.y = -30

    draw_point(canvas, new_point)

    my_circle = create_circle(new_point, 5, 'green')
    # draw_circle(canvas, my_circle)

    my_circle = create_circle(new_point, 30, 'red')
    # draw_circle(canvas, my_circle)


    # Polygon are made of points, so we should create a list of points
    point_a = Point(-100, -100)
    point_b = Point(50, 0)
    point_c = Point(-100, 100)

    my_points = (point_a, point_b, point_c)

    my_polygon = Polygon()
    # Create an attribute that is a list
    my_polygon.points = []
    # Append our point objects to the Polygon object's list
    my_polygon.points.append(point_a)
    my_polygon.points.append(point_b)
    my_polygon.points.append(point_c)

    # Add fill color attribute
    my_polygon.fill = 'blue'

    # After the polygon has all the points in question, we need a "draw_polygon"
    # function.
    draw_polygon(canvas, my_polygon)

    # Polygon are made of points, so we should create a list of points
    point_a = Point(-100, -100)
    point_b = Point(50, 0)
    point_c = Point(200, 0)
    point_d = Point(200,-100)
    my_points = (point_a, point_b, point_c, point_d)
    
    my_polygon = Polygon()
    # Create an attribute that is a list
    my_polygon.points = []
    # Append our point objects to the Polygon object's list
    my_polygon.points.append(point_a)
    my_polygon.points.append(point_b)
    my_polygon.points.append(point_c)
    my_polygon.points.append(point_d)
    
    # Add fill color attribute
    my_polygon.fill = 'red'
    # After the polygon has all the points in question, we need a "draw_polygon"
    # function.
    draw_polygon(canvas, my_polygon)


    # Polygon are made of points, so we should create a list of points
    point_a = Point(-100, 100)
    point_b = Point(50, 0)
    point_c = Point(200, 0)
    point_d = Point(200, 100)
    my_points = (point_a, point_b, point_c, point_d)
    
    my_polygon = Polygon()
    # Create an attribute that is a list
    my_polygon.points = []
    # Append our point objects to the Polygon object's list
    my_polygon.points.append(point_a)
    my_polygon.points.append(point_b)
    my_polygon.points.append(point_c)
    my_polygon.points.append(point_d)
    
    # Add fill color attribute
    my_polygon.fill = 'white'
    # After the polygon has all the points in question, we need a "draw_polygon"
    # function.
    draw_polygon(canvas, my_polygon)


    world.mainloop()
示例#9
0
def draw_point(c,p):
	world=World()
	can=world.ca(width=c.w,height=c.h,background='white')
	pt=[[p.x,p.y],[p.x,p.y]]
	can.rectangle(pt)
	world.mainloop()
示例#10
0
def draw_circle(c,cir):
	world=World()
	can=world.ca(width=c.w,height=c.h,background='white')
	can.circle(cir.o,cir.r,outline='black',width=2,fill='red')
	world.mainloop()
示例#11
0
def draw_rectangle(c,r):
	world=World()
	can=world.ca(width=c.w,height=c.h,background='white')
	bbox=[[r.p1.x,r.p1.y],[r.p2.x,r.p2.y]]
	can.rectangle(bbox,outline='black',width=0,fill=r.color)
	world.mainloop()
示例#12
0
def draw_point(x,y):
        point=World()
        canvas=point.ca(width=500,height=500,background='white')
        bbox=[[x,y],[x,y]]
        canvas.rectangle(bbox)
        point.mainloop()
示例#13
0
def draw_rec(x,y,col):
	world=World()
	canvas = world.ca(width=500, height=500, background='white')
	bbox = [[-x,-y], [x, y]]
	canvas.rectangle(bbox, outline='black', width=2, fill=col)
	world.mainloop()