diff --git a/lib/extensions/stitch_plan_preview.py b/lib/extensions/stitch_plan_preview.py
index 541c42f03..293bf2839 100644
--- a/lib/extensions/stitch_plan_preview.py
+++ b/lib/extensions/stitch_plan_preview.py
@@ -23,6 +23,7 @@ class StitchPlanPreview(InkstitchExtension):
self.arg_parser.add_argument("-i", "--insensitive", type=Boolean, default=False, dest="insensitive")
self.arg_parser.add_argument("-c", "--visual-commands", type=Boolean, default="symbols", dest="visual_commands")
self.arg_parser.add_argument("-o", "--overwrite", type=Boolean, default=True, dest="overwrite")
+ self.arg_parser.add_argument("-r", "--realistic", type=Boolean, default=True, dest="realistic")
def effect(self):
# delete old stitch plan
@@ -33,7 +34,7 @@ class StitchPlanPreview(InkstitchExtension):
return
svg = self.document.getroot()
- realistic = False
+ realistic = self.options.realistic
visual_commands = self.options.visual_commands
self.metadata = self.get_inkstitch_metadata()
collapse_len = self.metadata['collapse_len_mm']
diff --git a/lib/svg/rendering.py b/lib/svg/rendering.py
index b96fe9b7b..bca41f363 100644
--- a/lib/svg/rendering.py
+++ b/lib/svg/rendering.py
@@ -35,78 +35,42 @@ stitch_height = 1.216
# the axes of the stitch itself. That means that having a big enough value
# to add enough padding on the long sides of the stitch would waste a ton
# of space on the short sides and significantly slow down rendering.
+# The whiskers can probably be removed with the explicit filter size declaration below.
stitch_path = "M0,0c0.4,0,0.4,0.3,0.4,0.6c0,0.3,-0.1,0.6,-0.4,0.6v0.2,-0.2h-%sc-0.4,0,-0.4,-0.3,-0.4,-0.6c0,-0.3,0.1,-0.6,0.4,-0.6v-0.2,0.2z"
-# This filter makes the above stitch path look like a real stitch with lighting.
+# The filter size is 2% larger, because otherwise the edges get artifacting from boundary conditions.
+# Inkscape may or may not respect the edgeMode attribute for feGaussianBlur.
+# It seems like values less than 0.01 for x and y may be ignored, so 1% on each side is the effective minimum.
realistic_filter = """
+ x="-0.01"
+ width="1.02"
+ y="-0.01"
+ height="1.02"
+ inkscape:auto-region="false">
-
-
-
-
-
-
-
-
-
+ specularConstant="0.78"
+ surfaceScale="3"
+ specularExponent="1">
+ z="10"
+ y="0"
+ x="12" />
-
-
+ operator="atop" />
"""
@@ -250,5 +214,10 @@ def render_stitch_plan(svg, stitch_plan, realistic=False, visual_commands=True):
color_block_to_paths(color_block, svg, group, visual_commands)
if realistic:
+ # Remove filter from defs, if any
+ filter: inkex.BaseElement = svg.defs.findone("//*[@id='realistic-stitch-filter']")
+ if filter is not None:
+ svg.defs.remove(filter)
+
filter_document = inkex.load_svg(realistic_filter)
svg.defs.append(filter_document.getroot())
diff --git a/templates/stitch_plan_preview.xml b/templates/stitch_plan_preview.xml
index 0a760827e..2dc1a7576 100644
--- a/templates/stitch_plan_preview.xml
+++ b/templates/stitch_plan_preview.xml
@@ -24,6 +24,7 @@
false
false
+ false