about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--app.lua8
-rw-r--r--drawing.lua6
2 files changed, 7 insertions, 7 deletions
diff --git a/app.lua b/app.lua
index 3ed3aa8..56cd244 100644
--- a/app.lua
+++ b/app.lua
@@ -163,6 +163,10 @@ function App.newText(font, s)
   return {type='text', data=s, text=love.graphics.newText(font, s)}
 end
 
+function App.width(text)
+  return text.text:getWidth()
+end
+
 function App.screen.draw(obj, x,y)
   if type(obj) == 'userdata' then
     -- ignore most things as graphics the test harness can't handle
@@ -192,10 +196,6 @@ function App.run_after_mousepress(x,y, button)
   App.draw()
 end
 
-function App.width(text)
-  return text.text:getWidth()
-end
-
 function App.screen.check(y, expected_contents, msg)
 --?   print('checking for "'..expected_contents..'" at y '..tostring(y))
   local screen_row = 'y'..tostring(y)
diff --git a/drawing.lua b/drawing.lua
index 5575904..677cab3 100644
--- a/drawing.lua
+++ b/drawing.lua
@@ -56,11 +56,11 @@ function Drawing.draw(line)
           local name_text
           -- TODO: avoid computing name width on every repaint
           if p.name == '' then
-            name_text = love.graphics.newText(love.graphics.getFont(), 'm')  -- 1em
+            name_text = App.newText(love.graphics.getFont(), 'm')  -- 1em
           else
-            name_text = love.graphics.newText(love.graphics.getFont(), p.name)
+            name_text = App.newText(love.graphics.getFont(), p.name)
           end
-          love.graphics.rectangle('fill', x,y, math.floor(name_text:getWidth()*Zoom), math.floor(15*Zoom))
+          love.graphics.rectangle('fill', x,y, math.floor(App.width(name_text)*Zoom), math.floor(15*Zoom))
         end
       end
     end