diff --git a/README.md b/README.md index 6b65efb7..4cc9b8e5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MightyScape for Inkscape 1.0+ -In short: A maintained extension collection for Inkscape 1.0+, working on Windows and Linux. There are **220 extension folders** with **386 .inx files** inside. We also take part at https://inkscape.org/gallery/=extension/ (with single extension uploads). +In short: A maintained extension collection for Inkscape 1.0+, working on Windows and Linux. There are **221 extension folders** with **388 .inx files** inside. We also take part at https://inkscape.org/gallery/=extension/ (with single extension uploads). # About MightyScape diff --git a/extensions/fablabchemnitz/bounding_box/bounding_box.inx b/extensions/fablabchemnitz/bounding_box/bounding_box.inx index 9f10668b..38ecee40 100644 --- a/extensions/fablabchemnitz/bounding_box/bounding_box.inx +++ b/extensions/fablabchemnitz/bounding_box/bounding_box.inx @@ -3,8 +3,9 @@ Bounding Box fablabchemnitz.de.bounding_box - 0.0 + 0.000 true + 0.000 false true diff --git a/extensions/fablabchemnitz/bounding_box/bounding_box.py b/extensions/fablabchemnitz/bounding_box/bounding_box.py index 216e59a7..e41bcaff 100644 --- a/extensions/fablabchemnitz/bounding_box/bounding_box.py +++ b/extensions/fablabchemnitz/bounding_box/bounding_box.py @@ -9,6 +9,7 @@ class BoundingBox(inkex.EffectExtension): def add_arguments(self, pars): pars.add_argument('--offset', type=float, default=0.0, help='Offset from object (all directions)') pars.add_argument('--box', type=inkex.Boolean, default=0.0, help='Draw boxes') + pars.add_argument('--corner_radius', type=float, default=0.0, help='Corner radius') pars.add_argument('--circle', type=inkex.Boolean, default=0.0, help='Draw circles') pars.add_argument('--split', type = inkex.Boolean, default = True, help = 'Handle selection as group') @@ -20,6 +21,8 @@ class BoundingBox(inkex.EffectExtension): 'y' : str(bbox.top - self.options.offset), 'width' : str(bbox.width + 2 * self.options.offset), 'height': str(bbox.height + 2 * self.options.offset), + 'ry' : str(self.options.corner_radius), + 'rx' : str(self.options.corner_radius) } etree.SubElement(self.svg.get_current_layer(), inkex.addNS('rect','svg'), attribs) diff --git a/extensions/fablabchemnitz/glyph_ids/get_glyph_ids.inx b/extensions/fablabchemnitz/glyph_ids/get_glyph_ids.inx new file mode 100644 index 00000000..d06c10fe --- /dev/null +++ b/extensions/fablabchemnitz/glyph_ids/get_glyph_ids.inx @@ -0,0 +1,30 @@ + + + Glyph IDs - Get + fablabchemnitz.de.glyph_ids.get_glyph_ids + + + + + + + + + + + + all + + + + + + + + \ No newline at end of file diff --git a/extensions/fablabchemnitz/glyph_ids/get_glyph_ids.py b/extensions/fablabchemnitz/glyph_ids/get_glyph_ids.py new file mode 100644 index 00000000..3e17744c --- /dev/null +++ b/extensions/fablabchemnitz/glyph_ids/get_glyph_ids.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2020 Ellen Wasboe, ellen@wasbo.net +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +""" +Get path ids of all selected paths should be of all paths in "Glyphs" layer +Put all ids into a continueous string (no separation character) and paste as text element in layer Ids at position x 0 y 0. +Paths are sorted by left bounding box. +Intention: +to quickly retrieve all path-ids of the glyph-paths when using the Custom Stroke Font extension to edit a existing svg font https://github.com/Shriinivas/inkscapestrokefont +this string of ids can then be used to set ids using setIds.py as ids might be lost in different path operations. https://gitlab.com/EllenWasbo/inkscape-extension-setIds +""" + +import inkex +from inkex import Group, TextElement + +class getGlyphIDs(inkex.EffectExtension): + + def add_arguments(self, pars): + pars.add_argument("--tab", default="getGlyphIDs") + + def effect(self): + + if self.svg.getElementById('glyph') == None: + raise inkex.AbortExtension("Could not find layer Glyphs (id=glyphs)") + + else: + txtElem=TextElement() + + if self.svg.getElementById('glyphIds') == None: + txtLayer=self.svg.add(Group.new('glyphIds'))#, is_layer=True)) + txtLayer.set('id','glyphIds') + txtLayer.set('inkscape:groupmode','layer') + txtLayer.style={'display':'inline'} + else: + txtLayer=self.svg.getElementById('glyphIds') + + if self.svg.getElementById('txtGlyphIds') == None: + txt=txtLayer.add(txtElem) + txt.style={'font-size': '20px','letter-spacing': '2px','fill': '#000000','fill-opacity': 1,'stroke': 'none'} + txt.set('id','txtGlyphIds') + else: + txt=self.svg.getElementById('txtGlyphIds') + + idArr='' + + for elem in self.svg.getElementById('glyph'): + idArr=idArr+elem.get('id') + + txt.text = idArr + +if __name__ == '__main__': + getGlyphIDs().run() \ No newline at end of file diff --git a/extensions/fablabchemnitz/glyph_ids/meta.json b/extensions/fablabchemnitz/glyph_ids/meta.json new file mode 100644 index 00000000..715e70f1 --- /dev/null +++ b/extensions/fablabchemnitz/glyph_ids/meta.json @@ -0,0 +1,20 @@ +[ + { + "name": "Glyph IDs - ", + "id": "fablabchemnitz.de.glyph_ids.", + "path": "Glyph IDs - ", + "original_name": "", + "original_id": "EllenWasbo.cutlings.", + "license": "GNU GPL v2", + "license_url": "https://gitlab.com/EllenWasbo/inkscape-extension-getsetGlyphIDs/-/blob/master/getGlyphIDs.py", + "comment": "", + "source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/extensions/fablabchemnitz/glyph_ids", + "fork_url": "https://gitlab.com/EllenWasbo/inkscape-extension-getsetGlyphID", + "documentation_url": "https://stadtfabrikanten.org/display/IFM/Glyph+IDs", + "inkscape_gallery_url": null, + "main_authors": [ + "gitlab.com/EllenWasbo", + "github.com/vmario89" + ] + } +] \ No newline at end of file diff --git a/extensions/fablabchemnitz/glyph_ids/set_glyph_ids.inx b/extensions/fablabchemnitz/glyph_ids/set_glyph_ids.inx new file mode 100644 index 00000000..8f79e8e9 --- /dev/null +++ b/extensions/fablabchemnitz/glyph_ids/set_glyph_ids.inx @@ -0,0 +1,30 @@ + + + Glyph IDs - Set + fablabchemnitz.de.glyph_ids.set_glyph_ids + + + + + abc + + + + + + + all + + + + + + + + \ No newline at end of file diff --git a/extensions/fablabchemnitz/glyph_ids/set_glyph_ids.py b/extensions/fablabchemnitz/glyph_ids/set_glyph_ids.py new file mode 100644 index 00000000..0e1841c6 --- /dev/null +++ b/extensions/fablabchemnitz/glyph_ids/set_glyph_ids.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2020 Ellen Wasboe, ellen@wasbo.net +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +""" +Set ids of selected paths to a character in the specified string. +Paths a sorted by left bounding box. Id for the path to the left is set to the first character in the string. +Intention: to quickly set the correct id of the glyph-paths when using the Custom Stroke Font extension https://github.com/Shriinivas/inkscapestrokefont +""" + +import inkex, re + +class setGlyphIDs(inkex.EffectExtension): + """Set ids of selected paths to a character in the specified string. """ + def add_arguments(self, pars): + pars.add_argument("--tab", default="setGlyphIDs") + pars.add_argument("--characters", default="") + + def effect(self): + + if not self.svg.selected: + raise inkex.AbortExtension("Please select the glyph paths.") + + else: + if self.options.characters == "": + raise inkex.AbortExtension("No characters specified.") + else: + chars=self.options.characters + listChar=list(chars) + leftVal=[] + + i = 0 + for id, elem in self.svg.selection.id_dict().items(): + leftVal.append(elem.bounding_box().left) + elem.set('id','reset'+str(i))#reset all ids to prevent duplicate id problems + i+=1 + + leftVal.sort(key=float) + + i = 0 + for id, elem in self.svg.selection.id_dict().items(): + thisLeft=elem.bounding_box().left + charNo=leftVal.index(thisLeft) + + if i < len(listChar): + elem.set('id',listChar[charNo]) + i+=1 + else: + break + +if __name__ == '__main__': + setGlyphIDs().run() \ No newline at end of file