Exemple #1
0
    def first_time(self, argv):
        path_b_name="star.svgd"
        if len(argv) > 1:
            path_b_name = argv[1]
        self.paths_b = py2geom.read_svgd(path_b_name)
        
	bounds = py2geom.bounds_exact(self.paths_b)
        self.offset_handle.pos = bounds.midpoint() - bounds.corner(0)

        self.bs = cleanup(self.paths_b)
Exemple #2
0
    def first_time(self, argv):
        path_b_name = "star.svgd"
        if len(argv) > 1:
            path_b_name = argv[1]
        self.paths_b = py2geom.read_svgd(path_b_name)

        bounds = py2geom.bounds_exact(self.paths_b)
        self.offset_handle.pos = bounds.midpoint() - bounds.corner(0)

        self.bs = cleanup(self.paths_b)
Exemple #3
0
    def draw(self, cr, pos, save):
        cr.set_source_rgba(0., 0., 0., 1)
        cr.set_line_width(1)

        pws = [self.pwsbh[i].value() for i in range(self.curves)]
        for p in pws:
            cairo_pw(cr, p)
        cr.stroke()

        d = locals().copy()
        for i in dir(py2geom):
            d[i] = py2geom.__dict__[i]
        d['l2s'] = l2s
        d['constant'] = constant
        pw_out = eval(self.func, d)

        bs = py2geom.bounds_local(
            pw_out,
            py2geom.OptInterval(
                py2geom.Interval(self.interval_test[0].pos[0],
                                 self.interval_test[1].pos[0])))
        if not bs.isEmpty():
            bs = bs.toInterval()
            for ph in self.interval_test:
                ph.pos = py2geom.Point(ph.pos[0], bs.middle())
            cr.save()
            cr.set_source_rgba(.0, 0.25, 0.5, 1.)
            cr.rectangle(
                self.interval_test[0].pos[0], bs.min(),
                self.interval_test[1].pos[0] - self.interval_test[0].pos[0],
                bs.extent())
            cr.stroke()
        bs = py2geom.bounds_exact(pw_out)
        cr.set_source_rgba(0.25, 0.25, .5, 1.)
        if not bs.isEmpty():
            bs = bs.toInterval()
            cairo_horiz(cr, bs.middle(), pw_out.cuts)
            cr.stroke()
        cr.restore()

        cr.set_source_rgba(0., 0., .5, 1.)
        cairo_pw(cr, pw_out)
        cr.stroke()

        self.notify = str(bs)
        toyframework.Toy.draw(self, cr, pos, save)
Exemple #4
0
    def draw(self, cr, pos, save):
        cr.set_source_rgba (0., 0., 0., 1)
        cr.set_line_width (1)
        
        pws = [self.pwsbh[i].value() for i in range(self.curves)]
        for p in pws:
            cairo_pw(cr, p)
        cr.stroke()
        
        d = locals().copy()
        for i in dir(py2geom):
            d[i] = py2geom.__dict__[i]
        d['l2s'] = l2s
        d['constant'] = constant
        pw_out = eval(self.func, d)

        bs = py2geom.bounds_local(pw_out, py2geom.OptInterval(
                          py2geom.Interval(self.interval_test[0].pos[0], 
                                           self.interval_test[1].pos[0])));
        if not bs.isEmpty():
            bs = bs.toInterval()
            for ph in self.interval_test:
                ph.pos= py2geom.Point(ph.pos[0], bs.middle())
            cr.save()
            cr.set_source_rgba (.0, 0.25, 0.5, 1.)
            cr.rectangle(self.interval_test[0].pos[0], bs.min(),
                         self.interval_test[1].pos[0]-self.interval_test[0].pos[0], bs.extent())
            cr.stroke()
        bs = py2geom.bounds_exact(pw_out);
        cr.set_source_rgba (0.25, 0.25, .5, 1.);
        if not bs.isEmpty():
            bs = bs.toInterval()
            cairo_horiz(cr, bs.middle(), pw_out.cuts);
            cr.stroke()
        cr.restore()

        cr.set_source_rgba (0., 0., .5, 1.);
        cairo_pw(cr, pw_out)
        cr.stroke()


        self.notify = str(bs)
        toyframework.Toy.draw(self, cr, pos, save)