From ff7c9dc68d38dfb14ff6439e38fceecc712ebfcb Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Thu, 5 Oct 2023 17:11:32 +0200 Subject: [PATCH] enrich with features: chip_scratches --- .../chip_scratches/chip_scratches.inx | 1 + .../chip_scratches/chip_scratches.py | 22 ++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/extensions/fablabchemnitz/chip_scratches/chip_scratches.inx b/extensions/fablabchemnitz/chip_scratches/chip_scratches.inx index 2b122a9..842f77e 100644 --- a/extensions/fablabchemnitz/chip_scratches/chip_scratches.inx +++ b/extensions/fablabchemnitz/chip_scratches/chip_scratches.inx @@ -10,6 +10,7 @@ 1000 1.000 1 + true true diff --git a/extensions/fablabchemnitz/chip_scratches/chip_scratches.py b/extensions/fablabchemnitz/chip_scratches/chip_scratches.py index a1ea011..a5bcb5c 100644 --- a/extensions/fablabchemnitz/chip_scratches/chip_scratches.py +++ b/extensions/fablabchemnitz/chip_scratches/chip_scratches.py @@ -87,7 +87,8 @@ for number and size, as well as some specific to each type. pars.add_argument("--ry", type=int, default=1000, help="Height") pars.add_argument("--mainSize", type= float, default=1.0, help="Size of objects") pars.add_argument("--mainNum", type=int, default=200, help="Number of objects") - pars.add_argument("--honp", type=inkex.Boolean, help="Enable scratches") + pars.add_argument("--allInOneGroup", type=inkex.Boolean, default=False, help="Put all items into one group") + pars.add_argument("--honp", type=inkex.Boolean, default=True, help="Enable scratches") pars.add_argument("--hsize", type=float, default=2.0, help="Size of scratches") pars.add_argument("--hgrow", type=float, default=0.0, help="Grow scratches with distance") pars.add_argument("--hnum", type= int, default=10, help="Number of scratches") @@ -116,6 +117,12 @@ for number and size, as well as some specific to each type. rx = self.options.rx ry = self.options.ry parent = self.document.getroot() + aiog = self.options.allInOneGroup + uniqId = self.svg.get_unique_id('chipscratches-') + scId =self.svg.get_unique_id('') + + if aiog is True: + group = parent.add(inkex.Group(id=uniqId)) #Create scratches @@ -131,7 +138,8 @@ for number and size, as well as some specific to each type. 'curve' : self.options.hcurve, 'grad' : self.options.hgrad, } - draw( scratches, parent, pdic) + + draw(group if aiog is True else parent.add(inkex.Group(id='scratches-' + scId)), scratches, pdic) #Create chips @@ -148,7 +156,7 @@ for number and size, as well as some specific to each type. 'curve' : False, 'grad' : self.options.cgrad, } - draw( chips, parent, pdic) + draw(group if aiog is True else parent.add(inkex.Group(id='chips-' + scId)), chips, pdic) #Create specks @@ -165,17 +173,15 @@ for number and size, as well as some specific to each type. 'curve' : False, 'grad' : self.options.sgrad, } - draw( specks, parent, pdic) + draw(group if aiog is True else parent.add(inkex.Group(id='specks-' + scId)), specks, pdic) -def draw( obj, parent, pdic) : +def draw(group, obj, pdic) : if not pdic['enable'] : return - group = etree.SubElement(parent, 'g') - if pdic['grad'] : f = lambda x: math.sqrt(x) - else : + else: f = lambda x: x rx = pdic['rx']