summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorajuanpi <>2016-05-24 13:23:46 +0000
committerJazzyNico <nicoduf@yahoo.fr>2016-05-24 13:23:46 +0000
commitf96a7eb3f99d0893ddb1e07bd1d9853737e9b033 (patch)
treec131ce125dcfb343bd8e91fc6966001627214579
parent[Bug #1183473] Convert to Dashes does not work with an imported svg. (diff)
downloadinkscape-f96a7eb3f99d0893ddb1e07bd1d9853737e9b033.tar.gz
inkscape-f96a7eb3f99d0893ddb1e07bd1d9853737e9b033.zip
[Bug #1071833] major update of Jitter Nodes extension.
Fixed bugs: - https://launchpad.net/bugs/1071833 (bzr r14912)
-rw-r--r--po/POTFILES.in5
-rw-r--r--share/extensions/jitternodes.inx (renamed from share/extensions/radiusrand.inx)13
-rwxr-xr-xshare/extensions/jitternodes.py (renamed from share/extensions/radiusrand.py)82
-rwxr-xr-xshare/extensions/test/jitternodes.test.py (renamed from share/extensions/test/radiusrand.test.py)8
4 files changed, 68 insertions, 40 deletions
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 1dfd26eb1..f760c718c 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,6 +1,6 @@
# List of source files containing translatable strings.
# Please keep this file sorted alphabetically.
-# Generated by ./generate_POTFILES.sh at Thu Apr 14 04:25:58 CEST 2016
+# Generated by ./generate_POTFILES.sh at Mon May 23 11:59:28 CEST 2016
[encoding: UTF-8]
inkscape.appdata.xml.in
inkscape.desktop.in
@@ -148,7 +148,6 @@ src/live_effects/lpe-interpolate_points.cpp
src/live_effects/lpe-jointype.cpp
src/live_effects/lpe-knot.cpp
src/live_effects/lpe-lattice2.cpp
-src/live_effects/lpe-mirror_symmetry.cpp
src/live_effects/lpe-patternalongpath.cpp
src/live_effects/lpe-perspective-envelope.cpp
src/live_effects/lpe-powerstroke.cpp
@@ -524,6 +523,7 @@ share/extensions/wireframe_sphere.py
[type: gettext/xml] share/extensions/jessyInk_uninstall.inx
[type: gettext/xml] share/extensions/jessyInk_video.inx
[type: gettext/xml] share/extensions/jessyInk_view.inx
+[type: gettext/xml] share/extensions/jitternodes.inx
[type: gettext/xml] share/extensions/layers2svgfont.inx
[type: gettext/xml] share/extensions/layout_nup.inx
[type: gettext/xml] share/extensions/lindenmayer.inx
@@ -549,7 +549,6 @@ share/extensions/wireframe_sphere.py
[type: gettext/xml] share/extensions/print_win32_vector.inx
[type: gettext/xml] share/extensions/printing_marks.inx
[type: gettext/xml] share/extensions/ps_input.inx
-[type: gettext/xml] share/extensions/radiusrand.inx
[type: gettext/xml] share/extensions/render_alphabetsoup.inx
[type: gettext/xml] share/extensions/render_barcode.inx
[type: gettext/xml] share/extensions/render_barcode_datamatrix.inx
diff --git a/share/extensions/radiusrand.inx b/share/extensions/jitternodes.inx
index 38e7d6c4c..817fbd276 100644
--- a/share/extensions/radiusrand.inx
+++ b/share/extensions/jitternodes.inx
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<_name>Jitter nodes</_name>
- <id>org.ekips.filter.radiusrand</id>
- <dependency type="executable" location="extensions">radiusrand.py</dependency>
+ <id>org.ekips.filter.jitternodes</id>
+ <dependency type="executable" location="extensions">jitternodes.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
<param name="tab" type="notebook">
<page name="Options" _gui-text="Options">
@@ -10,7 +10,12 @@
<param name="radiusy" type="float" min="0.0" max="1000.0" _gui-text="Maximum displacement in Y (px):">10.0</param>
<param name="end" type="boolean" _gui-text="Shift nodes">true</param>
<param name="ctrl" type="boolean" _gui-text="Shift node handles">false</param>
- <param name="norm" type="boolean" _gui-text="Use normal distribution">true</param>
+ <param name="dist" type="enum" _gui-text="Distribution of the displacements:">
+ <_item value="Uniform">Uniform</_item>
+ <_item value="Pareto">Pareto</_item>
+ <_item value="Gaussian">Gaussian</_item>
+ <_item value="Lognorm">Log-normal</_item>
+ </param>
</page>
<page name="Help" _gui-text="Help">
<_param name="title" type="description">This effect randomly shifts the nodes (and optionally node handles) of the selected path.</_param>
@@ -23,6 +28,6 @@
</effects-menu>
</effect>
<script>
- <command reldir="extensions" interpreter="python">radiusrand.py</command>
+ <command reldir="extensions" interpreter="python">jitternodes.py</command>
</script>
</inkscape-extension>
diff --git a/share/extensions/radiusrand.py b/share/extensions/jitternodes.py
index e4585ccd4..d6f5ce36d 100755
--- a/share/extensions/radiusrand.py
+++ b/share/extensions/jitternodes.py
@@ -1,10 +1,11 @@
-#!/usr/bin/env python
+#!/usr/bin/env python
'''
+Copyright (C) 2012 Juan Pablo Carbajal ajuanpi-dev@gmail.com
Copyright (C) 2005 Aaron Spike, aaron@ekips.org
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
+the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -18,40 +19,63 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
'''
import random, math, inkex, cubicsuperpath
-def randomize((x, y), rx, ry, norm):
- if norm:
- r = abs(random.normalvariate(0.0,0.5*max(rx, ry)))
- else:
- r = random.uniform(0.0,max(rx, ry))
- a = random.uniform(0.0,2*math.pi)
- x += math.cos(a)*rx
- y += math.sin(a)*ry
+def randomize((x, y), rx, ry, dist):
+
+ if dist == "Gaussian":
+ r1 = random.gauss(0.0,rx)
+ r2 = random.gauss(0.0,ry)
+ elif dist == "Pareto":
+ '''
+ sign is used ot fake a double sided pareto distribution.
+ for parameter value between 1 and 2 the distribution has infinite variance
+ I truncate the distribution to a high value and then normalize it.
+ The idea is to get spiky distributions, any distribution with long-tails is
+ good (ideal would be Levy distribution).
+ '''
+ sign = random.uniform(-1.0,1.0)
+
+ r1 = min(random.paretovariate(1.0), 20.0)/20.0
+ r2 = min(random.paretovariate(1.0), 20.0)/20.0
+
+ r1 = rx * math.copysign(r1, sign)
+ r2 = ry * math.copysign(r2, sign)
+ elif dist == "Lognorm":
+ sign = random.uniform(-1.0,1.0)
+ r1 = rx * math.copysign(random.lognormvariate(0.0,1.0)/3.5,sign)
+ r2 = ry * math.copysign(random.lognormvariate(0.0,1.0)/3.5,sign)
+ elif dist == "Uniform":
+ r1 = random.uniform(-rx,rx)
+ r2 = random.uniform(-ry,ry)
+
+ x += r1
+ y += r2
+
return [x, y]
-class RadiusRandomize(inkex.Effect):
+class JitterNodes(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.OptionParser.add_option("--title")
self.OptionParser.add_option("-x", "--radiusx",
- action="store", type="float",
+ action="store", type="float",
dest="radiusx", default=10.0,
help="Randomly move nodes and handles within this radius, X")
self.OptionParser.add_option("-y", "--radiusy",
- action="store", type="float",
+ action="store", type="float",
dest="radiusy", default=10.0,
help="Randomly move nodes and handles within this radius, Y")
self.OptionParser.add_option("-c", "--ctrl",
- action="store", type="inkbool",
+ action="store", type="inkbool",
dest="ctrl", default=True,
help="Randomize control points")
self.OptionParser.add_option("-e", "--end",
- action="store", type="inkbool",
+ action="store", type="inkbool",
dest="end", default=True,
help="Randomize nodes")
- self.OptionParser.add_option("-n", "--norm",
- action="store", type="inkbool",
- dest="norm", default=True,
- help="Use normal distribution")
+ self.OptionParser.add_option("-d", "--dist",
+ action="store", type="string",
+ dest="dist", default="Uniform",
+ help="Choose the distribution of the displacements")
self.OptionParser.add_option("--tab",
action="store", type="string",
dest="tab",
@@ -65,20 +89,20 @@ class RadiusRandomize(inkex.Effect):
for subpath in p:
for csp in subpath:
if self.options.end:
- delta=randomize([0,0], self.options.radiusx, self.options.radiusy, self.options.norm)
- csp[0][0]+=delta[0]
- csp[0][1]+=delta[1]
- csp[1][0]+=delta[0]
- csp[1][1]+=delta[1]
- csp[2][0]+=delta[0]
- csp[2][1]+=delta[1]
+ delta=randomize([0,0], self.options.radiusx, self.options.radiusy, self.options.dist)
+ csp[0][0]+=delta[0]
+ csp[0][1]+=delta[1]
+ csp[1][0]+=delta[0]
+ csp[1][1]+=delta[1]
+ csp[2][0]+=delta[0]
+ csp[2][1]+=delta[1]
if self.options.ctrl:
- csp[0]=randomize(csp[0], self.options.radiusx, self.options.radiusy, self.options.norm)
- csp[2]=randomize(csp[2], self.options.radiusx, self.options.radiusy, self.options.norm)
+ csp[0]=randomize(csp[0], self.options.radiusx, self.options.radiusy, self.options.dist)
+ csp[2]=randomize(csp[2], self.options.radiusx, self.options.radiusy, self.options.dist)
node.set('d',cubicsuperpath.formatPath(p))
if __name__ == '__main__':
- e = RadiusRandomize()
+ e = JitterNodes()
e.affect()
diff --git a/share/extensions/test/radiusrand.test.py b/share/extensions/test/jitternodes.test.py
index 99cb2972b..699752af2 100755
--- a/share/extensions/test/radiusrand.test.py
+++ b/share/extensions/test/jitternodes.test.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-# This is only the automatic generated test file for ../radiusrand.py
+# This is only the automatic generated test file for ../jitternodes.py
# This must be filled with real tests and this commentary
# must be cleared.
# If you want to help, read the python unittest documentation:
@@ -10,15 +10,15 @@ import sys
sys.path.append('..') # this line allows to import the extension code
import unittest
-from radiusrand import *
+from jitternodes import *
-class RadiusRandomizeBasicTest(unittest.TestCase):
+class JitterNodesBasicTest(unittest.TestCase):
#def setUp(self):
def test_run_without_parameters(self):
args = [ 'minimal-blank.svg' ]
- e = RadiusRandomize()
+ e = JitterNodes()
e.affect( args, False )
#self.assertEqual( e.something, 'some value', 'A commentary about that.' )