fix: Darkness increases with higher values (#3448)

Previously, .darken(.98) would darken the image by 98%, now it darkens
by the inverse by 2%. This restores the original functionality.
This commit is contained in:
Gnarhard
2025-01-18 19:38:57 -07:00
committed by GitHub
parent 74763573c0
commit f85263f271
2 changed files with 3 additions and 3 deletions

View File

@ -26,7 +26,7 @@ void addImageStories(Dashbook dashbook) {
'brightness',
(context) => GameWidget(
game: ImageBrightnessExample(
brightness: context.numberProperty('brightness', 50),
brightness: context.numberProperty('brightness', 80),
),
),
codeLink: baseLink('image/brighten.dart'),
@ -36,7 +36,7 @@ void addImageStories(Dashbook dashbook) {
'darkness',
(context) => GameWidget(
game: ImageDarknessExample(
darkness: context.numberProperty('darkness', 50),
darkness: context.numberProperty('darkness', 80),
),
),
codeLink: baseLink('image/darkness.dart'),

View File

@ -17,7 +17,7 @@ extension ColorExtension on Color {
final hsl = HSLColor.fromColor(this);
return hsl
.withLightness(
clampDouble(hsl.lightness * amount, 0.0, 1.0),
clampDouble(hsl.lightness * (1 - amount), 0.0, 1.0),
)
.toColor();
}