This commit is contained in:
Insality
2024-11-23 12:39:55 +02:00
parent 28bd165cee
commit 06f682e8e4
4 changed files with 66 additions and 24 deletions

View File

@@ -1,4 +1,5 @@
local color = require("druid.color")
local helper = require("druid.helper")
---@class widget.mini_graph: druid.widget
local M = {}
@@ -78,7 +79,7 @@ function M:set_line_value(index, value)
self.values[index] = value
local normalized = vmath.clamp(value/self.max_value, 0, 1)
local normalized = helper.clamp(value/self.max_value, 0, 1)
local target_color = color.lerp(normalized, self.color_zero, self.color_one)
gui.set_color(line, target_color)
self:set_line_height(index)
@@ -115,7 +116,7 @@ end
function M:set_line_height(index)
local value = self.values[index] or 0
local normalized = vmath.clamp(value / self.max_value, 0, 1)
local normalized = helper.clamp(value / self.max_value, 0, 1)
local size_y = normalized * 70
gui.set(self.lines[index], SIZE_Y, size_y)
end