Esempio n. 1
0
def main():
    gc = GraphicsContext((500, 500))

    gc.scale_ctm(1.25, 1.25)
    draw(gc)

    gc.save(splitext(__file__)[0] + '.png', file_format='png')
Esempio n. 2
0
def gradient():
    gc = GraphicsContext((500, 500))
    gc.scale_ctm(1.25, 1.25)
    draw(gc)
    file_path = tempfile.mktemp(suffix='.png')
    gc.save(file_path, file_format='png')
    return file_path
Esempio n. 3
0
def main():
    gc = GraphicsContext((500, 500))

    gc.scale_ctm(1.25, 1.25)
    draw(gc)

    gc.save(splitext(__file__)[0]+'.png', file_format='png')
Esempio n. 4
0
def rect():
    gc = GraphicsContext((500, 500))
    gc.clear()
    gc.rect(100, 100, 300, 300)
    gc.draw_path()
    file_path = tempfile.mktemp(suffix='.bmp')
    gc.save(file_path)
    return file_path
Esempio n. 5
0
 def save(self, path):
     """ Save the contents of the component to a file.
     """
     # 100 DPI dimensions of the Macbook Pro 15"
     size = (1435, 982)
     gc = GraphicsContext(size)
     self.component.draw(gc)
     gc.save(path)
Esempio n. 6
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. 7
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. 8
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. 9
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
Esempio n. 10
0
    font = Font(face_name="Arial", size=32)
    gc.set_font(font)
    gc.translate_ctm(100.0, 100.0)
    gc.move_to(-5, 0)
    gc.line_to(5, 0)
    gc.move_to(0, 5)
    gc.line_to(0, -5)
    gc.move_to(0, 0)
    gc.stroke_path()
    txtRot = agg.rotation_matrix(PI / 6)
    gc.set_text_matrix(txtRot)
    gc.show_text("Hello")
    txtRot.invert()
    gc.set_text_matrix(txtRot)

    gc.show_text("inverted")


if __name__ == "__main__":
    tests = (
        (test_clip_stack, "clip_stack.png"),
        (test_arc_to, "arc_to.png"),
        (test_handling_text, "handling_text.png"),
    )

    for test_func, filename in tests:
        img = GraphicsContext((800, 600))
        img.clear(WHITE)
        test_func(img)
        img.save(filename)
Esempio n. 11
0
def test_handling_text(gc):
    font = Font(face_name="Arial", size = 32)
    gc.set_font(font)
    gc.translate_ctm(100.0, 100.0)
    gc.move_to(-5,0)
    gc.line_to(5,0)
    gc.move_to(0,5)
    gc.line_to(0,-5)
    gc.move_to(0,0)
    gc.stroke_path()
    txtRot = agg.rotation_matrix(PI/6)
    gc.set_text_matrix(txtRot)
    gc.show_text("Hello")
    txtRot.invert()
    gc.set_text_matrix(txtRot)

    gc.show_text("inverted")



if __name__ == "__main__":
    tests = ((test_clip_stack, "clip_stack.png"),
             (test_arc_to, "arc_to.png"),
             (test_handling_text, "handling_text.png"))

    for test_func, filename in tests:
        img = GraphicsContext((800, 600))
        img.clear(white)
        test_func(img)
        img.save(filename)
Esempio n. 12
0
from enable.kiva_graphics_context import GraphicsContext

gc = GraphicsContext((500,500))
gc.clear()
gc.rect(100,100,300,300)
gc.draw_path()
gc.save("rect.bmp")