Esempio n. 1
0
def stars():
    gc = GraphicsContext((500, 500))
    gc.translate_ctm(250, 300)
    add_star(gc)
    gc.draw_path()

    gc.translate_ctm(0, -100)
    add_star(gc)
    gc.set_fill_color((0.0, 0.0, 1.0))
    gc.draw_path(constants.EOF_FILL_STROKE)
    file_path = tempfile.mktemp(suffix='.bmp')
    gc.save(file_path)
    return file_path
Esempio n. 2
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. 3
0
def simple():
    gc = GraphicsContext((499, 500))
    gc.set_fill_color((0, 0, 0))
    gc.rect(99, 100, 300, 300)
    gc.draw_path()
    gc.save(tempfile.mktemp(suffix=".bmp"))

    # directly manipulate the underlying Numeric array.
    # The color tuple is expressed as BGRA.
    gc.bmp_array[:99, :100] = (139, 60, 71, 255)
    file_path = tempfile.mktemp(suffix='.bmp')
    gc.save(file_path)

    return file_path
Esempio n. 4
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