Exemple #1
0
 def allcond(_t):
     from andysSVGpathTools import segUnitTangent
     tt = max(0, min(1, _t.real))
     lin2pt = Line(seg.point(tt), pt)
     real_cond = isclose(_t.imag, 0)
     bezier_cond = (0 < _t.real < 1 or
                    isclose(_t.real, 0) or
                    isclose(_t.real, 1))
     nondeg_cond = (not isclose(seg.derivative(tt), 0) or 
                    isclose(dot_prod(segUnitTangent(seg, tt), lin2pt.unit_tangent()), 0))
     outward_cond = dot_prod(lin2pt.unit_tangent(), -1j*segUnitTangent(seg, tt)) > 0
     
     return real_cond and bezier_cond and nondeg_cond and outward_cond
Exemple #2
0
def displaySVGPaths_transects(ring_list, data_transects, transect_angles, skipped_angle_indices, fn=None):
    if not fn:
        filename = opt.output_directory + ring_list[0].svgname
    else:
        filename = fn

    transectPaths = []
    for tran_index in range(len(data_transects)):
        tran_path = Path()
        for seg_index in range(len(data_transects[tran_index]) - 1):
            start_pt = data_transects[tran_index][seg_index]
            end_pt = data_transects[tran_index][seg_index + 1]
            tran_path.append(Line(start_pt,end_pt))
        transectPaths.append(tran_path)

    ringPaths = [r.path for r in ring_list]
    ringColors = [r.color for r in ring_list]
    pathList = ringPaths + transectPaths
    colors = ringColors + ['black']*len(transectPaths)
    transect_nodes = [item for sublist in data_transects for item in sublist] # flatten data_transects
    nodes = transect_nodes + [ring_list[0].center]
    node_colors = ['purple']*len(transect_nodes) + ['blue']
    text = ['%.3f' % theta for idx, theta in enumerate(transect_angles)
            if idx not in skipped_angle_indices]
    text += ['skipped %.3f' % transect_angles[idx]
             for idx in skipped_angle_indices]
    text_path = []
    for tr in data_transects:
        end = tr[-1]
        last_seg = Line(tr[-2], tr[-1])
        u = last_seg.unit_tangent(1)
        text_path.append(Path(Line(end + 10*u, end + 100*u)))

    # handle skipped transects
    bdry_ring = max(ring_list, key=lambda ring: ring.maxR)
    bdry_length = bdry_ring.path.length()
    for idx in skipped_angle_indices:
        s = bdry_length * transect_angles[idx]
        T = inv_arclength(bdry_ring.path,  s)
        u = bdry_ring.path.normal(T)
        end = bdry_ring.path.point(T)
        text_path.append(Line(end + 10*u, end + 100*u))

    wsvg(pathList, colors, nodes=nodes, node_colors=node_colors, text=text,
         text_path=text_path, filename=filename+'_transects.svg')