Support negative background intensity.

This commit is contained in:
levlam 2021-06-04 16:05:29 +03:00
parent 4b2c948a99
commit 2af0aa0074
2 changed files with 4 additions and 4 deletions

View File

@ -2638,7 +2638,7 @@ backgroundTypeWallpaper is_blurred:Bool is_moving:Bool = BackgroundType;
//@description A PNG or TGV (gzipped subset of SVG with MIME type "application/x-tgwallpattern") pattern to be combined with the background fill chosen by the user
//@fill Description of the background fill
//@intensity Intensity of the pattern when it is shown above the filled background; 0-100
//@intensity Intensity of the pattern when it is shown above the filled background; -100-100. If negative, the pattern color and the filled background colors needs to be inverted
//@is_moving True, if the background needs to be slightly moved when device is tilted
backgroundTypePattern fill:BackgroundFill intensity:int32 is_moving:Bool = BackgroundType;

View File

@ -204,7 +204,7 @@ static string get_background_fill_color_hex_string(const BackgroundFill &fill, b
}
static bool is_valid_intensity(int32 intensity) {
return 0 <= intensity && intensity <= 100;
return -100 <= intensity && intensity <= 100;
}
int64 BackgroundFill::get_id() const {
@ -274,7 +274,7 @@ void BackgroundType::apply_parameters_from_link(Slice name) {
}
if (type == Type::Pattern) {
intensity = -1;
intensity = -101;
auto intensity_arg = query.get_arg("intensity");
if (!intensity_arg.empty()) {
intensity = to_integer<int32>(intensity_arg);
@ -401,7 +401,7 @@ BackgroundType get_background_type(bool is_pattern,
intensity = settings->intensity_;
if (!is_valid_intensity(intensity)) {
LOG(ERROR) << "Receive " << to_string(settings);
intensity = 0;
intensity = 50;
}
}
}