Ejemplo n.º 1
0
    def create_graphics_context(self, width=300, height=300):
        from reportlab.pdfgen.canvas import Canvas
        from kiva.pdf import GraphicsContext

        filename = "{0}.pdf".format(self.filename)
        canvas = Canvas(filename, (width, height))
        return GraphicsContext(canvas)
Ejemplo n.º 2
0
def font_metrics_provider():
    from reportlab.pdfgen.canvas import Canvas
    from reportlab.lib.pagesizes import letter
    from kiva.api import Font

    # a file will not be created unless save() is called on the context
    pdf_canvas = Canvas(filename="enable_tmp.pdf", pagesize=letter)
    gc = GraphicsContext(pdf_canvas)
    gc.set_font(Font())
    return gc
Ejemplo n.º 3
0
    gc.set_stroke_color((0.0, 0.0, 0.0, 1.0))
    gc.move_to(w / 3, h / 2)

    gc.arc_to(w / 3, 2 * h / 3,
              w / 2, 2 * h / 3,
              r)
    gc.arc_to(2 * w / 3, 2 * h / 3,
              2 * w / 3, h / 2,
              r)
    gc.arc_to(2 * w / 3, h / 3,
              w / 2, h / 3,
              r)
    gc.arc_to(w / 3, h / 3,
              w / 3, h / 2,
              r)
    gc.line_to(w / 3, h / 2)
    gc.stroke_path()


canvas = Canvas(filename="arcs.pdf", pagesize=letter)
gc = GraphicsContext(canvas)

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))
gc.rect(95, 95, 10, 10)
gc.fill_path()
draw_ellipse(gc, 100, 100, 35.0, 25.0, pi / 6)
draw_round_rect(gc)
gc.save()