add nightlight hyprland plugin + rename hyprsunsetmanager -> nightlightmanager to control both
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
namespace ZShell::services {
|
||||
|
||||
inline std::array<float, 3> kelvinToGain(int kelvin) {
|
||||
const double t = std::clamp(kelvin, 1000, 40000) / 100.0;
|
||||
double r, g, b;
|
||||
|
||||
r = t <= 66.0
|
||||
? 1.0
|
||||
: std::clamp(
|
||||
1.29293618606 * std::pow(t - 60.0, -0.1332047592), 0.0, 1.0);
|
||||
g = t <= 66.0
|
||||
? std::clamp(0.39008157876 * std::log(t) - 0.63184144378, 0.0, 1.0)
|
||||
: std::clamp(
|
||||
1.12989086089 * std::pow(t - 60.0, -0.0755148492), 0.0, 1.0);
|
||||
b = t >= 66.0
|
||||
? 1.0
|
||||
: (t <= 19.0
|
||||
? 0.0
|
||||
: std::clamp(
|
||||
0.54320678911 * std::log(t - 10.0) - 1.19625408914,
|
||||
0.0,
|
||||
1.0));
|
||||
|
||||
return {static_cast<float>(r), static_cast<float>(g), static_cast<float>(b)};
|
||||
}
|
||||
|
||||
inline float easeInOutCubic(float x) {
|
||||
return x < 0.5f ? 4.f * x * x * x
|
||||
: 1.f - std::pow(-2.f * x + 2.f, 3.f) / 2.f;
|
||||
}
|
||||
|
||||
} // namespace ZShell::services
|
||||
Reference in New Issue
Block a user