diff options
| author | Rubén Beltrán del Río <jj@r.bdr.sh> | 2026-01-16 11:37:51 +0100 |
|---|---|---|
| committer | Rubén Beltrán del Río <jj@r.bdr.sh> | 2026-01-16 11:49:15 +0100 |
| commit | 09c1181cb4df744f0ea34eb0f1fd325850f6b128 (patch) | |
| tree | dc161e628a087754be29e5c514fc8290d49273e0 /src | |
| parent | f53588e276fba9db2f3bee6a3421f60d7c458813 (diff) | |
Diffstat (limited to 'src')
| -rw-r--r-- | src/renderer.rs | 13 | ||||
| -rw-r--r-- | src/stage_type.rs | 27 |
2 files changed, 30 insertions, 10 deletions
diff --git a/src/renderer.rs b/src/renderer.rs index 69c3f70..d91c3f0 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -38,7 +38,7 @@ use crate::utils::percent_to_pixel; /// Returns `RenderError` if the surface creation, rendering, or PNG encoding fails pub fn render_to_png( map: &Map, - stage_type: StageType, + stage_type: &StageType, configuration: &Configuration, ) -> Result<Vec<u8>, RenderError> { // Safe cast: map dimensions are typically in the range of hundreds to thousands of pixels @@ -80,7 +80,7 @@ pub fn render_to_png( /// Returns `RenderError` if the surface creation or rendering fails pub fn render_to_surface( map: &Map, - stage_type: StageType, + stage_type: &StageType, configuration: &Configuration, ) -> Result<ImageSurface, RenderError> { // Safe cast: map dimensions are typically in the range of hundreds to thousands of pixels @@ -120,7 +120,7 @@ pub fn render_to_surface( /// Returns `RenderError` if the surface creation, rendering, or file I/O fails pub fn render_to_svg( map: &Map, - stage_type: StageType, + stage_type: &StageType, configuration: &Configuration, ) -> Result<String, RenderError> { let total_width = configuration.theme.sizes.map_width + configuration.theme.sizes.padding * 2.0; @@ -150,7 +150,7 @@ pub fn render_to_svg( fn render( context: &Context, map: &Map, - stage_type: StageType, + stage_type: &StageType, configuration: &Configuration, ) -> Result<(), RenderError> { // Apply padding transform @@ -177,7 +177,7 @@ fn render( draw_background(context, configuration)?; if configuration.options.show_background { - draw_stage_patterns(context, stage_type, map, configuration)?; + draw_stage_patterns(context, map, configuration)?; } draw_axes(context, stage_type, map, configuration)?; @@ -205,7 +205,6 @@ fn draw_background(context: &Context, configuration: &Configuration) -> Result<( fn draw_stage_patterns( context: &Context, - _stage_type: StageType, map: &Map, configuration: &Configuration, ) -> Result<(), RenderError> { @@ -276,7 +275,7 @@ fn draw_stage_patterns( fn draw_axes( context: &Context, - stage_type: StageType, + stage_type: &StageType, map: &Map, configuration: &Configuration, ) -> Result<(), RenderError> { diff --git a/src/stage_type.rs b/src/stage_type.rs index ae80166..46486e1 100644 --- a/src/stage_type.rs +++ b/src/stage_type.rs @@ -1,5 +1,5 @@ /// Stage type used to analyze different aspects of a Wardley map -#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] +#[derive(Debug, Clone, PartialEq, Eq, Default)] pub enum StageType { #[default] Activities, @@ -24,12 +24,19 @@ pub enum StageType { Understanding, UserPerception, EvolutionStage, + Custom { + name: String, + i: String, + ii: String, + iii: String, + iv: String, + }, } impl StageType { /// Returns the name of this stage type #[must_use] - pub fn name(&self) -> &'static str { + pub fn name(&self) -> &str { match self { Self::Activities => "Activities", Self::Behavior => "Behavior", @@ -53,6 +60,13 @@ impl StageType { Self::Understanding => "Understanding", Self::UserPerception => "User Perception", Self::EvolutionStage => "Evolution Stage", + Self::Custom { + name, + i: _, + ii: _, + iii: _, + iv: _, + } => name, } } @@ -61,7 +75,7 @@ impl StageType { // Splitting it would reduce clarity and require additional complexity #[allow(clippy::too_many_lines)] #[must_use] - pub fn stages(&self) -> [&'static str; 4] { + pub fn stages(&self) -> [&str; 4] { match self { Self::Activities => [ "Genesis", @@ -170,6 +184,13 @@ impl StageType { "Standard / expected / feeling of shock if not used", ], Self::EvolutionStage => ["Stage I", "Stage II", "Stage III", "Stage IV"], + Self::Custom { + name: _, + i, + ii, + iii, + iv, + } => [i, ii, iii, iv], } } } |