|
NovaSVG 0.11.5
An SVG library
|
#include <svg.h>
Public Types | |
| enum class | pdf_mode { vector , raster } |
| How render_to_pdf() writes the page. More... | |
| enum class | pdf_text { outlines , embed , embed_ignore_license } |
| How render_to_pdf() writes text in the vector mode (the raster mode has no text). More... | |
Public Member Functions | |
| void | apply_style_sheet (const std::string &content) |
| Applies a CSS stylesheet to the dom. | |
| element_list | query_selector_all (const std::string &content) const |
| Selects all elements that match the given CSS selector(s). | |
| const std::string & | title () const |
| Returns the text of the root <svg>'s first <title> child (entities decoded, white space trimmed), or an empty string when there is none. render_to_pdf() writes it as the PDF's /Title. | |
| float | width () const |
| Returns the intrinsic width of the dom in pixels. | |
| float | height () const |
| Returns the intrinsic height of the dom in pixels. | |
| box | bounding_box () const |
| Returns the smallest rectangle that encloses the dom content. | |
| void | update_layout () |
| Updates the layout of the dom if needed. | |
| void | force_layout () |
| Forces an immediate layout update. | |
| void | render (stb::image &image, const stb::matrix &matrix=stb::matrix()) const |
| Renders the dom onto an existing image, using a transformation matrix. | |
| stb::image | render_to_image (int width=-1, int height=-1, const stb::color &background_color=stb::color(0, 0, 0, 0)) const |
| Renders the dom to a new straight-alpha RGBA image with specified dimensions. | |
| void | render (pixmap &bitmap, const stb::matrix &matrix=stb::matrix()) const |
| pixmap | render_to_pixmap (int width=-1, int height=-1, const stb::color &background_color=stb::color(0, 0, 0, 0)) const |
| std::vector< uint8_t > | render_to_pdf (pdf_mode mode=pdf_mode::vector, float dpi=192.f, pdf_text text=pdf_text::outlines) const |
| Renders the document as a one-page PDF (page size = the document's size, 1 px = 0.75 pt). | |
| bool | save_pdf (const std::string &filename, pdf_mode mode=pdf_mode::vector, float dpi=192.f, pdf_text text=pdf_text::outlines) const |
| render_to_pdf() written to a file. | |
| element | element_from_point (float x, float y) const |
| Returns the topmost el under the specified point. | |
| element | element_by_id (const std::string &id) const |
| Retrieves an el by its ID. | |
| element | document_element () const |
| Retrieves the dom el. | |
| document (document &&) | |
| document & | operator= (document &&) |
| ~document () | |
| void | set_foreign_object_renderer (std::shared_ptr< foreign_object_renderer > renderer) |
| Sets the renderer that draws this document's <foreignObject> elements (see foreign_object.h). | |
| std::shared_ptr< foreign_object_renderer > | foreign_object_renderer_ptr () const |
| The renderer in use (null: foreignObject elements are skipped). | |
Static Public Member Functions | |
| static std::unique_ptr< document > | load_file (const std::string &filename) |
| Load an svg dom from a file. | |
| static std::unique_ptr< document > | load_data (const std::string &string) |
| Load an svg dom from a string. | |
| static std::unique_ptr< document > | load_data (const char *data) |
| Load an svg dom from a null-terminated string. | |
| static std::unique_ptr< document > | load_data (const char *data, size_t length_) |
| Load an svg dom from a string with a specified length. | |
Friends | |
| class | svg_uri_reference |
| class | svg_node |
|
strong |
How render_to_pdf() writes the page.
| Enumerator | |
|---|---|
| vector | |
| raster | |
|
strong |
How render_to_pdf() writes text in the vector mode (the raster mode has no text).
| Enumerator | |
|---|---|
| outlines | |
| embed | |
| embed_ignore_license | |
| nova::svg::document::document | ( | document && | ) |
References document().
Referenced by document(), and operator=().
| nova::svg::document::~document | ( | ) |
| void nova::svg::document::apply_style_sheet | ( | const std::string & | content | ) |
Applies a CSS stylesheet to the dom.
| content | A string containing the CSS rules to apply, with comments removed. |
| box nova::svg::document::bounding_box | ( | ) | const |
Returns the smallest rectangle that encloses the dom content.
| element nova::svg::document::document_element | ( | ) | const |
Retrieves the dom el.
| element nova::svg::document::element_by_id | ( | const std::string & | id | ) | const |
Retrieves an el by its ID.
| id | The ID of the el to retrieve. |
| element nova::svg::document::element_from_point | ( | float | x, |
| float | y ) const |
Returns the topmost el under the specified point.
| x | The x-coordinate in viewport space. |
| y | The y-coordinate in viewport space. |
| void nova::svg::document::force_layout | ( | ) |
Forces an immediate layout update.
|
inline |
| float nova::svg::document::height | ( | ) | const |
Returns the intrinsic height of the dom in pixels.
Referenced by render_to_image(), and render_to_pixmap().
|
static |
Load an svg dom from a null-terminated string.
| data | The string containing the svg data. |
|
static |
Load an svg dom from a string with a specified length.
| data | The string containing the svg data. |
| length | The length of the string in bytes. |
|
static |
Load an svg dom from a string.
| string | The svg data as a string. |
|
static |
Load an svg dom from a file.
| filename | The path to the svg file. |
References document().
| element_list nova::svg::document::query_selector_all | ( | const std::string & | content | ) | const |
Selects all elements that match the given CSS selector(s).
| content | A string containing the CSS selector(s) to match elements. |
| void nova::svg::document::render | ( | pixmap & | bitmap, |
| const stb::matrix & | matrix = stb::matrix() ) const |
| void nova::svg::document::render | ( | stb::image & | image, |
| const stb::matrix & | matrix = stb::matrix() ) const |
Renders the dom onto an existing image, using a transformation matrix.
The dom is drawn on a transparent layer the size of image and the layer is composited over the image's pixels with stb::image::blend (normal mode, "over" with straight alpha). Because the layer starts transparent, mix-blend-mode inside the dom blends against the layer, not against what was already in image. A root background-color is composited over the image too, instead of replacing it. Any pixel format is accepted; images larger than 32767 pixels on a side are left untouched.
| image | The image to render onto (changed in place). |
| matrix | The root transformation matrix. |
| stb::image nova::svg::document::render_to_image | ( | int | width = -1, |
| int | height = -1, | ||
| const stb::color & | background_color = stb::color(0, 0, 0, 0) ) const |
Renders the dom to a new straight-alpha RGBA image with specified dimensions.
| width | The desired width in pixels, or -1 to auto-scale based on the intrinsic size. |
| height | The desired height in pixels, or -1 to auto-scale based on the intrinsic size. |
| backgroundColor | The background color to render onto. |
| std::vector< uint8_t > nova::svg::document::render_to_pdf | ( | pdf_mode | mode = pdf_mode::vector, |
| float | dpi = 192.f, | ||
| pdf_text | text = pdf_text::outlines ) const |
Renders the document as a one-page PDF (page size = the document's size, 1 px = 0.75 pt).
| mode | See pdf_mode. |
| dpi | Resolution of every bitmap in the file (96 is the SVG's own pixel size). |
| text | How text is written, see pdf_text. |
| pixmap nova::svg::document::render_to_pixmap | ( | int | width = -1, |
| int | height = -1, | ||
| const stb::color & | background_color = stb::color(0, 0, 0, 0) ) const |
| bool nova::svg::document::save_pdf | ( | const std::string & | filename, |
| pdf_mode | mode = pdf_mode::vector, | ||
| float | dpi = 192.f, | ||
| pdf_text | text = pdf_text::outlines ) const |
render_to_pdf() written to a file.
| void nova::svg::document::set_foreign_object_renderer | ( | std::shared_ptr< foreign_object_renderer > | renderer | ) |
Sets the renderer that draws this document's <foreignObject> elements (see foreign_object.h).
The default is the built-in simple HTML renderer. A null renderer skips every foreignObject.
| const std::string & nova::svg::document::title | ( | ) | const |
Returns the text of the root <svg>'s first <title> child (entities decoded, white space trimmed), or an empty string when there is none. render_to_pdf() writes it as the PDF's /Title.
| void nova::svg::document::update_layout | ( | ) |
Updates the layout of the dom if needed.
| float nova::svg::document::width | ( | ) | const |
Returns the intrinsic width of the dom in pixels.
Referenced by render_to_image(), and render_to_pixmap().
|
friend |
|
friend |
Definition at line 493 of file svg.h.
References svg_uri_reference.
Referenced by svg_uri_reference.