use crate::{AnnIR, Dialect, IR, OpMap};
use std::path::Path;
mod composition;
mod hierarchy;
mod html;
mod layer_map;
mod layoutlang;
mod placement;
mod svg;
pub use hierarchy::*;
pub use layer_map::*;
pub use layoutlang::*;
#[cfg(test)]
mod test;
pub fn draw_ir<D: Dialect>(ir: &IR<D>, hierarchy_ann: OpMap<Hierarchy>, path: impl AsRef<Path>) {
let stylesheet = composition::StyleSheet::new();
let ann_ir = AnnIR::new(ir, hierarchy_ann, ir.filled_valmap(()));
let layout_ir = generate_layout_ir(&ann_ir);
let placed_ir = placement::place(&layout_ir);
let composed_ir = composition::compose(&placed_ir, &stylesheet);
let svg_output = svg::draw(&composed_ir, &stylesheet);
let svg_content = format!("{}", svg_output);
std::fs::write(path, svg_content).expect("Failed to write SVG file");
}
pub fn draw_ir_html<D: Dialect>(
ir: &IR<D>,
hierarchy_ann: OpMap<Hierarchy>,
path: impl AsRef<Path>,
) {
let stylesheet = composition::StyleSheet::new();
let ann_ir = AnnIR::new(ir, hierarchy_ann, ir.filled_valmap(()));
let layout_ir = generate_layout_ir(&ann_ir);
let placed_ir = placement::place(&layout_ir);
let composed_ir = composition::compose(&placed_ir, &stylesheet);
let svg_output = svg::draw(&composed_ir, &stylesheet);
let html_output = html::wrap_svg(svg_output);
let html_content = format!("{}", html_output);
std::fs::write(path, html_content).expect("Failed to write HTML file");
}