Some mods to primitive extension and viewbox
This commit is contained in:
parent
5f624d6692
commit
952d8b10cc
@ -5,6 +5,7 @@
|
||||
<label appearance="header">Settings</label>
|
||||
<separator/>
|
||||
<param name="keeporiginal" type="bool" gui-text="Keep original image on canvas">false</param>
|
||||
<param name="cliprect" type="bool" gui-text="Draw clipping rectangle">true</param>
|
||||
<param name="n" type="int" min="0" max="99999" gui-text="Number of shapes">100</param>
|
||||
<param name="m" appearance="combo" type="optiongroup" default="1" gui-text="Mode">
|
||||
<option value="0">Combo</option>
|
||||
|
@ -58,6 +58,7 @@ class Primitive (inkex.Effect):
|
||||
def __init__(self):
|
||||
inkex.Effect.__init__(self)
|
||||
self.arg_parser.add_argument("--keeporiginal", type=inkex.Boolean, default=False, help="Keep original image on canvas")
|
||||
self.arg_parser.add_argument("--cliprect", type=inkex.Boolean, default=True, help="Draw clipping rectangle")
|
||||
self.arg_parser.add_argument("--n", type=int, default=100, help="Number of shapes")
|
||||
self.arg_parser.add_argument("--m", default=1, help="Mode")
|
||||
self.arg_parser.add_argument("--rep", type=int, default=0,help="Extra shapes/iteration")
|
||||
@ -138,6 +139,26 @@ class Primitive (inkex.Effect):
|
||||
#remove the old image or not
|
||||
if self.options.keeporiginal is not True:
|
||||
node.getparent().remove(node)
|
||||
|
||||
# create clip path to remove the stuffy surroundings
|
||||
if self.options.cliprect:
|
||||
path = '//svg:defs'
|
||||
defslist = self.document.getroot().xpath(path, namespaces=inkex.NSS)
|
||||
if len(defslist) > 0:
|
||||
defs = defslist[0]
|
||||
clipPathData = {inkex.addNS('label', 'inkscape'):'imagetracerClipPath', 'clipPathUnits':'userSpaceOnUse', 'id':'imagetracerClipPath'}
|
||||
clipPath = etree.SubElement(defs, 'clipPath', clipPathData)
|
||||
#inkex.utils.debug(image.width)
|
||||
clipBox = {
|
||||
'x':str(0),
|
||||
'y':str(0),
|
||||
'width':str(doc.get('width')),
|
||||
'height':str(doc.get('height')),
|
||||
'style':'fill:#000000; stroke:none; fill-opacity:1;'
|
||||
}
|
||||
etree.SubElement(clipPath, 'rect', clipBox)
|
||||
#etree.SubElement(newGroup, 'g', {inkex.addNS('label','inkscape'):'imagetracerjs', 'clip-path':"url(#imagetracerClipPath)"})
|
||||
newGroup.getchildren()[0].set('clip-path','url(#imagetracerClipPath)')
|
||||
else:
|
||||
inkex.utils.debug("No image found for tracing. Please select an image first.")
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (c) 2012 Stuart Pernsteiner
|
||||
# All rights reserved.
|
||||
#
|
||||
@ -24,8 +26,6 @@
|
||||
import sys
|
||||
import inkex
|
||||
from inkex import Transform
|
||||
import gettext
|
||||
_ = gettext.gettext
|
||||
|
||||
class SetViewBoxEffect(inkex.Effect):
|
||||
def __init__(self):
|
||||
@ -33,7 +33,9 @@ class SetViewBoxEffect(inkex.Effect):
|
||||
|
||||
def effect(self):
|
||||
if len(self.svg.selected) != 1:
|
||||
sys.exit(_("Error: You must select exactly one rectangle"))
|
||||
sys.exit("Error: You must select exactly one rectangle")
|
||||
elif self.svg.selected[0].tag != inkex.addNS('rect','svg'):
|
||||
sys.exit("Error: You must select exactly one rectangle")
|
||||
|
||||
sel = None
|
||||
for pathId in self.svg.selected:
|
||||
|
Reference in New Issue
Block a user