Questions tagged [svgwrite]

svgwrite is an extension to the Python programming language which provides support for creating SVG drawings.

Official Resources

42 questions
1
vote
1 answer

Right-aligning text in Python svgwrite

I'm trying to rotate text, and that part is working fine, but I want it to be right-justified and not left. In other words I want the text to end on the perimeter of the circle that I have calculated, not begin. This code draws a circle with 365…
PhilHibbs
  • 859
  • 1
  • 13
  • 30
1
vote
0 answers

Autofill SVG object with text (Python / svgwrite)?

I am creating an SVG using svgwrite in Python and would like to create some object, say, a rectangle with sizes xsize and ysize, and also some text to fill it: import svgwrite xsize = 20 ysize = 30 xcoord = 0 ycoord = 0 mystr = 'some text more…
Zubo
  • 1,543
  • 2
  • 20
  • 26
1
vote
1 answer

Rotate path with svgwrite

Let's say I create a drawing with an arrow in SVG with svgwrite: In [1]: import svgwrite In [2]: dwg = svgwrite.Drawing('arrow.svg') In [3]: path = dwg.path(d='M 0,283.45145 H 39.819792 v 13.22917 L 66.278127,270.22229 39.819793,243.76395 v…
mrgou
  • 1,576
  • 2
  • 21
  • 45
1
vote
1 answer

Manipulating SVG-files with python

Is it possible to manipulate existing svg files in python? I know the svgwrite package but it only creates new svg files... I just want to add 3 numbers to an existing svg file. It should be only an update showing the old svg file with these 3 new…
roflcopter122
  • 165
  • 1
  • 14
1
vote
2 answers

Adding links to SVG elements in Python using SVGWRITE

I am trying to build an SVG that would feature lines, each line would link to a part elsewhere in the same document. I keep getting a ValueError, however, stating that "Invalid children 'line' for svg-element ." This MWE reproduces the…
cforster
  • 577
  • 2
  • 7
  • 19
1
vote
1 answer

TextPath with svgwrite - ValueError: Invalid children 'textPath' for svg-element

I have problems to use TextPath element with svgwrite library. I followed the documentation https://pythonhosted.org/svgwrite/classes/text.html#textpath I have path: w = dwg.path(d="M150 150 L2000 2000 L150 2000 Z", stroke="green") And that path I…
matousc
  • 3,698
  • 10
  • 40
  • 65
1
vote
1 answer

Flipped output using svgwrite-1.1.9

Building svg file using svgwrite-1.1.9 using polyline entities. How can I prevent flipped output? It seems the coordinates are messed up - vertical (y) is flipped. Here's the code I'm using to generate the polyline: # generate svg element line =…
shawn
  • 549
  • 1
  • 5
  • 11
0
votes
0 answers

Merging different svg elements using svgwrite

I am using SVGWrite to create different files with certain paths in the following way: dwg = svgwrite.Drawing(filename=save_path) dwg.viewbox(width=view_width, height=view_height) path = svgwrite.path.Path(p) dwg.add(path) I now need to "merge"…
0
votes
0 answers

I have svgwrite installed, but I get error: ModuleNotFoundError: No module named 'svgwrite' MacBook Pro Ventura 13.0.1

When I run my python code using svgwrite I get an error message: ModuleNotFoundError: No module named 'svgwrite'. I have svgwrite installed and when I tried to install it again with pip install svgwrite, I get this message: Requirement already…
0
votes
0 answers

How can I use svgwrite.image.Image to set an image in the background of a canvas I have other elements on?

I have an svgwrite.Drawing into which I wish to insert a JPG image as the background image. Here's the code to what I have so far. It is using computer vision for a machine learning task. The essential part to help me begin understanding how I can…
0
votes
1 answer

svgwrite: how to use Transform mixin

I want to transform a gradient to a certain degree. # I want to do something like this transform = svgwrite.mixins.Transform() transform = transform.rotate(angle="138") vert_grad = svgwrite.gradients.LinearGradient(start=(0, 0), end=(0,1),…
kyuden
  • 197
  • 1
  • 11
0
votes
1 answer

svgwrite example code not showing anything

I installed the svgwrite package, and ran the example code at the very first of the README dwg = svgwrite.Drawing('test.svg', profile='tiny') dwg.add(dwg.line((0, 0), (10, 0), stroke=svgwrite.rgb(10, 10, 16, '%'))) dwg.add(dwg.text('Test',…
kyuden
  • 197
  • 1
  • 11
0
votes
1 answer

Cutting out intersecting lines in SVG files using python

I am attempting to generate svgs where all the stuff in the middle of the outer ring of circles is removed. Ideally I would like this to all be in one path. So far I have tried calculating arcs and merging them with circle paths but that gets kinda…
Sichrono
  • 1
  • 1
0
votes
0 answers

Stack svg layers with python

I'm trying to stack different svg images as layers onto a base svg which is empty using python 3.9 and svgutils and svgwrite methods. The code gets all the svgs from one directory and images filenames are formatted as "n_x.svg" where n and x are…
oilCPL
  • 1
0
votes
1 answer

Scale and center any svg element full-viewport

My appologies for being the nth person to ask this question. I've snooped around a bunch and haven't cracked it yet. I would like to be able to scale "any" svg to the full size of the viewport, centered. For example, consider the following svg…
Captain Midday
  • 659
  • 8
  • 18