From a5814a2a81c0ea7bcf6d56626ff7167af78d63a6 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 6 Oct 2025 14:04:52 +0200 Subject: Collapse anywhere passive recipes --- server/tools/src/diagram_svg.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'server/tools/src/diagram_svg.rs') diff --git a/server/tools/src/diagram_svg.rs b/server/tools/src/diagram_svg.rs index 0fc75668..fe3d9de4 100644 --- a/server/tools/src/diagram_svg.rs +++ b/server/tools/src/diagram_svg.rs @@ -19,7 +19,7 @@ use anyhow::Result; use hurrycurry_protocol::{ Gamedata, Message, - book::{Diagram, DiagramNode, NodeStyle}, + book::{Diagram, DiagramEdge, DiagramNode, EdgeStyle, NodeStyle}, glam::Vec2, }; use std::fmt::Write; @@ -80,16 +80,18 @@ pub fn diagram_svg(data: &Gamedata, diagram: &Diagram) -> Result { let tip2 = dst + (dir + dir.perp() * -0.5) * 10.; dst += dir * 5.; // prevent miter line cap from peeking out + let color = edge_color(edge); + // line path writeln!( out, - r#""#, + r#""#, src.x, src.y, dst.x, dst.y, )?; // tip path writeln!( out, - r#""#, + r#""#, tip0.x, tip0.y, tip1.x, tip1.y, tip2.x, tip2.y )?; } @@ -110,7 +112,7 @@ fn node_edge_connect_pos(src: &DiagramNode, dst: &DiagramNode) -> Vec2 { } } -fn node_color(node: &DiagramNode) -> &'static str { +pub(crate) fn node_color(node: &DiagramNode) -> &'static str { match node.style { NodeStyle::FinalProduct => "#555", NodeStyle::IntermediateProduct => "#333", @@ -119,6 +121,12 @@ fn node_color(node: &DiagramNode) -> &'static str { NodeStyle::ProcessInstant => "#5452d8", } } +pub(crate) fn edge_color(edge: &DiagramEdge) -> &'static str { + match edge.style { + EdgeStyle::Regular => "#000000", + EdgeStyle::ProcessPassive => "#c4a32b", + } +} fn image_node(out: &mut String, node: &DiagramNode, path: String) -> Result<()> { if matches!( -- cgit v1.2.3-70-g09d2