From 1637dfcadb49da133c1e14b5d20c32cfebd0d3a3 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Wed, 15 Sep 2010 20:27:36 -0400 Subject: option to add endpoints on x-axis (Bug 628266) Fixed bugs: - https://launchpad.net/bugs/628266 (bzr r9763) --- share/extensions/funcplot.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'share/extensions/funcplot.py') diff --git a/share/extensions/funcplot.py b/share/extensions/funcplot.py index 126429853..b94fda278 100644 --- a/share/extensions/funcplot.py +++ b/share/extensions/funcplot.py @@ -30,7 +30,7 @@ from math import * from random import * def drawfunction(xstart, xend, ybottom, ytop, samples, width, height, left, bottom, - fx = "sin(x)", fpx = "cos(x)", fponum = True, times2pi = False, polar = False, isoscale = True, drawaxis = True): + fx = "sin(x)", fpx = "cos(x)", fponum = True, times2pi = False, polar = False, isoscale = True, drawaxis = True, endpts = False): if times2pi == True: xstart = 2 * pi * xstart @@ -122,7 +122,11 @@ def drawfunction(xstart, xend, ybottom, ytop, samples, width, height, left, bott dy0 = fp(xstart) # Start curve - a.append([' M ',[coordx(x0), coordy(y0)]]) # initial moveto + if endpts: + a.append([' M ',[left, coordy(0)]]) + a.append([' L ',[coordx(x0), coordy(y0)]]) + else: + a.append([' M ',[coordx(x0), coordy(y0)]]) # initial moveto for i in range(int(samples-1)): x1 = (i+1) * step + xstart @@ -153,7 +157,9 @@ def drawfunction(xstart, xend, ybottom, ytop, samples, width, height, left, bott x0 = x1 # Next segment's start is this segments end y0 = y1 dx0 = dx1 # Assume the function is smooth everywhere, so carry over the derivative too - dy0 = dy1 + dy0 = dy1 + if endpts: + a.append([' L ',[left + width, coordy(0)]]) return a class FuncPlot(inkex.Effect): @@ -211,6 +217,10 @@ class FuncPlot(inkex.Effect): action="store", type="inkbool", dest="drawaxis", default=True, help="If True, axis are drawn") + self.OptionParser.add_option("--endpts", + action="store", type="inkbool", + dest="endpts", default=False, + help="If True, end points are added") self.OptionParser.add_option("--tab", action="store", type="string", dest="tab", default="sampling", @@ -257,7 +267,8 @@ class FuncPlot(inkex.Effect): self.options.times2pi, self.options.polar, self.options.isoscale, - self.options.drawaxis))) + self.options.drawaxis, + self.options.endpts))) newpath.set('title', self.options.fofx) #newpath.setAttribute('desc', '!func;' + self.options.fofx + ';' -- cgit v1.2.3 From 144819c918dc761641c3cb5a490205fb73194ee3 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Wed, 17 Nov 2010 13:12:56 +1100 Subject: Super duper mega (fun!) commit: replaced encoding=utf-8 with fileencoding=utf-8 in all 1074 Vim modelines. The reason for this is that (a) setting the encoding isn't nice, and (b) Vim 7.3 (with modeline enabled) disallows it and pops up an error whenever you open any file with it ("invalid modeline"). Also corrected five deviant modestrings: * src/ui/widget/dock.cpp and src/ui/widget/dock.h: missing colon at the end * src/ui/dialog/tile.cpp: removed gratuitous second colon at the end * src/helper/units-test.h: removed gratuitous space before a colon * share/extensions/export_gimp_palette.py: missing textwidth=99 That's my geekiest commit yet. (bzr r9900) --- share/extensions/funcplot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'share/extensions/funcplot.py') diff --git a/share/extensions/funcplot.py b/share/extensions/funcplot.py index b94fda278..0beaf3946 100644 --- a/share/extensions/funcplot.py +++ b/share/extensions/funcplot.py @@ -289,4 +289,4 @@ if __name__ == '__main__': e.affect() -# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99 +# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 -- cgit v1.2.3