summaryrefslogtreecommitdiffstats
path: root/share/extensions/funcplot.py
diff options
context:
space:
mode:
authorAlvin Penner <penner@vaxxine.com>2012-12-24 02:21:36 +0000
committerapenner <penner@vaxxine.com>2012-12-24 02:21:36 +0000
commit2b08d8b3cc50015423e45effabdb43e71c59621a (patch)
tree04ffedc3646bde9dcadc1c3ef89d0c4436f16e9a /share/extensions/funcplot.py
parentMove some code from filter primitives to cairo-utils.cpp. Fix bug in lighting... (diff)
downloadinkscape-2b08d8b3cc50015423e45effabdb43e71c59621a.tar.gz
inkscape-2b08d8b3cc50015423e45effabdb43e71c59621a.zip
extensions. function plotter. patch by ~suv for clip rectangle (Bug 492103)
Fixed bugs: - https://launchpad.net/bugs/492103 (bzr r11977)
Diffstat (limited to 'share/extensions/funcplot.py')
-rwxr-xr-xshare/extensions/funcplot.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/share/extensions/funcplot.py b/share/extensions/funcplot.py
index 08ac15dbb..7f8fdafe1 100755
--- a/share/extensions/funcplot.py
+++ b/share/extensions/funcplot.py
@@ -28,6 +28,7 @@ Changes:
# standard library
from math import *
from random import *
+from copy import deepcopy
# local library
import inkex
import simplepath
@@ -217,6 +218,10 @@ class FuncPlot(inkex.Effect):
action="store", type="string",
dest="fpofx", default="cos(x)",
help="f'(x) for plotting")
+ self.OptionParser.add_option("--clip",
+ action="store", type="inkbool",
+ dest="clip", default=False,
+ help="If True, clip with copy of source rectangle")
self.OptionParser.add_option("--remove",
action="store", type="inkbool",
dest="remove", default=True,
@@ -293,6 +298,16 @@ class FuncPlot(inkex.Effect):
# add path into SVG structure
node.getparent().append(newpath)
+ # option whether to clip the path with rect or not.
+ if self.options.clip:
+ defs = self.xpathSingle('/svg:svg//svg:defs')
+ if defs == None:
+ defs = inkex.etree.SubElement(self.document.getroot(),inkex.addNS('defs','svg'))
+ clip = inkex.etree.SubElement(defs,inkex.addNS('clipPath','svg'))
+ clip.append(deepcopy(node))
+ clipId = self.uniqueId('clipPath')
+ clip.set('id', clipId)
+ newpath.set('clip-path', 'url(#'+clipId+')')
# option wether to remove the rectangle or not.
if self.options.remove:
node.getparent().remove(node)