summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-10-02 11:46:13 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-10-02 11:46:13 +0800
commit3d458397228889cccc1e111e56e529ab9d866970 (patch)
tree53af1a4ba425eeb0bf477c1064f2af19dd6ba6d2 /src
parent904f5daeae63dbecc713b0f41928d119a20fab9a (diff)
internal(image): put create() as associated function
Diffstat (limited to 'src')
-rw-r--r--src/image.rs22
-rw-r--r--src/main.rs4
2 files changed, 13 insertions, 13 deletions
diff --git a/src/image.rs b/src/image.rs
index c8f5d49..f5ad5e6 100644
--- a/src/image.rs
+++ b/src/image.rs
@@ -14,7 +14,7 @@ use crate::ast::DepthExpr;
offset based mutation model, to avoid overflowing on previous image
*/
-struct FlowChart {
+pub struct FlowChart {
img: DynamicImage,
offset: Offset,
font: FontArc,
@@ -47,7 +47,7 @@ impl FlowChart {
const RESOLUTION_MULTIPLIER: u32 = 5;
- fn new() -> Self {
+ pub fn new() -> Self {
Self {
img: DynamicImage::new(0, 0, ColorType::Rgba8),
offset: Offset {
@@ -59,6 +59,15 @@ impl FlowChart {
}
}
+ pub fn create(ast: &[DepthExpr], path: &Path) {
+ let mut chart = FlowChart::new();
+ chart.build(ast);
+ chart
+ .img
+ .save(path)
+ .unwrap();
+ }
+
fn get_system_font() -> FontArc {
let mut db = Database::new();
db.load_system_fonts();
@@ -384,12 +393,3 @@ mod colors {
255, 255, 255, 255,
]);
}
-
-pub fn create(ast: &[DepthExpr], path: &Path) {
- let mut chart = FlowChart::new();
- chart.build(ast);
- chart
- .img
- .save(path)
- .unwrap();
-}
diff --git a/src/main.rs b/src/main.rs
index 0fa96b0..f926b00 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,7 +1,7 @@
use std::path::Path;
use java2flowchart::ast::parse;
-use java2flowchart::image::create;
+use java2flowchart::image::FlowChart;
use java2flowchart::parser;
fn main() {
@@ -11,5 +11,5 @@ fn main() {
println!("{:#?}", ast);
- create(&ast, Path::new("output.png"));
+ FlowChart::create(&ast, Path::new("output.png"));
}