Esempio n. 1
0
def simple():
    gc = GraphicsContext((100, 100))

    gc.clear()
    gc.set_line_cap(constants.CAP_SQUARE)
    gc.set_line_join(constants.JOIN_MITER)
    gc.set_stroke_color((1, 0, 0))
    gc.set_fill_color((0, 0, 1))
    gc.rect(0, 0, 30, 30)
    gc.draw_path()
    file_path = tempfile.mktemp(suffix='.bmp')
    gc.save(file_path)
    return file_path
Esempio n. 2
0
def stars():
    gc = GraphicsContext((500, 500))

    with gc:
        gc.set_alpha(0.3)
        gc.set_stroke_color((1.0, 0.0, 0.0))
        gc.set_fill_color((0.0, 1.0, 0.0))

        for i in range(0, 600, 5):
            with gc:
                gc.translate_ctm(i, i)
                gc.rotate_ctm(i * pi / 180.)
                add_star(gc)
                gc.draw_path()

    gc.set_fill_color((0.5, 0.5, 0.5, 0.4))
    gc.rect(150, 150, 200, 200)
    gc.fill_path()
    file_path = tempfile.mktemp(suffix='.bmp')
    gc.save(file_path)
    return file_path