fix bug in chip_scratches, add randomize option
This commit is contained in:
parent
3e31fbfc4f
commit
c14423b6f5
@ -14,6 +14,7 @@
|
|||||||
<separator/>
|
<separator/>
|
||||||
<param name="mainSize" type="float" max="100.0" precision="3" gui-text="Size of objects (scale factor)">1.000</param>
|
<param name="mainSize" type="float" max="100.0" precision="3" gui-text="Size of objects (scale factor)">1.000</param>
|
||||||
<param name="mainNum" type="int" max="5000" gui-text="Number of objects (acts as multiplicator)">1</param>
|
<param name="mainNum" type="int" max="5000" gui-text="Number of objects (acts as multiplicator)">1</param>
|
||||||
|
<param name="randomize" type="bool" gui-text="Randomize number of objects">true</param>
|
||||||
<param name="allInOneGroup" type="bool" gui-text="Put all items into one group">true</param>
|
<param name="allInOneGroup" type="bool" gui-text="Put all items into one group">true</param>
|
||||||
</page>
|
</page>
|
||||||
<page name="Scratches" gui-text="Scratches">
|
<page name="Scratches" gui-text="Scratches">
|
||||||
|
@ -107,6 +107,7 @@ for number and size, as well as some specific to each type.
|
|||||||
pars.add_argument("--sgrow", type= float, default=0.0, help="Grow specks with distance")
|
pars.add_argument("--sgrow", type= float, default=0.0, help="Grow specks with distance")
|
||||||
pars.add_argument("--snum", type= int, default=10, help="Number of specks")
|
pars.add_argument("--snum", type= int, default=10, help="Number of specks")
|
||||||
pars.add_argument("--sgrad", type=inkex.Boolean, default=False, help="Use density gradient")
|
pars.add_argument("--sgrad", type=inkex.Boolean, default=False, help="Use density gradient")
|
||||||
|
pars.add_argument("--randomize", type=inkex.Boolean, default=False, help="Randomize number of objects")
|
||||||
pars.add_argument("--Nmain", "--Overall")
|
pars.add_argument("--Nmain", "--Overall")
|
||||||
|
|
||||||
def effect(self):
|
def effect(self):
|
||||||
@ -142,6 +143,7 @@ for number and size, as well as some specific to each type.
|
|||||||
'ang' : self.options.hang,
|
'ang' : self.options.hang,
|
||||||
'curve' : self.options.hcurve,
|
'curve' : self.options.hcurve,
|
||||||
'grad' : self.options.hgrad,
|
'grad' : self.options.hgrad,
|
||||||
|
'randomize': self.options.randomize,
|
||||||
}
|
}
|
||||||
pdic_chips = {
|
pdic_chips = {
|
||||||
'x' : x,
|
'x' : x,
|
||||||
@ -156,6 +158,7 @@ for number and size, as well as some specific to each type.
|
|||||||
'ang' : False,
|
'ang' : False,
|
||||||
'curve' : False,
|
'curve' : False,
|
||||||
'grad' : self.options.cgrad,
|
'grad' : self.options.cgrad,
|
||||||
|
'randomize': self.options.randomize,
|
||||||
}
|
}
|
||||||
pdic_specks = {
|
pdic_specks = {
|
||||||
'x' : x,
|
'x' : x,
|
||||||
@ -170,6 +173,7 @@ for number and size, as well as some specific to each type.
|
|||||||
'ang' : False,
|
'ang' : False,
|
||||||
'curve' : False,
|
'curve' : False,
|
||||||
'grad' : self.options.sgrad,
|
'grad' : self.options.sgrad,
|
||||||
|
'randomize': self.options.randomize,
|
||||||
}
|
}
|
||||||
uniqId = self.svg.get_unique_id('chipscratches-')
|
uniqId = self.svg.get_unique_id('chipscratches-')
|
||||||
scId =self.svg.get_unique_id('')
|
scId =self.svg.get_unique_id('')
|
||||||
@ -182,6 +186,7 @@ for number and size, as well as some specific to each type.
|
|||||||
inkex.utils.debug("No rectangle(s) have been selected.")
|
inkex.utils.debug("No rectangle(s) have been selected.")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
if aiog is False: #otherwise we have a lot of duplicates!
|
||||||
pdic_scratches = {
|
pdic_scratches = {
|
||||||
'x' : x,
|
'x' : x,
|
||||||
'y' : y,
|
'y' : y,
|
||||||
@ -195,6 +200,7 @@ for number and size, as well as some specific to each type.
|
|||||||
'ang' : self.options.hang,
|
'ang' : self.options.hang,
|
||||||
'curve' : self.options.hcurve,
|
'curve' : self.options.hcurve,
|
||||||
'grad' : self.options.hgrad,
|
'grad' : self.options.hgrad,
|
||||||
|
'randomize': self.options.randomize,
|
||||||
}
|
}
|
||||||
pdic_chips = {
|
pdic_chips = {
|
||||||
'x' : x,
|
'x' : x,
|
||||||
@ -209,6 +215,7 @@ for number and size, as well as some specific to each type.
|
|||||||
'ang' : False,
|
'ang' : False,
|
||||||
'curve' : False,
|
'curve' : False,
|
||||||
'grad' : self.options.cgrad,
|
'grad' : self.options.cgrad,
|
||||||
|
'randomize': self.options.randomize,
|
||||||
}
|
}
|
||||||
pdic_specks = {
|
pdic_specks = {
|
||||||
'x' : x,
|
'x' : x,
|
||||||
@ -223,6 +230,7 @@ for number and size, as well as some specific to each type.
|
|||||||
'ang' : False,
|
'ang' : False,
|
||||||
'curve' : False,
|
'curve' : False,
|
||||||
'grad' : self.options.sgrad,
|
'grad' : self.options.sgrad,
|
||||||
|
'randomize': self.options.randomize,
|
||||||
}
|
}
|
||||||
uniqId = self.svg.get_unique_id('chipscratches-')
|
uniqId = self.svg.get_unique_id('chipscratches-')
|
||||||
scId =self.svg.get_unique_id('')
|
scId =self.svg.get_unique_id('')
|
||||||
@ -253,11 +261,14 @@ def draw(group, obj, pdic) :
|
|||||||
mrmax = mrx if mrx > mry else mry
|
mrmax = mrx if mrx > mry else mry
|
||||||
#Curves 90 going from the center to the edge (long dim.) if parm = 1.0
|
#Curves 90 going from the center to the edge (long dim.) if parm = 1.0
|
||||||
curve = pdic['curve'] * 0.5 * math.pi / mrmax
|
curve = pdic['curve'] * 0.5 * math.pi / mrmax
|
||||||
|
if pdic['randomize'] is True:
|
||||||
|
cnt = (random.randint(0, int(pdic['num'])))
|
||||||
|
else:
|
||||||
|
cnt = pdic['num']
|
||||||
ctrs = [(
|
ctrs = [(
|
||||||
x + rx * f(random.random()) ,
|
x + rx * f(random.random()) ,
|
||||||
y + ry * f(random.random())
|
y + ry * f(random.random())
|
||||||
) for i in range(pdic['num'])]
|
) for i in range(cnt)]
|
||||||
zp = 2 + 3 * int(random.random()*len(obj) / 3 )
|
zp = 2 + 3 * int(random.random()*len(obj) / 3 )
|
||||||
for ctr in ctrs :
|
for ctr in ctrs :
|
||||||
path = etree.Element(inkex.addNS('path','svg'))
|
path = etree.Element(inkex.addNS('path','svg'))
|
||||||
|
Loading…
Reference in New Issue
Block a user