Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

SVG Public Interface

class svg

Signature Description Notes
svg() Constructor The default image size is (400, 400)
g_element& add_g_element() Adds a g_element at the root of the document tree. Acts as a push_back() Returns the g_element that is pushed back. This allows you to do something like the following: image.add_g_element().line(/**/).line(/**/).rect(/**/);  Which adds two lines and a rectangle to the g_element that was just created.
svg& circle(double x, double y, unsigned int radius = 5) Adds a point at (x,y) in the root level of the document If the user is calling the circle method, odds are they would prefer a real circle instead of a degenerate circle (a point). 5 is as good a default as any other, and the user does not likely want a point if they are making this call.
g_element& get_g_element(int) Gets the g_element at the index specified Gives a runtime error if you specify an index that does not contain a g_element. I am considering providing an iterator interface to access these elements.
unsigned int get_x_size() Returns the width of the image  
unsigned int get_y_size() Returns the height of the image  
svg& image_size(unsigned int, unsigned int) Sets the size of the image produced, in pixels  
svg& line(double x1, double y1, double x2, double y2) Adds a line from (x1,y1) to (x2,y2) in the root level of the document  
path_element& path() Pushes a path_element to the back of the tree and returns a reference to it. This allows you to do the following:
path_element& my_path = image.path();

my_path.M(3, 3).l(150, 150);
I'm open to suggestions for how to improve this process.
 
svg& rect(double x1, double y1, double width, double height) Adds a rectangle at point (x1, y1) that has width width and height height  
svg& text(double x, double y, std::string text) Adds text text at (x,y) in the root level of the document  
svg& write(const std::string&) Writes the document to the file represented by the argument Opens the file stream itself and tries to call write(std::ostream&). Throws std::runtime_exception if it can not open the file.
svg& write(std::ostream&) Writes the document to the stream represented by the argument  
Copyright © 2007 Jake Voytko

PrevUpHomeNext