Пример #1
0
    def spline(self, points):
        p0 = points[0:2]
        x1 = p0[0]
        y1 = p0[1]

        p1 = points[2:4]
        c = p1[0]
        d = p1[1]

        x3 = (x1 + c) / 2.0
        y3 = (y1 + d) / 2.0

        self.stream += op.join(op.moveto(x1, y1), op.lineto(x3, y3))

        for i in range(2, len(points) / 2):
            point = points[i * 2], points[i * 2 + 1]
            x1 = x3
            y1 = y3
            x2 = c
            y2 = d
            c = point[0]
            d = point[1]
            x3 = (x2 + c) / 2.0
            y3 = (y2 + d) / 2.0
            self.stream += op.curveto(x1, y1, x2, y2, x3, y3)

        self.stream += op.stroke()
Пример #2
0
 def line(self, x0, y0, x1, y1):
     self.stream += op.join(op.moveto(x0, y0), op.lineto(x1, y1),
                            op.stroke())
Пример #3
0
 def triangle(self, x0, y0, x1, y1, x2, y2):
     self.stream += op.join(op.moveto(x0, y0), op.lineto(x1, y1),
                            op.lineto(x2, y2), op.fill_even_odd(),
                            op.close_and_stroke())
Пример #4
0
 def text(self, x, y, size, string, fontId=1):
     self.stream += op.join(op.begin_text(), op.text_font(fontId, size),
                            op.text_offset(x, y), op.show_string(string),
                            op.end_text())