Skip to content

Commit

Permalink
improve rendering of connection being drawn
Browse files Browse the repository at this point in the history
  • Loading branch information
Spydr06 committed Oct 4, 2023
1 parent 16642df commit 58e8951
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
16 changes: 3 additions & 13 deletions src/application/selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};

use crate::{
renderer::{vector::Vector2, Renderable, COLOR_THEME},
simulator::{Block, BlockID, Plot, SegmentID},
simulator::{render_block_connector, render_line, Block, BlockID, Plot, SegmentID},
};
use std::cmp;

Expand Down Expand Up @@ -80,18 +80,8 @@ impl Renderable for Selection {
.map(|_| ())
}
Self::Connection(_, start, end) => {
let offset = Vector2(
Vector2(start.0 + ((end.0 - start.0) as f32 * 0.7) as i32, start.1),
Vector2(end.0 + ((start.0 - end.0) as f32 * 0.7) as i32, end.1),
);

renderer
.set_line_width(4.)
.set_color(unsafe { &COLOR_THEME.disabled_bg_color })
.move_to(*start)
.curve_to(offset.0, offset.1, *end)
.stroke()
.map(|_| ())
render_line(false, *start, *end, renderer)?;
render_block_connector(*end, false, false, renderer)
}
Self::MoveBlock(block) => block.render(renderer, data),
_ => Ok(()),
Expand Down
6 changes: 3 additions & 3 deletions src/simulator/connection.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;
use crate::{
application::editor::{EditorMode, self},
application::editor::{self, EditorMode},
id::Id,
renderer::{vector::*, *},
};
Expand Down Expand Up @@ -475,7 +475,7 @@ where
.map(|_| ())
}

fn render_block_connector<R>(
pub fn render_block_connector<R>(
position: Vector2<i32>,
active: bool,
highlighted: bool,
Expand Down Expand Up @@ -507,7 +507,7 @@ where
.map(|_| ())
}

fn render_line<R>(
pub fn render_line<R>(
active: bool,
start: Vector2<i32>,
end: Vector2<i32>,
Expand Down

0 comments on commit 58e8951

Please sign in to comment.