Code

Added "multiply x-range with 2*pi" option to function plotter for easier use
authorjohanengelen <johanengelen@users.sourceforge.net>
Fri, 24 Nov 2006 21:36:32 +0000 (21:36 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Fri, 24 Nov 2006 21:36:32 +0000 (21:36 +0000)
share/extensions/funcplot.inx
share/extensions/funcplot.py

index a7318ccbf80c51dc8fd35ab9b9819a8647b3b748..5c9ba6230dd760b5f354c4dbebc85d5fb7368274 100644 (file)
@@ -7,6 +7,7 @@
            <page name="sampling" _gui-text="Sampling">\r
                <param name="xstart" type="float" min="-1000.0" max="1000.0" _gui-text="Start x-value">0.0</param>\r
                <param name="xend" type="float" min="-1000.0" max="1000.0" _gui-text="End x-value">1.0</param>\r
+               <param name="times2pi" type="boolean" _gui-text="Multiply x-range by 2*pi">false</param>\r
                <param name="ybottom" type="float" min="-1000.0" max="1000.0" _gui-text="y-value of rectangle's bottom">0.0</param>\r
                <param name="ytop" type="float" min="-1000.0" max="1000.0" _gui-text="y-value of rectangle's top">1.0</param>\r
                <param name="samples" type="int" min="2" max="1000" _gui-text="Samples">8</param>\r
index f555bb612c3e3574a23fee73493a0402549be447..d4154dfe7ea1226be17da36b793b9e813ea61314 100644 (file)
@@ -25,8 +25,12 @@ from math import *
 from random import *\r
 \r
 def drawfunction(xstart, xend, ybottom, ytop, samples, width, height, left, top, \r
-    fx = "sin(x)", fpx = "cos(x)", fponum = True):\r
-\r
+    fx = "sin(x)", fpx = "cos(x)", fponum = True, times2pi = False):\r
+    \r
+    if times2pi == True:\r
+        xstart = 2 * pi * xstart\r
+        xend   = 2 * pi * xend   \r
+    \r
     # step is the distance between nodes on x\r
     step = (xend - xstart) / (samples-1)\r
     third = step / 3.0\r
@@ -83,6 +87,10 @@ class FuncPlot(inkex.Effect):
                         action="store", type="float", \r
                         dest="xend", default=1.0,\r
                         help="End x-value")\r
+        self.OptionParser.add_option("--times2pi",\r
+                        action="store", type="inkbool", \r
+                        dest="times2pi", default=True,\r
+                        help="Multiply x-range by 2*pi")    \r
         self.OptionParser.add_option("--ybottom",\r
                         action="store", type="float", \r
                         dest="ybottom", default=-1.0,\r
@@ -144,7 +152,8 @@ class FuncPlot(inkex.Effect):
                                 w,h,x,y,\r
                                 self.options.fofx, \r
                                 self.options.fpofx,\r
-                                self.options.fponum)))\r
+                                self.options.fponum,\r
+                                self.options.times2pi)))\r
                 newpath.setAttribute('title', self.options.fofx)\r
                 \r
                 #newpath.setAttribute('desc', '!func;' + self.options.fofx + ';' \r