Draft: Using square endcaps for lines in SVG output

This commit is contained in:
Yorik van Havre
2021-05-06 18:38:32 +02:00
parent 5705bb8aa8
commit e37e8eddfb
2 changed files with 13 additions and 4 deletions

View File

@@ -119,14 +119,14 @@ def get_arrow(obj,
point.x, point.y)
_transl = 'translate({},{})'.format(point.x, point.y)
_scale = 'scale({size},{size})'.format(size=arrowsize)
_style = 'style="stroke-miterlimit:4;stroke-dasharray:none"'
_style = 'style="stroke-miterlimit:4;stroke-dasharray:none;stroke-endcap:square"'
if obj.ViewObject.ArrowType == "Circle":
svg += '<circle '
svg += _cx_cy_r + ' '
svg += 'fill="{}" stroke="{}" '.format("none", color)
svg += 'style="stroke-width:{};'.format(linewidth)
svg += 'stroke-miterlimit:4;stroke-dasharray:none" '
svg += 'stroke-miterlimit:4;stroke-dasharray:none;stroke-endcap:square" '
svg += 'freecad:skip="1"'
svg += '/>\n'
elif obj.ViewObject.ArrowType == "Dot":
@@ -327,7 +327,7 @@ def _svg_dimension(obj, plane, scale, linewidth, fontsize,
svg += stroke + '" '
svg += 'stroke-width="' + str(linewidth) + ' px" '
svg += 'style="stroke-width:' + str(linewidth)
svg += ';stroke-miterlimit:4;stroke-dasharray:none" '
svg += ';stroke-miterlimit:4;stroke-dasharray:none;stroke-endcap:square" '
svg += 'freecad:basepoint1="'+str(p1.x)+' '+str(p1.y)+'" '
svg += 'freecad:basepoint2="'+str(p4.x)+' '+str(p4.y)+'" '
svg += 'freecad:dimpoint="'+str(p2.x)+' '+str(p2.y)+'"'
@@ -490,6 +490,11 @@ def get_svg(obj,
stroke = utils.get_rgb(obj.ViewObject.LineColor)
elif hasattr(obj.ViewObject, "TextColor"):
stroke = utils.get_rgb(obj.ViewObject.TextColor)
if hasattr(obj.ViewObject, "TextColor"):
tstroke = utils.get_rgb(obj.ViewObject.TextColor)
else:
tstroke = stroke
lstyle = "none"
if override:
@@ -617,6 +622,7 @@ def get_svg(obj,
svg_path += 'fill="none" '
svg_path += 'stroke="{}" '.format(stroke)
svg_path += 'stroke-width="{}" '.format(linewidth)
svg_path += 'stroke-endcap:square;'
svg_path += 'd="{}"'.format(path_dir_str)
svg_path += '/>'
svg += svg_path
@@ -667,7 +673,7 @@ def get_svg(obj,
j = obj.ViewObject.Justification
svg += svgtext.get_text(plane, techdraw,
stroke, fontsize, n,
tstroke, fontsize, n,
r, p, t,
linespacing, j)

View File

@@ -301,6 +301,7 @@ def get_circle(plane,
svg += 'stroke-width:{};'.format(linewidth)
svg += 'stroke-miterlimit:4;'
svg += 'stroke-dasharray:{};'.format(lstyle)
svg += 'stroke-endcap:square;'
svg += 'fill:{}'.format(fill) + '"'
svg += '/>\n'
return svg
@@ -330,6 +331,7 @@ def get_ellipse(plane,
svg += 'stroke-width:{};'.format(linewidth)
svg += 'stroke-miterlimit:4;'
svg += 'stroke-dasharray:{};'.format(lstyle)
svg += 'stroke-endcap:square;'
svg += 'fill:{}'.format(fill) + '"'
svg += '/>\n'
return svg
@@ -440,6 +442,7 @@ def get_path(obj, plane,
svg += 'stroke-width:{};'.format(linewidth)
svg += 'stroke-miterlimit:4;'
svg += 'stroke-dasharray:{};'.format(lstyle)
svg += 'stroke-endcap:square;'
svg += 'fill:{};'.format(fill)
# fill_opacity must be a number, but if it's `None` it is omitted
if fill_opacity is not None: