Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / geometry / doc / src / examples / algorithms / create_svg_one.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2011-2014 Barend Gehrels, Amsterdam, the Netherlands.
4
5 // This file was modified by Oracle on 2014.
6 // Modifications copyright (c) 2014, Oracle and/or its affiliates.
7
8 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
9
10 // Use, modification and distribution is subject to the Boost Software License,
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
13
14 // Code to create SVG for examples
15
16 #ifndef CREATE_SVG_ONE_HPP
17 #define CREATE_SVG_ONE_HPP
18
19 #include <fstream>
20 #include <boost/algorithm/string.hpp>
21
22 #if defined(HAVE_SVG)
23 #  include <boost/geometry/io/svg/svg_mapper.hpp>
24 #endif
25
26 template <typename Geometry>
27 void create_svg(std::string const& filename, Geometry const& g)
28 {
29 #if defined(HAVE_SVG)
30     std::cout  << std::endl << "[$img/algorithms/" << boost::replace_all_copy(filename, ".svg", ".png") << "]" << std::endl << std::endl;
31
32     typedef typename boost::geometry::point_type<Geometry>::type point_type;
33     std::ofstream svg(filename.c_str());
34
35     boost::geometry::svg_mapper<point_type> mapper(svg, 400, 400);
36     mapper.add(g);
37
38     mapper.map(g, "fill-opacity:0.3;fill:rgb(51,51,153);stroke:rgb(51,51,153);stroke-width:2");
39 #else
40     boost::ignore_unused(filename, g);
41 #endif
42 }
43
44 // NOTE: convert manually from svg to png using Inkscape ctrl-shift-E
45 // and copy png to html/img/algorithms/
46
47
48 #endif // CREATE_SVG_ONE_HPP
49