Skip to content

Commit

Permalink
Draft: split svg.get_svg into subfunctions
Browse files Browse the repository at this point in the history
Define a subfunction to process `Part.Shape` objects.
  • Loading branch information
vocx-fc authored and yorikvanhavre committed Oct 19, 2020
1 parent f136ee8 commit 8187cbe
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/Mod/Draft/draftfunctions/svg.py
Expand Up @@ -213,6 +213,23 @@ def format_point(coords, action='L'):
return "{action}{x},{y}".format(x=coords.x, y=coords.y, action=action)


def _svg_shape(svg, obj, plane,
fillstyle, pathdata, stroke, linewidth, lstyle):
"""Return the SVG representation of a Part.Shape."""
if "#" in fillstyle:
fill = fillstyle
elif fillstyle == "shape color":
fill = "#888888"
else:
fill = 'url(#' + fillstyle + ')'

svg += get_path(obj, plane,
fill, pathdata, stroke, linewidth, lstyle,
fill_opacity=None,
edges=obj.Edges, pathname="")
return svg


def get_svg(obj,
scale=1, linewidth=0.35, fontsize=12,
fillstyle="shape color", direction=None, linestyle=None,
Expand Down Expand Up @@ -335,16 +352,8 @@ def get_svg(obj,
pass

elif isinstance(obj, Part.Shape):
if "#" in fillstyle:
fill = fillstyle
elif fillstyle == "shape color":
fill = "#888888"
else:
fill = 'url(#'+fillstyle+')'
svg += get_path(obj, plane,
fill, pathdata, stroke, linewidth, lstyle,
fill_opacity=None,
edges=obj.Edges, pathname="")
svg = _svg_shape(svg, obj, plane,
fillstyle, pathdata, stroke, linewidth, lstyle)

elif utils.get_type(obj) in ["Dimension", "LinearDimension"]:
if not App.GuiUp:
Expand Down

0 comments on commit 8187cbe

Please sign in to comment.