summary refs log tree commit diff stats
path: root/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua22
1 files changed, 11 insertions, 11 deletions
diff --git a/main.lua b/main.lua
index 31922d8..c89801a 100644
--- a/main.lua
+++ b/main.lua
@@ -102,10 +102,16 @@ local function markupdated(pos, redraw)
   end
 end
 
+local function change_val(amt)
+  for i=math.min(visual_start or cp, cp), math.max(visual_start or cp, cp) do
+    imgt[i] = math.max(math.min(imgt[i] + amt, PAL_MAX), 0)
+    markupdated(i, true)
+  end
+end
+
 function love.wheelmoved(x, y)
   saved = nil
-  imgt[cp] = math.min(math.max(imgt[cp]+y, 0), PAL_MAX)
-  markupdated(cp, true)
+  change_val(y)
 end
 
 function setback(pos, highlight)
@@ -196,19 +202,13 @@ function love.update(dt)
   end
   local function decr()
     saved = nil
-    local amt = (kt['lshift'] and 16 or 1)
-    for i=math.min(visual_start or cp, cp), math.max(visual_start or cp, cp) do
-      imgt[i] = math.max(imgt[i] - amt, 0)
-      markupdated(i, true)
-    end
+    local amt = -(kt['lshift'] and 16 or 1)
+    change_val(amt)
   end
   local function incr()
     saved = nil
     local amt = (kt['lshift'] and 16 or 1)
-    for i=math.min(visual_start or cp, cp), math.max(visual_start or cp, cp) do
-      imgt[i] = math.min(imgt[i] + amt, PAL_MAX)
-      markupdated(i, true)
-    end
+    change_val(amt)
   end
   local function light_propagation_up()
     if visual_start then