Exporting SVG with transparent background


hi all! i’m looking to export some very simple arcs i have as an svg. however i intend on using the file with a pcb milling machine, so i need the background to be transparent, otherwise the milling software interprets it as a fill and it will mill out a square rather than just my arcs. i thought i could do this with

ofClear(255, 255, 255, 0);

in setup, and then

if (exportSVG) ofBeginSaveScreenAsSVG("test.svg");

for (ofPolyline &arc: arcs) 

if (exportSVG)
    exportSVG = false;

in draw. i end up with this:

which ostensibly would be fine, but when i open this in illustrator, the background seems to be filled, and it’s something i can erase / select + delete, so it doesn’t seem like the pixels are cleared.

would be great if somebody who had more familiarity than me was able to explain what was happening! i’d like to be able to just export an svg with the transparent background straight from the app.



instead of ofClear can you try ofSetBackgroundColor() and don’t use ofSetBackgroundAuto?


hi arturo! with

ofColor color = ofColor(255, 255, 255, 0);

in setup, i get the same results:



here’s a gdrive link to a short video demonstrating that the background hasn’t cleared for me. i export the svg from the app, open it in illustrator, and select + delete it.


Not sure what your work flow is, but you could bring it into Illustrator and release clipping mask, ungroup and delete anything you want (including the background).


hey @bakercp thanks for replying :slightly_smiling_face: i have to keep it all within openframeworks actually! would like to try to understand what’s happening here


can you try using ofSetBackgroundAuto(false) and not calling any kind of background clearing?

I think this might be a bug i’ll try to take a look for next release but meanwhile you can probably disable background clear completely in ofCairoRenderer, around line 1147. just commend any line where it says cairo_paint(cr)


@arturo the first suggestion didn’t seem to change anything! commenting out cairo_paint(cr) did though. here’s a screenshot of the file i was able to produce along with how it appears in the milling software:


so thanks for pointing me in that direction. i’m not too familiar with cairo so i’ll add this to the list of things i should read up on.

Implementing Dubins path?