예제 #1
0
파일: e1.py 프로젝트: Zhaeong/School
def copyright():
    pic=media.create_picture(20,20)
    black=media.black
    media.add_oval(pic,0,0,16,16,black)
    media.add_text(pic, 6,3,"C",black)
    media.show(pic)
    return pic
예제 #2
0
def draw(pic, root, d, side, curr):
    '''Draw on Picture pic a picture of the tree rooted at BTNode root, which
    appears at depth d in a tree. 'side' is the coordinate that marks the left
    of the tree being drawn, and curr is the currently selected value. Most
    values appear in black; only the value in curr appears in red.'''

    if root != None:
        left_size = bst.size(root.left)

        # the coordinate where the root will be drawn; the root has
        # left_size nodes to the left of it.
        x = side + left_size * NODE_WIDTH

        # The y coordinate of the root value.
        y = d * NODE_HEIGHT

        if curr == root:
            color = media.red
        else:
            color = media.black

        # Draw the current node's value.
        media.add_text(pic, WIDTH_OFFSET + x, HEIGHT_OFFSET + y, \
            str(root.data), color)

        if root.left:
            draw(pic, root.left, d + 1, side, curr)
        if root.right:
            draw(pic, root.right, d + 1, x + NODE_WIDTH, curr)
예제 #3
0
파일: e1.py 프로젝트: Zhaeong/School
def copyright():
    pic = media.create_picture(20, 20)
    black = media.black
    media.add_oval(pic, 0, 0, 16, 16, black)
    media.add_text(pic, 6, 3, "C", black)
    media.show(pic)
    return pic
예제 #4
0
    def draw_board(self):
        '''(self) -> NoneType
        draw player board and opponent board and return in list'''

        # Each space will be 25 pixels long, with a 10 pixel border on top
        board_l = self.l * 25 + 10
        # Each space will be 25 pixels wide, with a 10 pixel border on the side
        board_w = self.w * 25 + 10

        list_boards = []   # list holding boards

        # Draw player's board
        board_player = media.create_picture(board_w, board_l, media.navy)

        # Draw opponent's board
        board_opponent = media.create_picture(board_w, board_l, media.gray)

        list_boards.append(board_player)   # Add player board to list
        list_boards.append(board_opponent)  # Add opponent board to list

        for item in list_boards:  # loop through list of boards to add borders
            # Draw bar along top
            media.add_rect_filled(item, 0, 0, 10, board_l, media.white)
            media.add_rect_filled(item, 0, 0, board_w, 10, media.white)
            counter = 0  # counter for while loop to draw numbers to board
            while counter < self.w:  # loop to draw x coordinates on board
                temp = str(counter)
                x_val = (counter) * 25 + 10
                media.add_text(item, x_val, 2, temp, media.black)
                counter += 1
            counter = 0
            while counter < self.l:  # draw y coordinates on board
                temp = str(counter)
                y_val = (counter) * 25 + 10
                media.add_text(item, 2, y_val, temp, media.black)
                counter += 1

        # Loop through list of player ships to place them on board
        for item in self.coordinates:
            media.add_rect_filled(list_boards[0], item[0] * 25 + 10,\
                                  item[1] * 25 + 10, 25, 25, media.gray)
        media.show(list_boards[0])
        media.show(list_boards[1])

        self.boards = list_boards
예제 #5
0
media.save_as(pic, 'pic207cropped.jpg')

 

 
pic.get_width()
500
pic.get_height()
375
pic.title
'modules/pic207.jpg'

 

 
media.add_text(pic, 115, 40, 'Madeleine', media.magenta)
media.show(pic)

 



 
import media

pic1 = media.load_picture('pic207.jpg')
media.show(pic1)
pic2 = media.load_picture('pic207cropped.jpg')
media.show(pic2)
pic3 = media.load_picture('pic207named.jpg')
media.show(pic3)
import media

f = media.choose_file()
pic = media.load_picture(f)
media.add_text(pic, 115, 40, 'Medeleine', media.magenta)
media.show(pic)