Horizontal Wrapping

This commit is contained in:
2022-06-08 11:42:36 -05:00
parent 67ff5dd0df
commit dbd370f53c
2 changed files with 19 additions and 9 deletions

View File

@@ -7,7 +7,7 @@ use image::DynamicImage;
use rfd::FileDialog;
use board_builder::{ Board, Node, CoordTransformer, read_board_from_file, write_board_to_file, should_wrap_horizontal };
use board_builder::{ Board, Node, CoordTransformer, read_board_from_file, write_board_to_file };
use std::path::Path;
use std::collections::HashSet;
@@ -174,11 +174,11 @@ impl BoardBuilderApp {
let stroke = Stroke { width: 1.0, color: Color32::BLACK };
for edge in &node.edges {
let other_node = &board.nodes[edge];
if board.config.horizontal_wrapping && should_wrap_horizontal(node, other_node) {
if board.config.horizontal_wrapping && node.should_wrap_horizontal(other_node) {
let mut nodes = [node, other_node];
nodes.sort_by(|a, b| a.x.partial_cmp(&b.x).unwrap());
let [left_node, right_node] = nodes;
let y_mid = (left_node.y + right_node.y) / 2.0;
let y_mid = left_node.y_mid(right_node);
painter.line_segment(
[view.inv_xform(0.0, y_mid), view.inv_xform(left_node.x, left_node.y)],
stroke