pub use crate::diagrams::util::esc;
pub fn svg_root(
svg_id: &str,
max_width: f64,
vb_x: f64,
vb_y: f64,
vb_w: f64,
vb_h: f64,
) -> String {
format!(
concat!(
r##"<svg id="{id}" width="100%" xmlns="http://www.w3.org/2000/svg" "##,
r##"xmlns:xlink="http://www.w3.org/1999/xlink" "##,
r##"viewBox="{vx} {vy} {vw} {vh}" "##,
r##"style="max-width: {mw}px;" "##,
r##"font-family="Arial, sans-serif" font-size="16px" "##,
r##"role="graphics-document document" "##,
r##"aria-roledescription="treeView">"##,
),
id = svg_id,
mw = max_width,
vx = vb_x,
vy = vb_y,
vw = vb_w,
vh = vb_h,
)
}
pub fn node_text(x: f64, y: f64, label: &str) -> String {
format!(
r##"<text dominant-baseline="middle" font-size="16px" fill="black" class="treeView-node-label" x="{x}" y="{y}">{label}</text>"##,
x = x,
y = y,
label = label,
)
}
pub fn h_line(x1: f64, y1: f64, x2: f64, y2: f64) -> String {
format!(
r##"<line x1="{x1}" y1="{y1}" x2="{x2}" y2="{y2}" stroke="black" stroke-width="1" class="treeView-node-line"></line>"##,
x1 = x1,
y1 = y1,
x2 = x2,
y2 = y2,
)
}
pub fn v_line(x1: f64, y1: f64, x2: f64, y2: f64) -> String {
format!(
r##"<line x1="{x1}" y1="{y1}" x2="{x2}" y2="{y2}" stroke="black" stroke-width="1" class="treeView-node-line"></line>"##,
x1 = x1,
y1 = y1,
x2 = x2,
y2 = y2,
)
}