Beispiel #1
0
def brd2svg(brd):
    whole_board = brd.get_geometry("Dimension", polygonize_wires=SEFP.POLYGONIZE_STRICT)
    topCopper = brd.get_geometry("Top")
    tPlace = brd.get_geometry("tPlace", apply_width=False)#["tPlace", "tNames"])
    holes =  brd.get_geometry("Holes")
    tStop = brd.get_geometry("tStop")

    board = whole_board.difference(holes)
    topCopper = topCopper.difference(holes)

    mask = tStop
    mask = whole_board.difference(tStop)
#    tPlace = tPlace.difference(tStop)
        
    results = [polygon_as_svg(board, style="fill:#fff49a"),
               polygon_as_svg(topCopper, style="fill:#ffb600"),
               polygon_as_svg(mask, style="fill:#00ff00; fill-opacity:0.5"),
               polygon_as_svg(tPlace, style="stroke:white; stroke-width:0.05mm;stroke-linecap:round;fill:none")#, close_paths=False)
               #polygon_as_svg(tPlace, style="stroke:#ffffff; stroke-width:0.1mm;fill:none")
    ]
               
    svg = """<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <defs>
    <link href="my-style.css" type="text/css" rel="stylesheet" xmlns="http://www.w3.org/1999/xhtml"/>
    </defs><g transform="scale(1,-1)">{}</g></svg>""".format("".join(results))

    return svg
Beispiel #2
0
def package2svg(package):
    topCopper = package.get_geometry("Top")
    tPlace = package.get_geometry("tPlace", apply_width=False)
    tValues = package.get_geometry("tValues", apply_width=False)
    tNames = package.get_geometry("tNames", apply_width=False)
    holes =  package.get_geometry("Holes")
    tStop = package.get_geometry(layer_query="tStop")

    topCopper = topCopper.difference(holes)

    mask = tStop

    results = [
        polygon_as_svg(affinity.scale(topCopper, yfact=-1, origin=(0,0)), style="fill:#ffb600"),
        polygon_as_svg(affinity.scale(tPlace   , yfact=-1, origin=(0,0)), style="stroke:white; stroke-width:0.05mm;stroke-linecap:round;fill:none"),
        polygon_as_svg(affinity.scale(tNames   , yfact=-1, origin=(0,0)), style="stroke:white; stroke-width:0.05mm;stroke-linecap:round;fill:none"),
        polygon_as_svg(affinity.scale(tValues   , yfact=-1, origin=(0,0)), style="stroke:white; stroke-width:0.05mm;stroke-linecap:round;fill:none")
    ]
    return map(lambda x: ET.fromstring("<g>{}</g>".format(x)),results)