Exemplo n.º 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()
Exemplo n.º 2
0
 def line(self, x0, y0, x1, y1):
     self.stream += op.join(op.moveto(x0, y0), op.lineto(x1, y1),
                            op.stroke())
Exemplo n.º 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())
Exemplo n.º 4
0
 def polyline(self, points):
     self.stream += op.moveto(points[0], points[1])
     for i in range(1, len(points) / 2):
         point = points[i * 2], points[i * 2 + 1]
         self.stream += op.lineto(*point)
     self.stream += op.stroke()