Exemple #1
0
def between(x, y, x2, y2, outie=10, angle=45, color=PUR_3, width=4):
    """outie direction is billowing if it were traveling counterclockwise"""
    points = []
    sb = ShapeBuilder()
    points.append('{0},{1}'.format(x, y))
    slope = slope_angle(x, y, x2, y2)
    out_angle = slope + angle
    out_r = out_angle * math.pi / 180
    next_x = x + outie * math.cos(out_r)
    next_y = y - outie * math.sin(out_r)
    points.append('{0},{1}'.format(next_x, next_y))
    slope_r = slope * math.pi / 180

    distance = math.sqrt((x2 - x)**2 + (y2 - y)**2)
    flat_len = distance - 2 * outie * (math.cos(out_r))
    next_x2 = next_x + flat_len * math.cos(slope_r)
    next_y2 = next_y - flat_len * math.sin(slope_r)

    points.append('{0},{1}'.format(next_x2, next_y2))
    points.append('{0},{1}'.format(x2, y2))
    line = sb.createPolyline(points=' '.join(points))
    style = 'fill:{0};stroke-width:{1};stroke:{2};stroke-linecap:round'.format(
        ALPHA, width, color)
    line.set_style(style)
    return [line]
def between(x,y, x2,y2, outie=10, angle=45,
            color=PUR_3, width=4):
    """outie direction is billowing if it were traveling counterclockwise"""
    points = []
    sb = ShapeBuilder()
    points.append('{0},{1}'.format(x,y))
    slope = slope_angle(x,y, x2,y2)
    out_angle = slope + angle
    out_r = out_angle* math.pi/180
    next_x = x+ outie*math.cos(out_r)
    next_y = y - outie*math.sin(out_r)
    points.append('{0},{1}'.format(next_x, next_y))
    slope_r = slope*math.pi/180

    distance = math.sqrt((x2-x)**2 + (y2-y)**2)
    flat_len = distance - 2 * outie*(math.cos(out_r))
    next_x2 = next_x + flat_len*math.cos(slope_r)
    next_y2 = next_y - flat_len*math.sin(slope_r)

    points.append('{0},{1}'.format(next_x2, next_y2))
    points.append('{0},{1}'.format(x2,y2))
    line = sb.createPolyline(points=' '.join(points))
    style = 'fill:{0};stroke-width:{1};stroke:{2};stroke-linecap:round'.format(ALPHA, width, color)
    line.set_style(style)
    return [line]
Exemple #3
0
def diff(spikes=9, radius=10):
    points = []
    sb = ShapeBuilder()

    for i, angle in enumerate(xrange(0, 360 + 1, float(180) / spikes)):
        if i % 2 == 0:
            r = radius * .8
        else:
            r = radius
        radians = angle * math.pi / 180
        coord = '{0},{1}'.format(r * math.cos(radians), r * math.sin(radians))
        print "ANGLE", angle, "COOR", coord, "RAD", radians
        points.append(coord)
    print "POINTS", points
    line = sb.createPolyline(points=' '.join(points))
    fill = BLACK
    stroke = ORANGE_3
    style = 'fill:{0};stroke-width:{1};stroke:{2}'.format(fill, 2, stroke)
    line.set_style(style)
    return [line]
def diff(spikes=9, radius=10):
    points = []
    sb = ShapeBuilder()

    for i, angle in enumerate(xrange(0, 360+1, float(180)/spikes)):
        if i % 2 == 0:
            r = radius * .8
        else:
            r = radius
        radians = angle * math.pi/180
        coord = '{0},{1}'.format(r*math.cos(radians),
                                 r*math.sin(radians))
        print "ANGLE", angle, "COOR", coord, "RAD", radians
        points.append(coord)
    print "POINTS", points
    line = sb.createPolyline(points=' '.join(points))
    fill = BLACK
    stroke = ORANGE_3
    style = 'fill:{0};stroke-width:{1};stroke:{2}'.format(fill, 2, stroke)
    line.set_style(style)
    return [line]