summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbulia byak <buliabyak@gmail.com>2008-05-05 01:22:48 +0000
committerbuliabyak <buliabyak@users.sourceforge.net>2008-05-05 01:22:48 +0000
commit82c1b6bde1fcd65bd44dcb5d1325e77926864d7c (patch)
tree49666b16e399fa9e9eca3dee00ce7ff0e627d0a4
parentRemove warnings (diff)
downloadinkscape-82c1b6bde1fcd65bd44dcb5d1325e77926864d7c.tar.gz
inkscape-82c1b6bde1fcd65bd44dcb5d1325e77926864d7c.zip
separate x and y jittering
(bzr r5605)
-rw-r--r--share/extensions/radiusrand.inx3
-rwxr-xr-xshare/extensions/radiusrand.py26
2 files changed, 17 insertions, 12 deletions
diff --git a/share/extensions/radiusrand.inx b/share/extensions/radiusrand.inx
index 92fa5cd54..3349f4549 100644
--- a/share/extensions/radiusrand.inx
+++ b/share/extensions/radiusrand.inx
@@ -5,7 +5,8 @@
<dependency type="executable" location="extensions">radiusrand.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
<_param name="title" type="description">This effect randomly shifts the nodes (and optionally node handles) of the selected path.</_param>
- <param name="radius" type="float" min="0.0" max="1000.0" _gui-text="Maximum displacement, px">100.0</param>
+ <param name="radiusx" type="float" min="0.0" max="1000.0" _gui-text="Maximum displacement in X, px">10.0</param>
+ <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>
diff --git a/share/extensions/radiusrand.py b/share/extensions/radiusrand.py
index 5eb73965b..902601c28 100755
--- a/share/extensions/radiusrand.py
+++ b/share/extensions/radiusrand.py
@@ -18,24 +18,28 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'''
import random, math, inkex, cubicsuperpath
-def randomize((x, y), r, norm):
+def randomize((x, y), rx, ry, norm):
if norm:
- r = abs(random.normalvariate(0.0,0.5*r))
+ r = abs(random.normalvariate(0.0,0.5*max(rx, ry)))
else:
- r = random.uniform(0.0,r)
+ r = random.uniform(0.0,max(rx, ry))
a = random.uniform(0.0,2*math.pi)
- x += math.cos(a)*r
- y += math.sin(a)*r
+ x += math.cos(a)*rx
+ y += math.sin(a)*ry
return [x, y]
class RadiusRandomize(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.OptionParser.add_option("--title")
- self.OptionParser.add_option("-r", "--radius",
+ self.OptionParser.add_option("-x", "--radiusx",
action="store", type="float",
- dest="radius", default=10.0,
- help="Randomly move control and end points in this radius")
+ 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",
+ 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",
dest="ctrl", default=True,
@@ -56,7 +60,7 @@ class RadiusRandomize(inkex.Effect):
for subpath in p:
for csp in subpath:
if self.options.end:
- delta=randomize([0,0], self.options.radius, self.options.norm)
+ 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]
@@ -64,8 +68,8 @@ class RadiusRandomize(inkex.Effect):
csp[2][0]+=delta[0]
csp[2][1]+=delta[1]
if self.options.ctrl:
- csp[0]=randomize(csp[0], self.options.radius, self.options.norm)
- csp[2]=randomize(csp[2], self.options.radius, self.options.norm)
+ 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)
node.set('d',cubicsuperpath.formatPath(p))
e = RadiusRandomize()