Example #1
0
def wheel(cr, w=0.4, h=0.15):
    with cairo_save(cr):

        def shape():
            roundedrec(cr, -w / 2.0, -h / 2.0, w, h, r=min(w, h) / 3.0)

        cairo_plot_with_style(cr, shape, **CairoConstants.robot_wheel_style)
Example #2
0
def cairo_robot_skin_brai(cr, w=1.3, h=0.8, sensors=False):
    with cairo_save(cr):
        x0 = -.3
        wheel_h = 0.15
        wheel_w = 0.4
        M = h / 2 + .8 * wheel_h

        def body():
            roundedrec(cr, x0, -h / 2, w, h, r=min(w, h) / 8.0)
            # cr.rectangle(x0, -h / 2, w, h)

        cr.move_to(0, M)
        cr.line_to(0, -M)
        cairo_set_color(cr, BLACK)
        cr.set_line_width(0.05)
        cr.stroke()

        cairo_plot_with_style(cr, body, **CairoConstants.robot_body_style)

        for y in [-M, +M]:
            with cairo_transform(cr, t=[0, y]):
                wheel(cr, w=wheel_w, h=wheel_h)

        if sensors:
            for y in [.3 * h, -.3 * h]:
                with cairo_transform(cr, t=[0, y]):
                    cr.set_line_width(CairoConstants.robot_border_width)
                    cairo_set_color(cr, CairoConstants.robot_border_color)
                    cr.move_to(0, 0)
                    cr.line_to(1.1, 0)
                    cr.stroke()
                    r = .1
                    with cairo_transform(cr, t=[1.1 + r, 0]):
                        cr.arc(0, 0, r, +np.pi / 2, -np.pi / 2)
                        cr.stroke()
Example #3
0
def cairo_robot_skin_roundedrec(cr, w, h, r=None):
    if r is None:
        r = min(w, h) / 3.0
    with cairo_save(cr):

        def shape():
            roundedrec(cr, -w / 2.0, -h / 2.0, w, h, r=r)

        cairo_plot_with_style(cr, shape, **CairoConstants.robot_body_style)