summaryrefslogtreecommitdiffstats
path: root/svgbob/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'svgbob/src/lib.rs')
-rw-r--r--svgbob/src/lib.rs90
1 files changed, 23 insertions, 67 deletions
diff --git a/svgbob/src/lib.rs b/svgbob/src/lib.rs
index df78813..4df3726 100644
--- a/svgbob/src/lib.rs
+++ b/svgbob/src/lib.rs
@@ -1,71 +1,27 @@
-//! generate an SVG from the ascii text using the default settings
-//!
-//! ```
-//! let input = r#"
-//! .-------------------------------------.
-//! | Hello here and there and everywhere |
-//! '-------------------------------------'
-//! "#;
-//! println!("svg: {}",svgbob::to_svg(input));
-//! ```
-//!
-//! <svg font-family="Electrolize,Titillium Web, Trebuchet MS, Arial" font-size="14" height="80" width="344" xmlns="http://www.w3.org/2000/svg">
-//! <defs>
-//! <marker id="triangle" markerHeight="10" markerUnits="strokeWidth" markerWidth="10" orient="auto" refX="0" refY="5" viewBox="0 0 14 14">
-//! <path d="M 0 0 L 10 5 L 0 10 z"/>
-//! </marker>
-//! </defs>
-//! <style>
-//! line, path {
-//! stroke: black;
-//! stroke-width: 1;
-//! }
-//! </style>
-//! <path d=" M 36 28 L 36 48 M 40 24 A 4 4 0 0 0 36 28 M 40 24 L 336 24 M 340 28 L 340 48 M 340 28 A 4 4 0 0 0 336 24 M 36 32 L 36 48 M 340 32 L 340 48 M 36 48 L 36 52 A 4 4 0 0 0 40 56 L 336 56 M 340 48 L 340 52 M 336 56 A 4 4 0 0 0 340 52" fill="none"/>
-//! <path d="" fill="none" stroke-dasharray="3 3"/>
-//! <text x="50" y="44">
-//! Hello here and there and everywhere
-//! </text>
-//! </svg>
-//!
-//!
-#![deny(warnings)]
-extern crate pom;
-extern crate svg;
-extern crate unicode_width;
+//#![deny(warnings)]
+#![deny(clippy::all)]
+#![feature(is_sorted)]
+#![feature(test)]
-pub use grid::Grid;
-pub use settings::Settings;
-use svg::node::element::SVG;
-
-mod block;
-mod box_drawing;
-mod element;
-mod enhance;
-mod enhance_circle;
-mod focus_char;
-mod fragments;
-mod grid;
-mod loc;
-mod loc_block;
-mod location;
-mod optimizer;
+pub mod buffer;
+mod map;
mod point;
-mod point_block;
-mod properties;
-mod settings;
-mod svg_element;
+pub mod util;
+
+pub use buffer::{
+ fragment, fragment::Fragment, Cell, CellBuffer, FragmentBuffer, Property, Settings, Signal,
+};
+pub use point::Point;
+
+/// convert svgbob ascii art to svg
+pub fn to_svg(ascii: &str) -> String {
+ let cb = CellBuffer::from(ascii);
+ cb.get_node().to_string()
+}
-/// generate an SVG from the ascii text input
-///
-/// Usage:
-///
-/// ```
-/// let input = "------->";
-/// println!("svg: {}", svgbob::to_svg(input));
-/// ```
-///
-/// commercial version enhances memes automatically
-pub fn to_svg(input: &str) -> SVG {
- Grid::from_str(&input, &Settings::default()).get_svg()
+/// convert ascii art into an svg
+pub fn to_svg_with_settings(ascii: &str, settings: &Settings) -> String {
+ let cb = CellBuffer::from(ascii);
+ let (node, _w, _h) = cb.get_node_with_size(settings);
+ node.to_string()
}