1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! `svgwriter` is a typed library for writing correct SVG files. It includes SVG
//! specification and documentation from [mdn](https://developer.mozilla.org).
//!
//! ## Example
//!
//! ```rust
//! # use std::fmt::Write as _;
//! use svgwriter::{
//! tags::{Path, TagWithPresentationAttributes as _},
//! Data, Graphic
//! };
//!
//! let mut svg = Graphic::new();
//! let size = 100;
//! svg.set_width(size);
//! svg.set_height(size);
//! svg.set_view_box(format!("0 0 {size} {size}"));
//!
//! // draw a heart, inspired by https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#example
//! let d = 40;
//! let padding = size / 2 - d;
//! let mut heart = Data::new();
//! heart
//! .move_to(padding, padding + d / 2)
//! .arc_by(d / 2, d / 2, 0, false, true, d, 0)
//! .arc_by(d / 2, d / 2, 0, false, true, d, 0)
//! .quad_by(0, d * 3 / 4, -d, d * 3 / 2)
//! .quad_by(-d,-d * 3 / 4, -d, -d * 3 / 2);
//! svg.push(
//! Path::new()
//! .with_d(heart)
//! .with_fill("#A919FA")
//! .with_fill_opacity(0.5)
//! .with_stroke("#A919FA")
//! .with_stroke_width(3)
//! );
//!
//! // write the svg to a file
//! # let mut file = String::new();
//! write!(file, "{}", svg.to_string());
//! # assert_eq!(file, "<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='100' height='100' viewBox='0 0 100 100'><path d='M10,30a20,20,0,0,1,40,0a20,20,0,0,1,40,0q0,30,-40,60q-40,-30,-40,-60' fill='#A919FA' fill-opacity='0.5' stroke='#A919FA' stroke-width='3'/></svg>");
//! ```
//!
//! This code produces the following image:
//!
//! <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='100' height='100' viewBox='0 0 100 100'><path d='M10,30a20,20,0,0,1,40,0a20,20,0,0,1,40,0q0,30,-40,60q-40,-30,-40,-60' fill='#A919FA' fill-opacity='0.5' stroke='#A919FA' stroke-width='3'/></svg>
//!
//! 
// TODO use xmlwriter crate if it ever creates a new release
pub use Data;
pub use Graphic;
pub use Container;
pub use RawXml;
pub use Transform;
pub use Value;