Geometrize  1.0
C++ library for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
svgexporter.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdint>
4 #include <string>
5 #include <vector>
6 
7 #include "../bitmap/rgba.h"
8 
9 namespace geometrize
10 {
11 class Shape;
12 struct ShapeResult;
13 }
14 
15 namespace geometrize
16 {
17 
18 namespace exporter
19 {
20 
24 static const std::string SVG_STYLE_HOOK = "::svg_style_hook::";
25 
27 {
28  ELLIPSE_ITEM = 0, // Export as a translated, rotated and scaled svg <ellipse>. OpenFL's SVG library can't handle this
29  POLYGON = 1 // Export as a <polygon>, OpenFL's SVG library can handle this, but it looks quite ugly
30 };
31 
36 {
38  std::size_t itemId{ 0 }; // Id to tag the exported SVG shapes with
39 };
40 
48 std::string getSingleShapeSVGData(const geometrize::rgba& color, const geometrize::Shape& shape, SVGExportOptions options = SVGExportOptions{});
49 
59 std::string exportSingleShapeSVG(const geometrize::rgba& color, const geometrize::Shape& shape, const std::uint32_t width, const std::uint32_t height, SVGExportOptions options = SVGExportOptions{});
60 
69 std::string exportSVG(const std::vector<geometrize::ShapeResult>& data, const std::uint32_t width, const std::uint32_t height, SVGExportOptions options = SVGExportOptions{});
70 
71 }
72 
73 }
The SVGExportOptions struct represents the options that can be set for the SVG export.
Definition: svgexporter.h:35
std::string getSingleShapeSVGData(const geometrize::rgba &color, const geometrize::Shape &shape, SVGExportOptions options)
getSvgShapeData Gets the SVG data for a single shape. This is just the <rect>/<path> etc block for th...
Definition: svgexporter.cpp:240
RotatedEllipseSVGExportMode
Definition: svgexporter.h:26
std::string exportSVG(const std::vector< geometrize::ShapeResult > &data, const std::uint32_t width, const std::uint32_t height, SVGExportOptions options)
exportSVG Exports shape data as a complete SVG image.
Definition: svgexporter.cpp:261
static const std::string SVG_STYLE_HOOK
SVG_STYLE_HOOK A hook that an SVG exporter should use to augment shape styling produced by the getSvg...
Definition: svgexporter.h:24
The rgba struct is a helper for manipulating RGBA8888 color data.
Definition: rgba.h:12
RotatedEllipseSVGExportMode rotatedEllipseExportMode
Definition: svgexporter.h:37
Definition: shape.h:17
std::size_t itemId
Definition: svgexporter.h:38
std::string exportSingleShapeSVG(const geometrize::rgba &color, const geometrize::Shape &shape, const std::uint32_t width, const std::uint32_t height, SVGExportOptions options)
exportSVG Exports a single shape as a complete SVG image.
Definition: svgexporter.cpp:245