From 9182a57af544afe53d5203d550f8a9babad382cf Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Thu, 24 Jan 2019 09:58:34 -0800 Subject: [PATCH] enabling draw_arrow again... math is not quite great --- docs/TODO_ux.md | 19 +++++++++---------- editor/src/render/turn.rs | 2 +- ezgui/src/lib.rs | 20 ++------------------ 3 files changed, 12 insertions(+), 29 deletions(-) diff --git a/docs/TODO_ux.md b/docs/TODO_ux.md index 1d6003343f..dcc33abde9 100644 --- a/docs/TODO_ux.md +++ b/docs/TODO_ux.md @@ -65,17 +65,16 @@ ## Switch to OpenGL (for speed) -- no bugs - - arrows... then debug legend - - do basic benchmarking - -- make polygon store points and indices efficiently -- change ezgui API to allow uploading geometry once - - see if performance of huge maps is noticably affected -- undo the y inversion hacks at last! -- need padding around text -- text entry needs to draw the cursor differently +- speed + - make polygon store points and indices efficiently + - change ezgui API to allow uploading geometry once + - measure performance of huge maps +- quality + - need padding around text + - text entry needs to draw the cursor differently + - better arrows (then debug the legend plugin) - refactoring - pass canvas to text module, make it do the glyph borrowing? - pass dims to draw_text_bubble; all callers have it anyway, right? - probably use f32, not f64 everywhere + - undo the y inversion hacks at last! diff --git a/editor/src/render/turn.rs b/editor/src/render/turn.rs index 0d2b037fe5..d8d13d098f 100644 --- a/editor/src/render/turn.rs +++ b/editor/src/render/turn.rs @@ -47,7 +47,7 @@ impl DrawTurn { g.draw_polygon(color, &pl.make_polygons(2.0 * BIG_ARROW_THICKNESS)); } // And a cap on the arrow - g.draw_arrow(color, BIG_ARROW_THICKNESS, &t.geom.last_line()); + g.draw_arrow(color, 2.0 * BIG_ARROW_THICKNESS, &t.geom.last_line()); } pub fn draw_dashed(turn: &Turn, g: &mut GfxCtx, color: Color) { diff --git a/ezgui/src/lib.rs b/ezgui/src/lib.rs index 59fd13ad42..eba27f66d5 100644 --- a/ezgui/src/lib.rs +++ b/ezgui/src/lib.rs @@ -24,6 +24,7 @@ pub use crate::text::Text; pub use crate::text_box::TextBox; pub use crate::top_menu::{Folder, TopMenu}; pub use crate::wizard::{Wizard, WrappedWizard}; +use dimensioned::si; use geom::{Angle, Circle, Line, Polygon, Pt2D, Triangle}; use glium::{implement_vertex, uniform, Surface}; @@ -180,23 +181,6 @@ impl<'a> GfxCtx<'a> { } pub fn draw_arrow(&mut self, color: Color, thickness: f64, line: &Line) { - self.draw_line(color, thickness, line); - - // TODO Raw method doesn't work yet in all cases... - /*graphics::Line::new_round(color.0, thickness).draw_arrow( - [ - line.pt1().x(), - line.pt1().y(), - line.pt2().x(), - line.pt2().y(), - ], - 2.0 * thickness, - &self.ctx.draw_state, - self.ctx.transform, - self.gfx, - );*/ - - /*use dimensioned::si; let head_size = 2.0 * thickness; let angle = line.angle(); let triangle_height = (head_size / 2.0).sqrt() * si::M; @@ -226,7 +210,7 @@ impl<'a> GfxCtx<'a> { .project_away(head_size, angle.rotate_degs(-135.0)), line.pt2().project_away(head_size, angle.rotate_degs(135.0)), ]), - );*/ + ); } pub fn draw_polygon(&mut self, color: Color, poly: &Polygon) {