Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions stdlib/src/canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ use techscript_runtime::{
};

/// Convert a DslBlockValue to SVG string.
fn dsl_to_svg(val: &RuntimeValue, is_dragon: bool) -> String {
fn render_dsl_to_svg(svg: &mut String, val: &RuntimeValue, is_dragon: bool) {
match val {
RuntimeValue::DslBlock(dsl) => {
let mut svg = String::new();
if is_dragon {
match dsl.kind.as_str() {
"logo" => {
Expand Down Expand Up @@ -249,12 +248,17 @@ fn dsl_to_svg(val: &RuntimeValue, is_dragon: bool) -> String {
_ => {}
}
}
svg
}
_ => String::new(),
_ => {}
}
}

fn dsl_to_svg(val: &RuntimeValue, is_dragon: bool) -> String {
let mut svg = String::new();
render_dsl_to_svg(&mut svg, val, is_dragon);
svg
}

struct CanvasFn {
name: String,
min_arity: usize,
Expand Down Expand Up @@ -684,7 +688,7 @@ impl StdlibRegistry {
<rect width="100%" height="100%" fill="{}"/>
"##, bg_color);
for block in &blocks {
svg.push_str(&dsl_to_svg(block, is_dragon));
render_dsl_to_svg(&mut svg, block, is_dragon);
}
svg.push_str("</svg>");
Ok(RuntimeValue::Str(svg))
Expand Down
Loading