How do you use vector file with Graphics class?


#1

How do you use a vector file with the Graphics class?

I would have thought there would be a function something like

Graphics g;

g.drawVectorFile(xml, x, y, width, height, opacity);

something like that.

Edit: Oh jeez I think I already have the answer and asked it in the past in a different way: How do I edit JUCE demo to draw a specific svg file?

Edit: It’s not immediately obvious how to change the height and width of the original. Maybe a tip on doing that is in order? :slight_smile:

Edit: Wait I think I got it. use drawWithin() instead of draw()

drawable->drawWithin(g, juce::Rectangle<float>(x, y, width, height), RectanglePlacement::Flags::centred, 1.0);

#2

I figured this out a while ago, see SVG bounding box (with some details about alignment)


#3

Another workaround might be doing a 0 opacity box for your svg to create bounds.

I was even thinking maybe some simple svg file manipulation could allow for some creative opportunities.