Code

make whirl use the center of view as center of whirl
authorbuliabyak <buliabyak@users.sourceforge.net>
Sat, 31 Mar 2007 17:22:06 +0000 (17:22 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Sat, 31 Mar 2007 17:22:06 +0000 (17:22 +0000)
share/extensions/whirl.inx
share/extensions/whirl.py

index eb1293b2bde8ca18086110f1667c3e8110ce85d9..927294b53fda15a89b3e66cf1569a123a4eb95f8 100644 (file)
@@ -3,8 +3,6 @@
     <id>org.ekips.filter.whirl</id>
        <dependency type="executable" location="extensions">whirl.py</dependency>
        <dependency type="executable" location="extensions">inkex.py</dependency>
-       <param name="centerx" type="float" min="0.0" max="10000.0" _gui-text="Center X">0.0</param>
-       <param name="centery" type="float" min="0.0" max="10000.0" _gui-text="Center Y">0.0</param>
        <param name="whirl" type="float" min="0.00" max="1000.00" _gui-text="Amount of whirl">5.0</param>
        <param name="rotation" type="boolean" _gui-text="Rotation is clockwise">true</param>
     <effect>
index b2014191708785d791a56b77c38a26e45772b35f..3e9df6c1681644c35db02399fd51ba7f48939560 100644 (file)
@@ -21,14 +21,6 @@ import math, inkex, cubicsuperpath
 class Whirl(inkex.Effect):
     def __init__(self):
         inkex.Effect.__init__(self)
-        self.OptionParser.add_option("-x", "--centerx",
-                        action="store", type="float", 
-                        dest="centerx", default=10.0,
-                        help="")
-        self.OptionParser.add_option("-y", "--centery",
-                        action="store", type="float", 
-                        dest="centery", default=0.0,
-                        help="")
         self.OptionParser.add_option("-t", "--whirl",
                         action="store", type="float", 
                         dest="whirl", default=1.0,
@@ -49,16 +41,16 @@ class Whirl(inkex.Effect):
                 for sub in p:
                     for csp in sub:
                         for point in csp:
-                            point[0] -= self.options.centerx
-                            point[1] -= self.options.centery
+                            point[0] -= self.view_center[0]
+                            point[1] -= self.view_center[1]
                             dist = math.sqrt((point[0] ** 2) + (point[1] ** 2))
                             if dist != 0:
                                 a = rotation * dist * whirl
                                 theta = math.atan2(point[1], point[0]) + a
                                 point[0] = (dist * math.cos(theta))
                                 point[1] = (dist * math.sin(theta))
-                            point[0] += self.options.centerx
-                            point[1] += self.options.centery
+                            point[0] += self.view_center[0]
+                            point[1] += self.view_center[1]
                 d.value = cubicsuperpath.formatPath(p)
 
 e = Whirl()