1use js_sys::Object;
2use wasm_bindgen::prelude::*;
3
4use crate::{create_object_with_properties, renderer::Renderer};
5
6#[wasm_bindgen]
7extern "C" {
8 #[wasm_bindgen(extends = Renderer)]
15 #[derive(Debug, Clone)]
16 pub type Svg;
17
18 #[wasm_bindgen(js_namespace = L, js_name = svg)]
19 pub fn svg_with_options(options: &SvgOptions) -> Svg;
20
21 #[wasm_bindgen(js_namespace = L, js_name = svg)]
22 pub fn svg() -> Svg;
23}
24
25create_object_with_properties!(
26 (SvgOptions, SvgOptions),
27 (padding, padding, f64),
29 (tolerance, tolerance, f64),
30 (stroke, stroke, bool),
32 (color, color, String),
33 (weight, weight, f64),
34 (opacity, opacity, f64),
35 (line_cap, lineCap, String),
36 (line_join, lineJoin, String),
37 (dash_array, dashArray, String),
38 (dash_offset, dashOffset, String),
39 (fill, fill, bool),
40 (fill_color, fillColor, String),
41 (fill_opacity, fillOpacity, f64),
42 (fill_rule, fillRule, String),
43 (interactive, interactive, bool),
44 (bubbling_mouse_events, bubblingMouseEvents, bool),
45 (class_name, className, String),
46 (pane, pane, String)
47);
48
49impl Default for SvgOptions {
50 fn default() -> Self {
51 SvgOptions::new()
52 }
53}
54
55impl Svg {
56 #[must_use]
58 pub fn new() -> Self {
59 svg()
60 }
61
62 #[must_use]
64 pub fn with_options(options: &SvgOptions) -> Self {
65 svg_with_options(options)
66 }
67}
68
69impl Default for Svg {
70 fn default() -> Self {
71 Self::new()
72 }
73}