コード例 #1
0
ファイル: flies.py プロジェクト: AndreaCensi/vehicles
def cairo_skin_fly1(cr):

    r = 1.0  # will be scaled by robot radius

    with cairo_save(cr):
        cr.scale(0.32, 0.32)

        def wing():
            rw = r
            with cairo_save(cr):
                cr.scale(1.5, 1)
                cairo_plot_circle2(cr, rw / 2, 0, rw,
                           fill_color=[.5, .5, .5])

        wa = 3 / 2
        with cairo_transform(cr, t=[0, wa], r=np.pi / 2):
            wing()

        with cairo_transform(cr, t=[0, -wa], r=(-np.pi / 2)):
            wing()

        with cairo_save(cr):
            cr.scale(1.5, 0.75)
            cairo_plot_circle2(cr, 0, 0, r,
                       fill_color=WHITE, border_color=BLACK,
                       border_width=0.005)

        cairo_plot_circle2(cr, r * 1.5, 0, r / 1.5,
                       fill_color=WHITE, border_color=BLACK,
                       border_width=0.005)
コード例 #2
0
ファイル: robot_skins.py プロジェクト: ajaycharan/vehicles
def cairo_robot_skin_circular(cr):
    with cairo_save(cr):
        cairo_plot_circle2(cr, 0, 0, 1, **CairoConstants.robot_body_style)

        def line():
            cr.move_to(0.2, 0)
            cr.line_to(1, 0)

        cairo_stroke_with_style(cr, line, **CairoConstants.robot_body_style)
コード例 #3
0
def cairo_skin_fly1(cr):

    r = 1.0  # will be scaled by robot radius

    with cairo_save(cr):
        cr.scale(0.32, 0.32)

        def wing():
            rw = r
            with cairo_save(cr):
                cr.scale(1.5, 1)
                cairo_plot_circle2(cr, rw / 2, 0, rw, fill_color=[.5, .5, .5])

        wa = 3 / 2
        with cairo_transform(cr, t=[0, wa], r=np.pi / 2):
            wing()

        with cairo_transform(cr, t=[0, -wa], r=(-np.pi / 2)):
            wing()

        with cairo_save(cr):
            cr.scale(1.5, 0.75)
            cairo_plot_circle2(cr,
                               0,
                               0,
                               r,
                               fill_color=WHITE,
                               border_color=BLACK,
                               border_width=0.005)

        cairo_plot_circle2(cr,
                           r * 1.5,
                           0,
                           r / 1.5,
                           fill_color=WHITE,
                           border_color=BLACK,
                           border_width=0.005)
コード例 #4
0
ファイル: sensor_data.py プロジェクト: ajaycharan/vehicles
def plot_fieldsampler_fancy(cr, positions, sensels, radius=None,
                            alpha=0.2):
    # Scale in [0,1] for better contrast

    sensels = sensels - np.min(sensels)
    if np.max(sensels) > 0:
        sensels = sensels / np.max(sensels)

    # find radius if none given as the minimum distance of the first
    # sensels to the others
    if radius is None:
        radius = find_radius(positions)

    indices = np.array(range(sensels.size))

    # Use completely random permutation
    permutation = np.argsort(RANDOM_PERM[:indices.size])
    # Sort by value
    # permutation = np.argsort(np.array(sensels.flat))

    indices = indices[permutation]

    for i in indices:
        value = sensels.flat[i]
        p = positions[i, :]

        uvalue = value
        facecolor = [uvalue, uvalue, uvalue, value]
        border_color = [0, 0, 0, 0.3 + 0.5 * value]

        radius_i = (alpha + (1 - alpha) * value) * radius

        cairo_plot_circle2(cr, x=p[0], y=p[1], radius=radius_i,
                                fill_color=facecolor,
                                border_color=border_color,
                                border_width=radius / 10.0)
コード例 #5
0
ファイル: sensors.py プロジェクト: ajaycharan/vehicles
def cairo_skin_eye(cr, size=1.0):
    with cairo_save(cr):
        cr.scale(size, size)
        # White part
        cairo_plot_circle2(cr, 0, 0, 1,
                           fill_color=WHITE, border_color=BLACK,
                           border_width=0.05)

        # Brown
        # BROWN1 = [.4, .2, 0]
        BROWN2 = [.6, .3, 0]
        cairo_plot_circle2(cr, 0.5, 0, 0.5,
                           fill_color=BROWN2,
                           border_color=None,
                           border_width=None)

        # Black
        cairo_plot_circle2(cr, 0.6, 0, 0.22,  # 0.25,
                           fill_color=BLACK,
                           border_color=None,
                           border_width=None)
コード例 #6
0
 def wing():
     rw = r
     with cairo_save(cr):
         cr.scale(1.5, 1)
         cairo_plot_circle2(cr, rw / 2, 0, rw, fill_color=[.5, .5, .5])
コード例 #7
0
ファイル: flies.py プロジェクト: AndreaCensi/vehicles
 def wing():
     rw = r
     with cairo_save(cr):
         cr.scale(1.5, 1)
         cairo_plot_circle2(cr, rw / 2, 0, rw,
                    fill_color=[.5, .5, .5])
コード例 #8
0
ファイル: robot_skins.py プロジェクト: ajaycharan/vehicles
def omni_wheel(cr, r=0.15):
    cairo_plot_circle2(cr, 0, 0, r, **CairoConstants.omni_wheel_style)