← back to joemooney__JMT

Function bodies 571 total

All specs Real LLM only Function bodies
is_active function · rust · L23-L25 (3 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn is_active(&self) -> bool {
        self.start.is_some() && self.current.is_some()
    }
to_egui_rect function · rust · L28-L34 (7 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn to_egui_rect(&self) -> Option<egui::Rect> {
        if let (Some(start), Some(current)) = (self.start, self.current) {
            Some(egui::Rect::from_two_pos(start, current))
        } else {
            None
        }
    }
to_core_rect function · rust · L37-L47 (11 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn to_core_rect(&self) -> Option<Rect> {
        if let (Some(start), Some(current)) = (self.start, self.current) {
            let min_x = start.x.min(current.x);
            let min_y = start.y.min(current.y);
            let max_x = start.x.max(current.x);
            let max_y = start.y.max(current.y);
            Some(Rect::new(min_x, min_y, max_x, max_y))
        } else {
            None
        }
    }
clear function · rust · L50-L53 (4 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn clear(&mut self) {
        self.start = None;
        self.current = None;
    }
is_active function · rust · L67-L69 (3 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn is_active(&self) -> bool {
        self.node_id.is_some() && self.corner != Corner::None
    }
start function · rust · L72-L75 (4 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn start(&mut self, node_id: NodeId, corner: Corner) {
        self.node_id = Some(node_id);
        self.corner = corner;
    }
clear function · rust · L78-L81 (4 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn clear(&mut self) {
        self.node_id = None;
        self.corner = Corner::None;
    }
Citation: Repobility (2026). State of AI-Generated Code. https://repobility.com/research/
new function · rust · L140-L150 (11 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn new() -> Self {
        Self {
            visible: false,
            center: None,
            candidates: Vec::new(),
            source_radius: 30.0,  // Area to magnify
            display_radius: 120.0, // Size of loupe on screen
            magnification: 4.0,
            just_opened: false,
        }
    }
show function · rust · L151-L157 (7 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn show(&mut self, center: Point, candidates: Vec<ClickCandidate>) {
        self.visible = true;
        self.center = Some(center);
        self.candidates = candidates;
        self.just_opened = true; // Skip click-outside detection this frame
    }
hide function · rust · L158-L164 (7 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn hide(&mut self) {
        self.visible = false;
        self.center = None;
        self.candidates.clear();
        self.just_opened = false;
    }
begin_frame function · rust · L167-L169 (3 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn begin_frame(&mut self) {
        self.just_opened = false;
    }
default function · rust · L215-L241 (27 LOC)
jmt-rust/jmt-client/src/app.rs
    fn default() -> Self {
        Self {
            // Selection
            selection_sensitivity: 12.0,
            pivot_hit_tolerance: 12.0,
            connection_hit_tolerance: 12.0,
            corner_hit_margin: 15.0,
            click_cycle_distance: 15.0,

            // Loupe
            loupe_display_radius: 120.0,

            // Double-click
            double_click_time_ms: 500,
            double_click_distance: 10.0,

            // Visual
            show_debug_info: false,
            highlight_on_hover: true,
            show_selection_radius: false,

            // Grid
            snap_to_grid: false,
            grid_size: 10.0,
            show_grid: false,
        }
    }
new function · rust · L258-L267 (10 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn new(diagram: Diagram) -> Self {
        Self {
            canvas: DiagramCanvas::new(),
            diagram,
            modified: false,
            file_path: None,
            is_embedded_sub: false,
            parent_state_id: None,
        }
    }
with_path function · rust · L270-L281 (12 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn with_path(mut diagram: Diagram, path: std::path::PathBuf) -> Self {
        // Ensure the diagram settings also have the path
        diagram.settings.file_path = Some(path.to_string_lossy().to_string());
        Self {
            canvas: DiagramCanvas::new(),
            diagram,
            modified: false,
            file_path: Some(path),
            is_embedded_sub: false,
            parent_state_id: None,
        }
    }
default function · rust · L357-L392 (36 LOC)
jmt-rust/jmt-client/src/app.rs
    fn default() -> Self {
        // Create a default diagram to start with
        let diagram = Diagram::new("Untitled");
        let diagram_state = DiagramState::new(diagram);

        Self {
            diagrams: vec![diagram_state],
            active_diagram: 0,
            edit_mode: EditMode::Arrow,
            status_message: String::from("Ready"),
            pending_connection_source: None,
            selection_rect: SelectionRect::default(),
            dragging_nodes: false,
            dragging_label: None,
            dragging_separator: None,
            dragging_pivot: None,
            dragging_endpoint: None,
            selected_pivot: None,
            cursor_pos: None,
            diagram_cursor_pos: None,
            hover_info: None,
            resize_state: ResizeState::default(),
            lasso_points: Vec::new(),
            last_click_time: None,
            last_click_pos: None,
            zoom_level: 1.0,
            preview_substatemachine: None,
If a scraper extracted this row, it came from Repobility (https://repobility.com)
new function · rust · L397-L399 (3 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn new(_cc: &eframe::CreationContext<'_>) -> Self {
        Self::default()
    }
current_diagram function · rust · L402-L404 (3 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn current_diagram(&self) -> Option<&DiagramState> {
        self.diagrams.get(self.active_diagram)
    }
current_diagram_mut function · rust · L407-L409 (3 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn current_diagram_mut(&mut self) -> Option<&mut DiagramState> {
        self.diagrams.get_mut(self.active_diagram)
    }
current_diagram_idx function · rust · L412-L418 (7 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn current_diagram_idx(&self) -> Option<usize> {
        if self.diagrams.is_empty() {
            None
        } else {
            Some(self.active_diagram)
        }
    }
check_pivot_or_endpoint_at function · rust · L423-L476 (54 LOC)
jmt-rust/jmt-client/src/app.rs
    fn check_pivot_or_endpoint_at(&self, pos: Point) -> Option<(uuid::Uuid, PivotDragType)> {
        let state = self.current_diagram()?;

        let pivot_tolerance = self.settings.pivot_hit_tolerance;

        // First, check the selected connection for pivot points and endpoints
        if let Some(conn_id) = state.diagram.selected_connection() {
            if let Some(conn) = state.diagram.find_connection(conn_id) {
                // First check pivot points (gold circles) - only for selected connection
                if let Some(pivot_idx) = conn.find_pivot_at(pos, pivot_tolerance) {
                    return Some((conn_id, PivotDragType::Pivot(pivot_idx)));
                }

                // Check endpoints
                if let (Some(source_node), Some(target_node)) = (
                    state.diagram.find_node(conn.source_id),
                    state.diagram.find_node(conn.target_id),
                ) {
                    let source_bounds = source_node.bounds()
find_all_candidates_at function · rust · L480-L601 (122 LOC)
jmt-rust/jmt-client/src/app.rs
    fn find_all_candidates_at(&self, pos: Point) -> Vec<ClickCandidate> {
        let mut candidates = Vec::new();
        let Some(state) = self.current_diagram() else {
            return candidates;
        };

        let pivot_tolerance = self.settings.pivot_hit_tolerance;
        let connection_tolerance = self.settings.connection_hit_tolerance;

        eprintln!("[CANDIDATES] Checking at ({:.1}, {:.1})", pos.x, pos.y);

        // 1. Check pivot points on selected connection
        if let Some(conn_id) = state.diagram.selected_connection() {
            if let Some(conn) = state.diagram.find_connection(conn_id) {
                for (idx, pivot) in conn.pivot_points.iter().enumerate() {
                    let dx = pos.x - pivot.x;
                    let dy = pos.y - pivot.y;
                    let dist = (dx * dx + dy * dy).sqrt();
                    if dist <= pivot_tolerance {
                        eprintln!("[CANDIDATES] Pivot {} hit (dist: {:.1})", idx, dist);
      
select_candidate function · rust · L605-L733 (129 LOC)
jmt-rust/jmt-client/src/app.rs
    fn select_candidate(&mut self, candidate: ClickCandidate) -> bool {
        match candidate {
            ClickCandidate::Pivot(conn_id, idx) => {
                if let Some(state) = self.current_diagram_mut() {
                    if state.diagram.selected_connection() != Some(conn_id) {
                        state.diagram.select_connection(conn_id);
                    }
                    state.diagram.push_undo();
                }
                self.dragging_pivot = Some((conn_id, idx));
                self.selected_pivot = Some((conn_id, idx));
                self.dragging_nodes = false;
                self.dragging_label = None;
                self.dragging_endpoint = None;
                self.selection_rect.clear();
                self.status_message = format!("Pivot point {} (Delete to remove)", idx + 1);
                true
            }
            ClickCandidate::Endpoint(conn_id, is_source) => {
                if let Some(state) = self.current_diagram_mut
handle_click_with_disambiguation function · rust · L737-L818 (82 LOC)
jmt-rust/jmt-client/src/app.rs
    fn handle_click_with_disambiguation(&mut self, pos: Point) -> bool {
        eprintln!("[CLICK] Position: ({:.1}, {:.1}), mode: {:?}", pos.x, pos.y, self.selection_mode);

        // If loupe is visible and we clicked outside it, hide it
        if self.loupe.visible {
            // Loupe click handling is done separately
            return false;
        }

        // Find all candidates at this position
        let candidates = self.find_all_candidates_at(pos);
        eprintln!("[CLICK] Found {} candidates at position:", candidates.len());
        for (i, c) in candidates.iter().enumerate() {
            eprintln!("[CLICK]   {}: {:?}", i + 1, c);
        }

        if candidates.is_empty() {
            eprintln!("[CLICK] No candidates found - clearing state");
            self.click_cycle_candidates.clear();
            self.click_cycle_index = 0;
            self.click_cycle_pos = None;
            self.loupe.hide();
            return false;
        }

        // If only one
Same scanner, your repo: https://repobility.com — Repobility
handle_click_with_cycling function · rust · L821-L823 (3 LOC)
jmt-rust/jmt-client/src/app.rs
    fn handle_click_with_cycling(&mut self, pos: Point) -> bool {
        self.handle_click_with_disambiguation(pos)
    }
find_nearest_side_and_offset function · rust · L826-L857 (32 LOC)
jmt-rust/jmt-client/src/app.rs
    fn find_nearest_side_and_offset(bounds: &Rect, pos: Point) -> (jmt_core::node::Side, f32) {
        use jmt_core::node::Side;

        let center_x = (bounds.x1 + bounds.x2) / 2.0;
        let center_y = (bounds.y1 + bounds.y2) / 2.0;

        // Distance to each side
        let dist_top = (pos.y - bounds.y1).abs();
        let dist_bottom = (pos.y - bounds.y2).abs();
        let dist_left = (pos.x - bounds.x1).abs();
        let dist_right = (pos.x - bounds.x2).abs();

        let min_dist = dist_top.min(dist_bottom).min(dist_left).min(dist_right);

        // Calculate max offset (ensure it's never negative)
        let max_h_offset = (bounds.width() / 2.0 - 10.0).max(0.0);
        let max_v_offset = (bounds.height() / 2.0 - 10.0).max(0.0);

        if min_dist == dist_top {
            let offset = (pos.x - center_x).clamp(-max_h_offset, max_h_offset);
            (Side::Top, offset)
        } else if min_dist == dist_bottom {
            let offset = (pos.x - center_x).clamp(-
new_diagram function · rust · L860-L862 (3 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn new_diagram(&mut self) {
        self.new_diagram_of_type(DiagramType::StateMachine);
    }
new_diagram_of_type function · rust · L865-L874 (10 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn new_diagram_of_type(&mut self, diagram_type: DiagramType) {
        let type_name = diagram_type.display_name();
        let name = format!("{} {}", type_name, self.diagrams.len() + 1);
        let mut diagram = Diagram::new(&name);
        diagram.diagram_type = diagram_type;
        self.diagrams.push(DiagramState::new(diagram));
        self.active_diagram = self.diagrams.len() - 1;
        self.edit_mode = EditMode::Arrow;
        self.status_message = format!("Created new {}", type_name);
    }
close_diagram function · rust · L877-L884 (8 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn close_diagram(&mut self) {
        if self.diagrams.len() > 1 {
            self.diagrams.remove(self.active_diagram);
            if self.active_diagram >= self.diagrams.len() {
                self.active_diagram = self.diagrams.len() - 1;
            }
        }
    }
open_substatemachine function · rust · L887-L922 (36 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn open_substatemachine(&mut self, state_id: NodeId) {
        // Get the sub-statemachine info from the state
        let substatemachine_info = {
            let Some(diagram_state) = self.current_diagram() else { return; };
            let Some(node) = diagram_state.diagram.find_node(state_id) else { return; };
            let Some(state) = node.as_state() else { return; };

            match &state.substatemachine_path {
                Some(path) if !path.is_empty() => {
                    // External file
                    Some((path.clone(), state.name.clone(), state.title.clone()))
                }
                Some(_) => {
                    // Embedded - create view from regions
                    Some((String::new(), state.name.clone(), state.title.clone()))
                }
                None => None,
            }
        };

        if let Some((path, state_name, title)) = substatemachine_info {
            if path.is_empty() {
                // Embed
create_substatemachine function · rust · L925-L936 (12 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn create_substatemachine(&mut self, state_id: NodeId) {
        // Mark the state as having an embedded sub-statemachine
        if let Some(diagram_state) = self.current_diagram_mut() {
            if let Some(node) = diagram_state.diagram.find_node_mut(state_id) {
                if let Some(state) = node.as_state_mut() {
                    state.substatemachine_path = Some(String::new()); // Embedded by default
                    diagram_state.modified = true;
                    self.status_message = format!("Created sub-statemachine for '{}'", state.name);
                }
            }
        }
    }
open_embedded_substatemachine function · rust · L939-L986 (48 LOC)
jmt-rust/jmt-client/src/app.rs
    fn open_embedded_substatemachine(
        &mut self,
        state_id: NodeId,
        state_name: &str,
        title: &str,
        parent_file_path: Option<std::path::PathBuf>,
        parent_file_name: Option<String>,
    ) {
        // Extract child nodes and connections from the parent state
        let (nodes, connections) = if let Some(diagram_state) = self.current_diagram() {
            diagram_state.diagram.extract_substatemachine_contents(state_id)
        } else {
            (Vec::new(), Vec::new())
        };

        // Create a new diagram with the extracted contents
        let display_name = if title.is_empty() { state_name } else { title };
        // Use parent file name in tab title to indicate which file contains this sub-statemachine
        let parent_indicator = parent_file_name.as_deref().unwrap_or("sub");
        let name = format!("{} ({})", display_name, parent_indicator);
        let mut diagram = Diagram::new(&name);
        diagram.title = display_n
Repobility's GitHub App fixes findings like these · https://github.com/apps/repobility-bot
open_file_at_path function · rust · L990-L1031 (42 LOC)
jmt-rust/jmt-client/src/app.rs
    fn open_file_at_path(&mut self, path: &str) {
        use std::path::PathBuf;

        // Resolve relative path based on current diagram's location
        let resolved_path = if let Some(current_state) = self.current_diagram() {
            if let Some(current_path) = &current_state.file_path {
                if let Some(parent) = current_path.parent() {
                    parent.join(path)
                } else {
                    PathBuf::from(path)
                }
            } else {
                PathBuf::from(path)
            }
        } else {
            PathBuf::from(path)
        };

        match std::fs::read_to_string(&resolved_path) {
            Ok(content) => {
                match serde_json::from_str::<Diagram>(&content) {
                    Ok(mut diagram) => {
                        diagram.assign_missing_seq_ids();
                        diagram.recalculate_connections();
                        let state = DiagramState::with_path(diagram, resolv
open_file_at_path function · rust · L1034-L1036 (3 LOC)
jmt-rust/jmt-client/src/app.rs
    fn open_file_at_path(&mut self, path: &str) {
        self.status_message = format!("Cannot open external files in web mode: {}", path);
    }
check_substatemachine_icon_at function · rust · L1039-L1065 (27 LOC)
jmt-rust/jmt-client/src/app.rs
    fn check_substatemachine_icon_at(&self, point: Point) -> Option<NodeId> {
        let state = self.current_diagram()?;
        let zoom = self.zoom_level;

        for node in state.diagram.nodes() {
            if let Some(state_node) = node.as_state() {
                if state_node.has_substatemachine() && !state_node.show_expanded {
                    // Check if click is in icon area (bottom-right corner)
                    let bounds = node.bounds();
                    let icon_size = 16.0 / zoom; // Unscale for diagram coords
                    let margin = 4.0 / zoom;

                    let icon_left = bounds.x2 - icon_size - margin;
                    let icon_top = bounds.y2 - icon_size - margin;
                    let icon_right = bounds.x2 - margin;
                    let icon_bottom = bounds.y2 - margin;

                    if point.x >= icon_left && point.x <= icon_right
                        && point.y >= icon_top && point.y <= icon_bottom
               
render_substatemachine_preview function · rust · L1068-L1115 (48 LOC)
jmt-rust/jmt-client/src/app.rs
    fn render_substatemachine_preview(&mut self, ctx: &egui::Context) {
        if let Some(state_id) = self.preview_substatemachine {
            let (state_name, title) = {
                let Some(diagram_state) = self.current_diagram() else {
                    self.preview_substatemachine = None;
                    return;
                };
                let Some(node) = diagram_state.diagram.find_node(state_id) else {
                    self.preview_substatemachine = None;
                    return;
                };
                let Some(state) = node.as_state() else {
                    self.preview_substatemachine = None;
                    return;
                };
                (state.name.clone(), state.title.clone())
            };

            let display_name = if title.is_empty() { &state_name } else { &title };

            let mut open = true;
            egui::Window::new(format!("Sub-Statemachine: {}", display_name))
                .collapsible(true
save function · rust · L1119-L1129 (11 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn save(&mut self) {
        if let Some(state) = self.current_diagram() {
            if state.file_path.is_some() {
                // Has a path, save directly
                self.save_to_current_path();
            } else {
                // No path yet, do Save As
                self.save_as();
            }
        }
    }
save_to_current_path function · rust · L1133-L1161 (29 LOC)
jmt-rust/jmt-client/src/app.rs
    fn save_to_current_path(&mut self) {
        if let Some(state) = self.current_diagram() {
            if let Some(path) = &state.file_path {
                let json = serde_json::to_string_pretty(&state.diagram);
                match json {
                    Ok(content) => {
                        match std::fs::write(path, &content) {
                            Ok(_) => {
                                let filename = path.file_name()
                                    .map(|s| s.to_string_lossy().to_string())
                                    .unwrap_or_else(|| "file".to_string());
                                self.status_message = format!("Saved: {}", filename);
                                // Mark as not modified after successful save
                                if let Some(state) = self.current_diagram_mut() {
                                    state.modified = false;
                                }
                            }
                         
save_as function · rust · L1165-L1193 (29 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn save_as(&mut self) {
        use rfd::FileDialog;

        if self.current_diagram().is_none() {
            return;
        }

        // Get diagram name for default filename
        let default_name = self.current_diagram()
            .map(|s| s.diagram.settings.name.clone())
            .unwrap_or_else(|| "diagram".to_string());

        let dialog = FileDialog::new()
            .set_title("Save Diagram As")
            .add_filter("JMT Diagram", &["jmt"])
            .add_filter("JSON", &["json"])
            .set_file_name(&format!("{}.jmt", default_name));

        if let Some(path) = dialog.save_file() {
            // Update the file path in both places
            if let Some(state) = self.current_diagram_mut() {
                state.file_path = Some(path.clone());
                // Also update the diagram settings so it gets serialized
                state.diagram.settings.file_path = Some(path.to_string_lossy().to_string());
            }
            // Now 
open function · rust · L1197-L1233 (37 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn open(&mut self) {
        use rfd::FileDialog;

        let dialog = FileDialog::new()
            .set_title("Open Diagram")
            .add_filter("JMT Diagram", &["jmt"])
            .add_filter("JSON", &["json"])
            .add_filter("All Files", &["*"]);

        if let Some(path) = dialog.pick_file() {
            match std::fs::read_to_string(&path) {
                Ok(content) => {
                    match serde_json::from_str::<Diagram>(&content) {
                        Ok(mut diagram) => {
                            // Assign seq_ids to any elements that don't have them
                            diagram.assign_missing_seq_ids();
                            // Recalculate connection routing (segments are not serialized)
                            diagram.recalculate_connections();
                            let state = DiagramState::with_path(diagram, path.clone());
                            self.diagrams.push(state);
                            self.
Citation: Repobility (2026). State of AI-Generated Code. https://repobility.com/research/
crop_diagram function · rust · L1237-L1266 (30 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn crop_diagram(&mut self) -> bool {
        let Some(state) = self.current_diagram_mut() else {
            return false;
        };

        // Check if there's content to crop
        if state.diagram.tight_content_bounds().is_none() {
            self.status_message = "No content to crop".to_string();
            return false;
        }

        state.diagram.push_undo();
        let margin = 20.0;
        let snap_to_grid = true;
        let grid_size = 10.0;

        if let Some((dx, dy)) = state.diagram.crop(margin, snap_to_grid, grid_size) {
            if dx.abs() > 0.01 || dy.abs() > 0.01 {
                state.modified = true;
                self.status_message = format!("Diagram cropped (moved by {:.0}, {:.0})", dx, dy);
                true
            } else {
                self.status_message = "Diagram already cropped".to_string();
                false
            }
        } else {
            self.status_message = "No content to crop".to_string();
       
export_png function · rust · L1270-L1333 (64 LOC)
jmt-rust/jmt-client/src/app.rs
    pub fn export_png(&mut self, autocrop: bool) {
        use rfd::FileDialog;
        use image::{ImageBuffer, Rgba};

        let state = match self.current_diagram() {
            Some(s) => s,
            None => return,
        };

        // Get diagram name for default filename
        let default_name = state.diagram.settings.name.clone();

        let dialog = FileDialog::new()
            .set_title("Export as PNG")
            .add_filter("PNG Image", &["png"])
            .set_file_name(&format!("{}.png", default_name));

        if let Some(path) = dialog.save_file() {
            // Calculate diagram bounds
            let (min_x, min_y, max_x, max_y) = self.calculate_diagram_bounds();

            if max_x <= min_x || max_y <= min_y {
                self.status_message = "No elements to export".to_string();
                return;
            }

            // Add margin
            let margin = if autocrop { 20.0 } else { 50.0 };
            let (x_offset, y_offset, w
calculate_diagram_bounds function · rust · L1337-L1368 (32 LOC)
jmt-rust/jmt-client/src/app.rs
    fn calculate_diagram_bounds(&self) -> (f32, f32, f32, f32) {
        let state = match self.current_diagram() {
            Some(s) => s,
            None => return (0.0, 0.0, 0.0, 0.0),
        };

        let mut min_x = f32::MAX;
        let mut min_y = f32::MAX;
        let mut max_x = f32::MIN;
        let mut max_y = f32::MIN;

        // State machine nodes
        for node in state.diagram.nodes() {
            let bounds = node.bounds();
            min_x = min_x.min(bounds.x1);
            min_y = min_y.min(bounds.y1);
            max_x = max_x.max(bounds.x2);
            max_y = max_y.max(bounds.y2);
        }

        // Connection endpoints
        for conn in state.diagram.connections() {
            for seg in &conn.segments {
                min_x = min_x.min(seg.start.x).min(seg.end.x);
                min_y = min_y.min(seg.start.y).min(seg.end.y);
                max_x = max_x.max(seg.start.x).max(seg.end.x);
                max_y = max_y.max(seg.start.y).max(seg.
render_diagram_to_image function · rust · L1372-L1485 (114 LOC)
jmt-rust/jmt-client/src/app.rs
    fn render_diagram_to_image(
        img: &mut image::ImageBuffer<image::Rgba<u8>, Vec<u8>>,
        diagram: &Diagram,
        x_offset: f32,
        y_offset: f32,
    ) {
        use image::Rgba;

        let state_fill = Rgba([255, 255, 204, 255]); // Light yellow
        let state_stroke = Rgba([0, 0, 0, 255]); // Black
        let pseudo_fill = Rgba([0, 0, 0, 255]); // Black for initial/final
        let connection_color = Rgba([100, 100, 100, 255]); // Gray

        // Draw states
        for node in diagram.nodes() {
            let bounds = node.bounds();
            let x1 = (bounds.x1 - x_offset) as i32;
            let y1 = (bounds.y1 - y_offset) as i32;
            let x2 = (bounds.x2 - x_offset) as i32;
            let y2 = (bounds.y2 - y_offset) as i32;

            match node {
                jmt_core::node::Node::State(state) => {
                    // Draw filled rounded rectangle with proper corners
                    let corner_radius = 12; // Match the diagra
draw_filled_rect function · rust · L1488-L1495 (8 LOC)
jmt-rust/jmt-client/src/app.rs
    fn draw_filled_rect(img: &mut image::ImageBuffer<image::Rgba<u8>, Vec<u8>>, x1: i32, y1: i32, x2: i32, y2: i32, color: image::Rgba<u8>) {
        let (width, height) = img.dimensions();
        for y in y1.max(0)..y2.min(height as i32) {
            for x in x1.max(0)..x2.min(width as i32) {
                img.put_pixel(x as u32, y as u32, color);
            }
        }
    }
draw_rect_outline function · rust · L1498-L1503 (6 LOC)
jmt-rust/jmt-client/src/app.rs
    fn draw_rect_outline(img: &mut image::ImageBuffer<image::Rgba<u8>, Vec<u8>>, x1: i32, y1: i32, x2: i32, y2: i32, color: image::Rgba<u8>) {
        Self::draw_line(img, x1, y1, x2, y1, color); // Top
        Self::draw_line(img, x1, y2, x2, y2, color); // Bottom
        Self::draw_line(img, x1, y1, x1, y2, color); // Left
        Self::draw_line(img, x2, y1, x2, y2, color); // Right
    }
draw_filled_rounded_rect function · rust · L1507-L1543 (37 LOC)
jmt-rust/jmt-client/src/app.rs
    fn draw_filled_rounded_rect(img: &mut image::ImageBuffer<image::Rgba<u8>, Vec<u8>>, x1: i32, y1: i32, x2: i32, y2: i32, radius: i32, color: image::Rgba<u8>) {
        let (width, height) = img.dimensions();
        let r = radius.min((x2 - x1) / 2).min((y2 - y1) / 2);

        for y in y1.max(0)..y2.min(height as i32) {
            for x in x1.max(0)..x2.min(width as i32) {
                // Check if point is inside rounded rect
                let in_rect = if x < x1 + r && y < y1 + r {
                    // Top-left corner
                    let dx = x - (x1 + r);
                    let dy = y - (y1 + r);
                    dx * dx + dy * dy <= r * r
                } else if x > x2 - r && y < y1 + r {
                    // Top-right corner
                    let dx = x - (x2 - r);
                    let dy = y - (y1 + r);
                    dx * dx + dy * dy <= r * r
                } else if x < x1 + r && y > y2 - r {
                    // Bottom-left corner
         
draw_rounded_rect_outline function · rust · L1547-L1561 (15 LOC)
jmt-rust/jmt-client/src/app.rs
    fn draw_rounded_rect_outline(img: &mut image::ImageBuffer<image::Rgba<u8>, Vec<u8>>, x1: i32, y1: i32, x2: i32, y2: i32, radius: i32, color: image::Rgba<u8>) {
        let r = radius.min((x2 - x1) / 2).min((y2 - y1) / 2);

        // Draw straight edges (excluding corners)
        Self::draw_line(img, x1 + r, y1, x2 - r, y1, color); // Top
        Self::draw_line(img, x1 + r, y2, x2 - r, y2, color); // Bottom
        Self::draw_line(img, x1, y1 + r, x1, y2 - r, color); // Left
        Self::draw_line(img, x2, y1 + r, x2, y2 - r, color); // Right

        // Draw corner arcs using circle algorithm
        Self::draw_corner_arc(img, x1 + r, y1 + r, r, 2, color); // Top-left
        Self::draw_corner_arc(img, x2 - r, y1 + r, r, 1, color); // Top-right
        Self::draw_corner_arc(img, x1 + r, y2 - r, r, 3, color); // Bottom-left
        Self::draw_corner_arc(img, x2 - r, y2 - r, r, 0, color); // Bottom-right
    }
If a scraper extracted this row, it came from Repobility (https://repobility.com)
draw_corner_arc function · rust · L1565-L1594 (30 LOC)
jmt-rust/jmt-client/src/app.rs
    fn draw_corner_arc(img: &mut image::ImageBuffer<image::Rgba<u8>, Vec<u8>>, cx: i32, cy: i32, r: i32, quadrant: u8, color: image::Rgba<u8>) {
        let (width, height) = img.dimensions();
        let mut x = 0;
        let mut y = r;
        let mut d = 3 - 2 * r;

        while x <= y {
            let points = match quadrant {
                0 => [(cx + x, cy + y), (cx + y, cy + x)], // Bottom-right
                1 => [(cx + x, cy - y), (cx + y, cy - x)], // Top-right
                2 => [(cx - x, cy - y), (cx - y, cy - x)], // Top-left
                3 => [(cx - x, cy + y), (cx - y, cy + x)], // Bottom-left
                _ => [(cx, cy), (cx, cy)],
            };

            for (px, py) in points {
                if px >= 0 && px < width as i32 && py >= 0 && py < height as i32 {
                    img.put_pixel(px as u32, py as u32, color);
                }
            }

            if d < 0 {
                d += 4 * x + 6;
            } else {
                d +=
draw_line function · rust · L1597-L1616 (20 LOC)
jmt-rust/jmt-client/src/app.rs
    fn draw_line(img: &mut image::ImageBuffer<image::Rgba<u8>, Vec<u8>>, x1: i32, y1: i32, x2: i32, y2: i32, color: image::Rgba<u8>) {
        let (width, height) = img.dimensions();
        let dx = (x2 - x1).abs();
        let dy = (y2 - y1).abs();
        let sx = if x1 < x2 { 1 } else { -1 };
        let sy = if y1 < y2 { 1 } else { -1 };
        let mut err = dx - dy;
        let mut x = x1;
        let mut y = y1;

        loop {
            if x >= 0 && x < width as i32 && y >= 0 && y < height as i32 {
                img.put_pixel(x as u32, y as u32, color);
            }
            if x == x2 && y == y2 { break; }
            let e2 = 2 * err;
            if e2 > -dy { err -= dy; x += sx; }
            if e2 < dx { err += dx; y += sy; }
        }
    }
draw_filled_circle function · rust · L1619-L1632 (14 LOC)
jmt-rust/jmt-client/src/app.rs
    fn draw_filled_circle(img: &mut image::ImageBuffer<image::Rgba<u8>, Vec<u8>>, cx: i32, cy: i32, radius: i32, color: image::Rgba<u8>) {
        let (width, height) = img.dimensions();
        for dy in -radius..=radius {
            for dx in -radius..=radius {
                if dx * dx + dy * dy <= radius * radius {
                    let x = cx + dx;
                    let y = cy + dy;
                    if x >= 0 && x < width as i32 && y >= 0 && y < height as i32 {
                        img.put_pixel(x as u32, y as u32, color);
                    }
                }
            }
        }
    }
page 1 / 12next ›