Фон стола: исходный синий без светофора (anton/desktop-dashboard#4) #5

Merged
anton merged 1 commits from backdrop/original-blue into main 2026-09-15 11:59:41 +03:00
+10 -31
View File
@@ -755,34 +755,16 @@ function Rule:render_background(cr)
end
local function rule() return Rule() end
--- Full-screen backdrop: vertical gradient + coloured light blooms (desktop only).
--- The gradient is the MOOD of the machine (Anton, 2026-09-14): blue = everything fine (the original palette, whatever the load),
--- yellow = one warning, orange = several warnings, red = something is overloaded. Colours drift smoothly (~10 s) so it never flickers.
--- Anton explicitly rejected a green "busy" state: "по умолчанию когда всё хорошо — синий, как был".
-- MOOD = one number 0..1: 0 = the original blue palette (everything fine), 1 = red (overload). Warnings push it up
-- gradually (each yellow +0.25, any red = 1), so the desktop "reddens" with trouble instead of jumping between colours.
local MOOD_BLUE = {top = {0.05, 0.06, 0.14}, mid = {0.08, 0.07, 0.18}, bot = {0.04, 0.05, 0.11}}
local MOOD_RED = {top = {0.20, 0.04, 0.06}, mid = {0.25, 0.05, 0.08}, bot = {0.14, 0.03, 0.05}}
MOOD_TARGET = 0
local mood_cur = 0
local function mood_step() -- returns true while still drifting toward the target
local d = MOOD_TARGET - mood_cur
if math.abs(d) < 0.003 then mood_cur = MOOD_TARGET; return false end
mood_cur = mood_cur + d * 0.12
return true
end
local function mix(a, b, t) return {a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t, a[3] + (b[3] - a[3]) * t} end
--- Full-screen backdrop: the ORIGINAL fixed blue gradient + light blooms (desktop only).
--- 2026-09-15 Anton: the alert-driven blue→red mood is removed — with agents at work something is always
--- over a threshold, so the desktop stayed red. Alerts still show in the summary line and on the sensors.
local Backdrop = util.class(widget.Frame)
-- polycore paints backgrounds into a cached surface at layout time; while the mood colour drifts we ask for a relayout
-- each second (return true) so the cache is repainted. Once settled the cache is reused — no per-frame cost.
function Backdrop:update() return mood_step() end
function Backdrop:render_background(cr)
local w, h = SCREEN_W, SCREEN_H
local pat = cairo_pattern_create_linear(0, 0, 0, h)
local t = mood_cur
cairo_pattern_add_color_stop_rgb(pat, 0, unpack(mix(MOOD_BLUE.top, MOOD_RED.top, t)))
cairo_pattern_add_color_stop_rgb(pat, 0.55, unpack(mix(MOOD_BLUE.mid, MOOD_RED.mid, t)))
cairo_pattern_add_color_stop_rgb(pat, 1, unpack(mix(MOOD_BLUE.bot, MOOD_RED.bot, t)))
cairo_pattern_add_color_stop_rgb(pat, 0, 0.05, 0.06, 0.14)
cairo_pattern_add_color_stop_rgb(pat, 0.55, 0.08, 0.07, 0.18)
cairo_pattern_add_color_stop_rgb(pat, 1, 0.04, 0.05, 0.11)
cairo_rectangle(cr, 0, 0, w, h); cairo_set_source(cr, pat); cairo_fill(cr); cairo_pattern_destroy(pat)
local function bloom(x, y, rad, c, a)
local rp = cairo_pattern_create_radial(x, y, 0, x, y, rad)
@@ -790,11 +772,10 @@ function Backdrop:render_background(cr)
cairo_pattern_add_color_stop_rgba(rp, 1, c[1], c[2], c[3], 0)
cairo_rectangle(cr, 0, 0, w, h); cairo_set_source(cr, rp); cairo_fill(cr); cairo_pattern_destroy(rp)
end
-- blooms keep the original colours and warm toward red with the mood
bloom(120, 120, 620, mix(BLUE, RED, t), 0.16 + 0.10 * t)
bloom(w - 160, 240, 560, mix(MAUVE, RED, t), 0.14)
bloom(w * 0.5, h - 80, 700, mix(PINK, RED, t), 0.10)
bloom(220, h - 120, 480, mix(TEAL, RED, t), 0.08)
bloom(120, 120, 620, BLUE, 0.16)
bloom(w - 160, 240, 560, MAUVE, 0.14)
bloom(w * 0.5, h - 80, 700, PINK, 0.10)
bloom(220, h - 120, 480, TEAL, 0.08)
widget.Frame.render_background(self, cr)
end
@@ -856,8 +837,6 @@ local function clock_block()
local reds, yellows = {}, {}
for name, l in pairs(ALERTS) do if l == 2 then reds[#reds + 1] = name elseif l == 1 then yellows[#yellows + 1] = name end end
table.sort(reds); table.sort(yellows)
-- mood of the whole desktop (drives the backdrop colour): 0 = blue, each warning +0.25, any overload = 1 (red)
MOOD_TARGET = #reds > 0 and 1 or math.min(0.75, #yellows * 0.25)
if #reds > 0 then status_t:set_text("ПЕРЕГРУЗКА: " .. table.concat(reds, ", ")); paint(status_t, 2)
elseif #yellows > 0 then status_t:set_text("Внимание: " .. table.concat(yellows, ", ")); paint(status_t, 1)
else status_t:set_text("Всё в норме"); paint(status_t, 0) end