Skip to content
Closed
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
61 changes: 33 additions & 28 deletions stdlib/src/canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,34 +110,39 @@ fn render_dsl_to_svg(svg: &mut String, val: &RuntimeValue, is_dragon: bool) {
);
}
"rings" => {
let count = dsl
.properties
.iter()
.find(|p| p.name == "count")
.and_then(|p| p.value.as_ref())
.and_then(|v| v.try_into_int().ok())
.unwrap_or(3);
let color = dsl
.properties
.iter()
.find(|p| p.name == "color")
.and_then(|p| p.value.as_ref())
.map(|v| v.to_string())
.unwrap_or_else(|| "#00d4ff".to_string());
let size = dsl
.properties
.iter()
.find(|p| p.name == "size")
.and_then(|p| p.value.as_ref())
.and_then(|v| v.try_into_int().ok())
.unwrap_or(40);
let thickness = dsl
.properties
.iter()
.find(|p| p.name == "thickness")
.and_then(|p| p.value.as_ref())
.and_then(|v| v.try_into_int().ok())
.unwrap_or(3);
let mut count = 3;
let mut color = None;
let mut size = 40;
let mut thickness = 3;

for p in &dsl.properties {
if let Some(v) = &p.value {
match p.name.as_str() {
"count" => {
if let Ok(c) = v.try_into_int() {
count = c;
}
}
"color" => {
color = Some(v.to_string());
}
"size" => {
if let Ok(s) = v.try_into_int() {
size = s;
}
}
"thickness" => {
if let Ok(t) = v.try_into_int() {
thickness = t;
}
}
_ => {}
}
}
}

let color = color.unwrap_or_else(|| "#00d4ff".to_string());

for i in 0..count {
let r = 80 + i as i64 * (size / 2);
let opacity = 0.4 - (i as f32 * 0.08);
Expand Down
Loading