From 2026acde325e875a0fa9e53aa8cf370c9381f22f Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Tue, 23 Oct 2018 13:56:04 -0700 Subject: [PATCH] draw_text_at centers the text box --- ezgui/src/canvas.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ezgui/src/canvas.rs b/ezgui/src/canvas.rs index 1db39be0bc..a1007111fb 100644 --- a/ezgui/src/canvas.rs +++ b/ezgui/src/canvas.rs @@ -86,7 +86,9 @@ impl Canvas { } pub fn draw_text_at(&self, g: &mut GfxCtx, txt: Text, pt: Pt2D) { - text::draw_text_bubble(g, self.map_to_screen(pt), txt); + let (width, height) = txt.dims(g); + let (x, y) = self.map_to_screen(pt); + text::draw_text_bubble(g, (x - (width / 2.0), y - (height / 2.0)), txt); } pub fn draw_text(