コード例 #1
0
def grayscale_image():
    gw = GWindow(GWINDOW_WIDTH, GWINDOW_HEIGHT)
    image = GImage(IMAGE_FILENAME)
    gw.add(image, (gw.get_width() - IMAGE_SEP) / 2 - image.get_width(),
                  (gw.get_height() - image.get_height()) / 2)
    grayscale = create_grayscale_image(image)
    gw.add(grayscale, (gw.get_width() + IMAGE_SEP) / 2,
                      (gw.get_height() - image.get_height()) / 2)
コード例 #2
0
def draw_hexagon():
    """
    Draws a hexagon at the center of the graphics window.
    """
    gw = GWindow(GWINDOW_WIDTH, GWINDOW_HEIGHT)
    gw.add(create_hexagon(HEXAGON_SIDE),
           gw.get_width() / 2,
           gw.get_height() / 2)
コード例 #3
0
    obj = GCompound()

    cube = GRect(0, 0, width, height)
    cube.set_filled(True)
    cube.set_color(random_color())
    obj.add(cube)

    dvdtext = GLabel("DVD")
    dvdtext.set_font("bold 60px 'serif'")
    obj.add(dvdtext, width / 2 - dvdtext.get_width() / 2, height / 2 - 10)

    vidtext = GLabel("video")
    vidtext.set_font("bold 50px 'serif'")
    vidtext.set_color("white")
    obj.add(vidtext, width / 2 - vidtext.get_width() / 2,
            height / 2 + vidtext.get_ascent())

    return obj


gw = GWindow(800, 600)
# Setting a black background so it looks like the tv
bg = GRect(0, 0, gw.get_width(), gw.get_height())
bg.set_filled(True)
bg.set_color('black')
gw.add(bg)
# Create and add the logo
logo = create_object()
gw.add(logo, 300, 200)