mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Rotate background with half a speed.
This commit is contained in:
parent
b6cd9c2911
commit
e880b66574
1 changed files with 26 additions and 6 deletions
|
@ -32,6 +32,25 @@ constexpr auto kMinAcceptableContrast = 1.14;// 4.5;
|
|||
return QColor(213, 223, 233);
|
||||
}
|
||||
|
||||
[[nodiscard]] int ComputeRealRotation(const CacheBackgroundRequest &request) {
|
||||
if (request.background.colors.size() < 3) {
|
||||
return request.background.gradientRotation;
|
||||
}
|
||||
const auto doubled = (request.background.gradientRotation
|
||||
+ request.gradientRotationAdd) % 720;
|
||||
return (((doubled % 2) ? (doubled - 45) : doubled) / 2) % 360;
|
||||
}
|
||||
|
||||
[[nodiscard]] double ComputeRealProgress(
|
||||
const CacheBackgroundRequest &request) {
|
||||
if (request.background.colors.size() < 3) {
|
||||
return 1.;
|
||||
}
|
||||
const auto doubled = (request.background.gradientRotation
|
||||
+ request.gradientRotationAdd) % 720;
|
||||
return (doubled % 2) ? 0.5 : 1.;
|
||||
}
|
||||
|
||||
[[nodiscard]] CacheBackgroundResult CacheBackground(
|
||||
const CacheBackgroundRequest &request) {
|
||||
Expects(!request.area.isEmpty());
|
||||
|
@ -42,8 +61,8 @@ constexpr auto kMinAcceptableContrast = 1.14;// 4.5;
|
|||
? Images::GenerateGradient(
|
||||
request.background.gradientForFill.size(),
|
||||
request.background.colors,
|
||||
(request.background.gradientRotation
|
||||
+ request.gradientRotationAdd) % 360)
|
||||
ComputeRealRotation(request),
|
||||
ComputeRealProgress(request))
|
||||
: request.background.gradientForFill;
|
||||
if (request.background.isPattern
|
||||
|| request.background.tile
|
||||
|
@ -431,10 +450,10 @@ void ChatTheme::generateNextBackgroundRotation() {
|
|||
if (background().colors.size() < 3) {
|
||||
return;
|
||||
}
|
||||
constexpr auto kAddRotation = 315;
|
||||
constexpr auto kAddRotationDoubled = (720 - 45);
|
||||
const auto request = currentCacheRequest(
|
||||
_backgroundState.now.area,
|
||||
kAddRotation);
|
||||
kAddRotationDoubled);
|
||||
if (!request) {
|
||||
return;
|
||||
}
|
||||
|
@ -445,10 +464,11 @@ void ChatTheme::generateNextBackgroundRotation() {
|
|||
}
|
||||
const auto request = currentCacheRequest(
|
||||
_backgroundState.now.area,
|
||||
kAddRotation);
|
||||
kAddRotationDoubled);
|
||||
if (forRequest == request) {
|
||||
_mutableBackground.gradientRotation
|
||||
= (_mutableBackground.gradientRotation + kAddRotation) % 360;
|
||||
= (_mutableBackground.gradientRotation
|
||||
+ kAddRotationDoubled) % 720;
|
||||
_backgroundNext = std::move(result);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue