kopia lustrzana https://github.com/inkstitch/inkstitch
Add indicator size option for density map (#2572)
* add indicator size option * obey min stitch length settingkall/test dev-build-kall-test
rodzic
bc2a50b525
commit
0d77b99bfd
|
@ -25,6 +25,7 @@ class DensityMap(InkstitchExtension):
|
|||
self.arg_parser.add_argument("-r", "--density-radius-red", type=float, default=0.5, dest="radius_red")
|
||||
self.arg_parser.add_argument("-m", "--num-neighbors-yellow", type=int, default=3, dest="num_neighbors_yellow")
|
||||
self.arg_parser.add_argument("-s", "--density-radius-yellow", type=float, default=0.5, dest="radius_yellow")
|
||||
self.arg_parser.add_argument("-i", "--indicator-size", type=float, default=0.5, dest="indicator_size")
|
||||
|
||||
def effect(self):
|
||||
# delete old stitch plan
|
||||
|
@ -37,14 +38,15 @@ class DensityMap(InkstitchExtension):
|
|||
|
||||
self.metadata = self.get_inkstitch_metadata()
|
||||
collapse_len = self.metadata['collapse_len_mm']
|
||||
min_stitch_len = self.metadata['min_stitch_len_mm']
|
||||
patches = self.elements_to_stitch_groups(self.elements)
|
||||
stitch_plan = stitch_groups_to_stitch_plan(patches, collapse_len=collapse_len)
|
||||
stitch_plan = stitch_groups_to_stitch_plan(patches, collapse_len=collapse_len, min_stitch_len=min_stitch_len)
|
||||
|
||||
layer = svg.find(".//*[@id='__inkstitch_density_plan__']")
|
||||
color_groups = create_color_groups(layer)
|
||||
density_options = [{'max_neighbors': self.options.num_neighbors_red, 'radius': self.options.radius_red},
|
||||
{'max_neighbors': self.options.num_neighbors_yellow, 'radius': self.options.radius_yellow}]
|
||||
color_block_to_density_markers(svg, color_groups, stitch_plan, density_options)
|
||||
color_block_to_density_markers(svg, color_groups, stitch_plan, density_options, self.options.indicator_size)
|
||||
|
||||
# update layer visibility 0 = unchanged, 1 = hidden, 2 = lower opacity
|
||||
groups = self.document.getroot().findall(SVG_GROUP_TAG)
|
||||
|
@ -92,7 +94,7 @@ def create_color_groups(layer):
|
|||
return color_groups
|
||||
|
||||
|
||||
def color_block_to_density_markers(svg, groups, stitch_plan, density_options):
|
||||
def color_block_to_density_markers(svg, groups, stitch_plan, density_options, indicator_size):
|
||||
num_neighbors = []
|
||||
for option in density_options:
|
||||
radius = option['radius'] * PIXELS_PER_MM
|
||||
|
@ -113,7 +115,7 @@ def color_block_to_density_markers(svg, groups, stitch_plan, density_options):
|
|||
'style': "fill: %s; stroke: #7e7e7e; stroke-width: 0.02%%;" % color,
|
||||
'cx': "%s" % coord[0],
|
||||
'cy': "%s" % coord[1],
|
||||
'r': str(0.5),
|
||||
'r': str(indicator_size * 2),
|
||||
'transform': get_correction_transform(svg)
|
||||
})
|
||||
group.append(density_marker)
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
<option value="1">Hidden</option>
|
||||
<option value="2">Lower opacity</option>
|
||||
</param>
|
||||
<spacer />
|
||||
<param name="indicator-size" type="float" min="0" max="50" indent="1" gui-text="Indicator size"
|
||||
precision="2">0.5</param>
|
||||
<script>
|
||||
{{ command_tag | safe }}
|
||||
</script>
|
||||
|
|
Ładowanie…
Reference in New Issue