Re: Generating SVG from turtle graphics
https://image.online-convert.com/convert-to-svg On 15 Jan 2018 02:55, "Niles Rogoff"wrote: > On Sun, 14 Jan 2018 16:32:53 +0400, Abdur-Rahmaan Janhangeer wrote: > > > maybe save to .png then use another tool to svg > > PNG is a bitmap format[1], so you can't covert it to an SVG (a vector > format) without guessing things like the start/end points of the lines, > their slopes, etc... not to mention things like arcs. > > [1] RFC2083 > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Generating SVG from turtle graphics
Peter Otten <__pete...@web.de> writes: > Then convert to SVG with an external tool. It looks like ghostscript can do > that: > > $ gs -dBATCH -dNOPAUSE -sDEVICE=svg -sOutputFile=tmp_turtle.svg tmp_turtle.ps And if not (I at least don't have svg output on three ghostscripts I tried), pstoedit can do it too. -- https://mail.python.org/mailman/listinfo/python-list
Re: Generating SVG from turtle graphics
On Sun, 14 Jan 2018 16:32:53 +0400, Abdur-Rahmaan Janhangeer wrote: > maybe save to .png then use another tool to svg PNG is a bitmap format[1], so you can't covert it to an SVG (a vector format) without guessing things like the start/end points of the lines, their slopes, etc... not to mention things like arcs. [1] RFC2083 -- https://mail.python.org/mailman/listinfo/python-list
Re: Generating SVG from turtle graphics
11.01.18 13:03, Steven D'Aprano пише: I'd like to draw something with turtle, then generate a SVG file from it. Is this possible? If not, is there something I can do which lets me plot lines, shapes and curves and output to SVG? You can translate the following Tcl/Tk recipe to Python/Tkinter: http://wiki.tcl.tk/4534. Or just run the code directly in the buildin Tcl interpreter. -- https://mail.python.org/mailman/listinfo/python-list
Re: Generating SVG from turtle graphics
maybe save to .png then use another tool to svg On 11 Jan 2018 15:06, "Steven D'Aprano" < steve+comp.lang.pyt...@pearwood.info> wrote: > I'd like to draw something with turtle, then generate a SVG file from it. > > Is this possible? > > If not, is there something I can do which lets me plot lines, shapes and > curves and output to SVG? > > Ideally, I'd like to draw a figure pixel by pixel, and then have the SVG > library fit a bezier curve to it. > > > > > -- > Steve > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Generating SVG from turtle graphics
Steven D'Aprano wrote: > I'd like to draw something with turtle, then generate a SVG file from it. > > Is this possible? If this is a one-off job consider creating Postscript from the underlying Canvas: >>> import turtle >>> for i in range(12): ... turtle.forward(100) ... turtle.left(150) ... >>> turtle.getcanvas().postscript(file="tmp_turtle.ps") [...] Then convert to SVG with an external tool. It looks like ghostscript can do that: $ gs -dBATCH -dNOPAUSE -sDEVICE=svg -sOutputFile=tmp_turtle.svg tmp_turtle.ps -- https://mail.python.org/mailman/listinfo/python-list
Re: Generating SVG from turtle graphics
On 2018-01-11 12:03, Steven D'Aprano wrote: > I'd like to draw something with turtle, then generate a SVG file from it. > > Is this possible? > > If not, is there something I can do which lets me plot lines, shapes and > curves and output to SVG? > > Ideally, I'd like to draw a figure pixel by pixel, and then have the SVG > library fit a bezier curve to it. > You *could* use matplotlib, which can export to SVG. Of course, the API is far from ideal for drawing arbitrary shapes -- though it's naturally quite good with lines. There are some helpful examples in the docs: https://matplotlib.org/examples/ https://matplotlib.org/examples/shapes_and_collections/index.html https://matplotlib.org/api/patches_api.html https://matplotlib.org/api/pyplot_summary.html ... and so on ... I just played around with it for a few minutes to get a feel for how much boilerplate you need - ### from matplotlib import pyplot as plt from matplotlib.patches import Circle, Rectangle import numpy as np ax = plt.gca() ax.set_ylim([-2, 2]) ax.set_xlim([-2, 2]) ax.set_aspect('equal') plt.axis('off') circle = Circle([0,0], 1, fc='red', ec='none') halfdiag = np.sqrt(0.5) rect = Rectangle([-halfdiag, -halfdiag], 2*halfdiag, 2*halfdiag, fc='yellow', ec='none') ax.add_patch(circle) ax.add_patch(rect) plt.savefig('/tmp/test.svg') ### - and this gave a reasonable-looking SVG - ### http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd;> http://www.w3.org/2000/svg; xmlns:xlink="http://www.w3.org/1999/xlink;> *{stroke-linecap:butt;stroke-linejoin:round;} -- https://mail.python.org/mailman/listinfo/python-list
Re: Generating SVG from turtle graphics
Steven D'Apranowrites: > Ideally, I'd like to draw a figure pixel by pixel, and then have the SVG > library fit a bezier curve to it. Uhm, dunno if it is a good approach, it really depends on the kind of "figures" you are going to draw. Anyway, in the past I used http://pyx.sourceforge.net/ to produce the images for a book[1] on the Carrom game, and I enjoyed its simplicity. ciao, lele. [1] https://bitbucket.org/lele/cta -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. l...@metapensiero.it | -- Fortunato Depero, 1929. -- https://mail.python.org/mailman/listinfo/python-list
Generating SVG from turtle graphics
I'd like to draw something with turtle, then generate a SVG file from it. Is this possible? If not, is there something I can do which lets me plot lines, shapes and curves and output to SVG? Ideally, I'd like to draw a figure pixel by pixel, and then have the SVG library fit a bezier curve to it. -- Steve -- https://mail.python.org/mailman/listinfo/python-list