summaryrefslogtreecommitdiffstats
path: root/svgbob/src/lib.rs
diff options
context:
space:
mode:
authorJovansonlee Cesar <ivanceras@gmail.com>2021-06-30 04:01:29 +0800
committerJovansonlee Cesar <ivanceras@gmail.com>2021-06-30 04:01:29 +0800
commitd5265ef87fff2293fdd842594499b565b3da2420 (patch)
treec508d708b13b87f3276e8c6f9697505f32327cfa /svgbob/src/lib.rs
parentd58b79164ac5404639821209151bca8c0c708af4 (diff)
Add a function to convert ascii to svg with an override size
Diffstat (limited to 'svgbob/src/lib.rs')
-rw-r--r--svgbob/src/lib.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/svgbob/src/lib.rs b/svgbob/src/lib.rs
index 3fe7c75..bd4fe48 100644
--- a/svgbob/src/lib.rs
+++ b/svgbob/src/lib.rs
@@ -32,3 +32,17 @@ pub fn to_svg_with_settings(ascii: &str, settings: &Settings) -> String {
node.render(&mut buffer).expect("must render");
buffer
}
+
+/// convert ascii art to svg using the size supplied
+pub fn to_svg_with_override_size(
+ ascii: &str,
+ settings: &Settings,
+ w: f32,
+ h: f32,
+) -> String {
+ let cb = CellBuffer::from(ascii);
+ let node: Node<()> = cb.get_node_override_size(settings, w, h);
+ let mut buffer = String::new();
+ node.render(&mut buffer).expect("must render");
+ buffer
+}