Some fixes
This commit is contained in:
parent
9356b657e4
commit
41663ffd86
@ -31,6 +31,7 @@
|
|||||||
<param name="link_multiplicator" type="int" min="0" max="9999" gui-text="Link multiplicator" gui-description="If set, we create a set of multiple gaps of same size next to the main gap">0</param>
|
<param name="link_multiplicator" type="int" min="0" max="9999" gui-text="Link multiplicator" gui-description="If set, we create a set of multiple gaps of same size next to the main gap">0</param>
|
||||||
<param name="length_link" type="float" min="0.000" max="9999.000" precision="3" gui-text="Link length (the length of the gap)">1.000</param>
|
<param name="length_link" type="float" min="0.000" max="9999.000" precision="3" gui-text="Link length (the length of the gap)">1.000</param>
|
||||||
<param name="link_offset" type="float" min="-9999.000.000" max="9999.000" precision="3" gui-text="Link offset (+/-)">0.000</param>
|
<param name="link_offset" type="float" min="-9999.000.000" max="9999.000" precision="3" gui-text="Link offset (+/-)">0.000</param>
|
||||||
|
<param name="switch_pattern" type="bool" gui-text="Swap links with dashes" gui-description="If enabled, we use gap length as dash length (switches the dasharray pattern">false</param>
|
||||||
<label appearance="header">Creation: Custom Dash Pattern Settings</label>
|
<label appearance="header">Creation: Custom Dash Pattern Settings</label>
|
||||||
<param name="custom_dasharray_value" type="string" gui-text="Dash pattern" gui-description="A list of separated lengths that specify the lengths of alternating dashes and gaps. Input only accepts numbers. It ignores percentages or other characters.">10 5.5 2.0 2.0</param>
|
<param name="custom_dasharray_value" type="string" gui-text="Dash pattern" gui-description="A list of separated lengths that specify the lengths of alternating dashes and gaps. Input only accepts numbers. It ignores percentages or other characters.">10 5.5 2.0 2.0</param>
|
||||||
<param name="custom_dashoffset_value" type="float" min="-9999.000.000" max="9999.000" precision="3" gui-text="Link offset (+/-)">0.000</param>
|
<param name="custom_dashoffset_value" type="float" min="-9999.000.000" max="9999.000" precision="3" gui-text="Link offset (+/-)">0.000</param>
|
||||||
|
@ -51,6 +51,7 @@ class LinksCreator(inkex.EffectExtension):
|
|||||||
pars.add_argument("--link_multiplicator", type=int, default=1, help="If set, we create a set of multiple gaps of same size next to the main gap")
|
pars.add_argument("--link_multiplicator", type=int, default=1, help="If set, we create a set of multiple gaps of same size next to the main gap")
|
||||||
pars.add_argument("--length_link", type=float, default=1.000, help="Link length")
|
pars.add_argument("--length_link", type=float, default=1.000, help="Link length")
|
||||||
pars.add_argument("--link_offset", type=float, default=0.000, help="Link offset (+/-)")
|
pars.add_argument("--link_offset", type=float, default=0.000, help="Link offset (+/-)")
|
||||||
|
pars.add_argument("--switch_pattern", type=inkex.Boolean, default=False, help="If enabled, we use gap length as dash length (switches the dasharray pattern")
|
||||||
pars.add_argument("--custom_dasharray_value", default="", help="A list of separated lengths that specify the lengths of alternating dashes and gaps. Input only accepts numbers. It ignores percentages or other characters.")
|
pars.add_argument("--custom_dasharray_value", default="", help="A list of separated lengths that specify the lengths of alternating dashes and gaps. Input only accepts numbers. It ignores percentages or other characters.")
|
||||||
pars.add_argument("--custom_dashoffset_value", type=float, default=0.000, help="Link offset (+/-)")
|
pars.add_argument("--custom_dashoffset_value", type=float, default=0.000, help="Link offset (+/-)")
|
||||||
pars.add_argument("--length_filter", type=inkex.Boolean, default=False, help="Enable path length filtering")
|
pars.add_argument("--length_filter", type=inkex.Boolean, default=False, help="Enable path length filtering")
|
||||||
@ -129,11 +130,16 @@ class LinksCreator(inkex.EffectExtension):
|
|||||||
dashes = [] #central dashes array
|
dashes = [] #central dashes array
|
||||||
|
|
||||||
if self.options.creationtype == "entered_values":
|
if self.options.creationtype == "entered_values":
|
||||||
dashes.append(((stotal - length_link * self.options.link_count) / self.options.link_count) - 2 * length_link * self.options.link_multiplicator)
|
dash_length = ((stotal - length_link * self.options.link_count) / self.options.link_count) - 2 * length_link * self.options.link_multiplicator
|
||||||
|
dashes.append(dash_length)
|
||||||
dashes.append(length_link)
|
dashes.append(length_link)
|
||||||
for i in range(0, self.options.link_multiplicator):
|
for i in range(0, self.options.link_multiplicator):
|
||||||
dashes.append(length_link) #stroke (=gap)
|
dashes.append(length_link) #stroke (=gap)
|
||||||
dashes.append(length_link) #gap
|
dashes.append(length_link) #gap
|
||||||
|
|
||||||
|
if self.options.switch_pattern is True:
|
||||||
|
dashes = dashes[::-1] #reverse the array
|
||||||
|
|
||||||
#validate dashes. May not be negative. Otherwise Inkscape will freeze forever. Reason: rendering issue
|
#validate dashes. May not be negative. Otherwise Inkscape will freeze forever. Reason: rendering issue
|
||||||
if any(dash <= 0.0 for dash in dashes) == True:
|
if any(dash <= 0.0 for dash in dashes) == True:
|
||||||
if self.options.show_info is True: inkex.errormsg("node " + node.get('id') + ": Error! Dash array may not contain negative numbers: " + ' '.join(format(dash, "1.3f") for dash in dashes) + ". Path skipped. Maybe it's too short. Adjust your link count, multiplicator and length accordingly, or set to unit '%'")
|
if self.options.show_info is True: inkex.errormsg("node " + node.get('id') + ": Error! Dash array may not contain negative numbers: " + ' '.join(format(dash, "1.3f") for dash in dashes) + ". Path skipped. Maybe it's too short. Adjust your link count, multiplicator and length accordingly, or set to unit '%'")
|
||||||
@ -144,6 +150,9 @@ class LinksCreator(inkex.EffectExtension):
|
|||||||
else:
|
else:
|
||||||
stroke_dashoffset = self.svg.unittouu(str(self.options.link_offset) + self.options.creationunit)
|
stroke_dashoffset = self.svg.unittouu(str(self.options.link_offset) + self.options.creationunit)
|
||||||
|
|
||||||
|
if self.options.switch_pattern is True:
|
||||||
|
stroke_dashoffset = stroke_dashoffset + ((self.options.link_multiplicator * 2) + 1) * length_link
|
||||||
|
|
||||||
if self.options.creationtype == "use_existing":
|
if self.options.creationtype == "use_existing":
|
||||||
if self.options.no_convert is True:
|
if self.options.no_convert is True:
|
||||||
if self.options.show_info is True: inkex.errormsg("node " + node.get('id') + ": Nothing to do. Please select another creation method or disable cosmetic style output paths.")
|
if self.options.show_info is True: inkex.errormsg("node " + node.get('id') + ": Nothing to do. Please select another creation method or disable cosmetic style output paths.")
|
||||||
@ -194,12 +203,12 @@ class LinksCreator(inkex.EffectExtension):
|
|||||||
if len(parts) == 2:
|
if len(parts) == 2:
|
||||||
(prop, val) = parts
|
(prop, val) = parts
|
||||||
prop = prop.strip().lower()
|
prop = prop.strip().lower()
|
||||||
if prop == 'fill':
|
#if prop == 'fill':
|
||||||
declarations[i] = prop + ':{}'.format(default_fill)
|
# declarations[i] = prop + ':{}'.format(default_fill)
|
||||||
if prop == 'stroke':
|
#if prop == 'stroke':
|
||||||
declarations[i] = prop + ':{}'.format(default_stroke)
|
# declarations[i] = prop + ':{}'.format(default_stroke)
|
||||||
if prop == 'stroke-width':
|
#if prop == 'stroke-width':
|
||||||
declarations[i] = prop + ':{}'.format(default_stroke_width)
|
# declarations[i] = prop + ':{}'.format(default_stroke_width)
|
||||||
if prop == 'stroke-dasharray': #comma separated list of one or more float values
|
if prop == 'stroke-dasharray': #comma separated list of one or more float values
|
||||||
declarations[i] = prop + ':{}'.format(stroke_dasharray)
|
declarations[i] = prop + ':{}'.format(stroke_dasharray)
|
||||||
if prop == 'stroke-dashoffset':
|
if prop == 'stroke-dashoffset':
|
||||||
|
@ -105,9 +105,7 @@ class PasteLengthEffect(inkex.EffectExtension):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
inkex.errormsg("Please select at least two paths, with the path whose \
|
inkex.errormsg("Please select at least two paths, with the path whose length is to be copied at the top. You may have to convert the shape to path with path->Object to Path.")
|
||||||
length is to be copied at the top. You may have to convert the shape \
|
|
||||||
to path with path->Object to Path.")
|
|
||||||
else:
|
else:
|
||||||
if(len(paths) > 0):
|
if(len(paths) > 0):
|
||||||
srclen = self.svg.unittouu(str(self.options.custom_length) + self.options.unit)
|
srclen = self.svg.unittouu(str(self.options.custom_length) + self.options.unit)
|
||||||
|
Reference in New Issue
Block a user