def plot_ks(segs, nodes, xo, yo, xscale, yscale): j = 0 cmd = 'moveto' x = xo for i in range(len(segs)): i1 = (i + 1) % len(nodes) n0 = nodes[i] n1 = nodes[i1] x0, y0, t0 = n0.x, n0.y, n0.ty x1, y1, t1 = n1.x, n1.y, n1.ty ks = segs[i].ks chord, ch_th = poly3.integ_chord(ks) l = chord/segs[i].chord k0 = l * poly3.eval_cubic(ks[0], ks[1], .5 * ks[2], 1./6 * ks[3], -.5) print x, yo + yscale * k0, cmd cmd = 'lineto' k3 = l * poly3.eval_cubic(ks[0], ks[1], .5 * ks[2], 1./6 * ks[3], .5) k1 = k0 + l/3 * (ks[1] - 0.5 * ks[2] + .125 * ks[3]) k2 = k3 - l/3 * (ks[1] + 0.5 * ks[2] + .125 * ks[3]) print x + xscale / l / 3., yo + yscale * k1 print x + 2 * xscale / l / 3., yo + yscale * k2 print x + xscale / l, yo + yscale * k3, 'curveto' x += xscale / l if t1 == 'v': j += 2 else: j += 1 print 'stroke' print xo, yo, 'moveto', x, yo, 'lineto stroke'
def compute_ends(self, ks): chord, ch_th = poly3.integ_chord(ks) l = chord / self.chord thl = ch_th - (-.5 * ks[0] + .125 * ks[1] - 1./48 * ks[2] + 1./384 * ks[3]) thr = (.5 * ks[0] + .125 * ks[1] + 1./48 * ks[2] + 1./384 * ks[3]) - ch_th k0l = l * (ks[0] - .5 * ks[1] + .125 * ks[2] - 1./48 * ks[3]) k0r = l * (ks[0] + .5 * ks[1] + .125 * ks[2] + 1./48 * ks[3]) l2 = l * l k1l = l2 * (ks[1] - .5 * ks[2] + .125 * ks[3]) k1r = l2 * (ks[1] + .5 * ks[2] + .125 * ks[3]) l3 = l2 * l k2l = l3 * (ks[2] - .5 * ks[3]) k2r = l3 * (ks[2] + .5 * ks[3]) return (thl, k0l, k1l, k2l), (thr, k0r, k1r, k2r), l