about summary refs log tree commit diff stats
path: root/text.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-05-19 16:35:52 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-05-19 16:35:52 -0700
commit21f166689a6904dd85da7ede2ce06e7b2ab81a27 (patch)
treea25a59df8a42c7a28d27d0d0b655f02e3a074623 /text.lua
parent58169561b789b962e849aab87e846d387f805201 (diff)
downloadtext.love-21f166689a6904dd85da7ede2ce06e7b2ab81a27.tar.gz
a few more integer coordinates
Diffstat (limited to 'text.lua')
-rw-r--r--text.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/text.lua b/text.lua
index 1b78251..bd51971 100644
--- a/text.lua
+++ b/text.lua
@@ -181,14 +181,14 @@ function Text.move_cursor_down_to_next_text_line_while_scrolling_again_if_necess
 end
 
 function Text.scroll_up_while_cursor_on_screen()
-  local y = Screen_height - 15*Zoom -- for Cursor_line
+  local y = Screen_height - math.floor(15*Zoom) -- for Cursor_line
   while true do
     if Screen_top_line == 1 then break end
-    y = y - 15*Zoom
+    y = y - math.floor(15*Zoom)
     if Lines[Screen_top_line].mode == 'drawing' then
       y = y - Drawing.pixels(Lines[Screen_top_line].h)
     end
-    if y < 15*Zoom then
+    if y < math.floor(15*Zoom) then
       break
     end
     Screen_top_line = Screen_top_line - 1
@@ -197,7 +197,7 @@ end
 
 function Text.in_line(line, x,y)
   if line.y == nil then return false end  -- outside current page
-  return x >= 16 and y >= line.y and y < line.y+15*Zoom
+  return x >= 16 and y >= line.y and y < line.y + math.floor(15*Zoom)
 end
 
 function Text.move_cursor(line_index, line, x)
@@ -246,7 +246,7 @@ end
 function Text.cursor_x(line_data, cursor_pos)
   local line_before_cursor = line_data:sub(1, cursor_pos-1)
   local text_before_cursor = love.graphics.newText(love.graphics.getFont(), line_before_cursor)
-  return 25+text_before_cursor:getWidth()*Zoom
+  return 25 + math.floor(text_before_cursor:getWidth()*Zoom)
 end
 
 return Text