mirror of
https://github.com/flame-engine/flame.git
synced 2025-10-29 16:05:47 +08:00
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:
@ -26,7 +26,7 @@ void addImageStories(Dashbook dashbook) {
|
|||||||
'brightness',
|
'brightness',
|
||||||
(context) => GameWidget(
|
(context) => GameWidget(
|
||||||
game: ImageBrightnessExample(
|
game: ImageBrightnessExample(
|
||||||
brightness: context.numberProperty('brightness', 50),
|
brightness: context.numberProperty('brightness', 80),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
codeLink: baseLink('image/brighten.dart'),
|
codeLink: baseLink('image/brighten.dart'),
|
||||||
@ -36,7 +36,7 @@ void addImageStories(Dashbook dashbook) {
|
|||||||
'darkness',
|
'darkness',
|
||||||
(context) => GameWidget(
|
(context) => GameWidget(
|
||||||
game: ImageDarknessExample(
|
game: ImageDarknessExample(
|
||||||
darkness: context.numberProperty('darkness', 50),
|
darkness: context.numberProperty('darkness', 80),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
codeLink: baseLink('image/darkness.dart'),
|
codeLink: baseLink('image/darkness.dart'),
|
||||||
|
|||||||
@ -17,7 +17,7 @@ extension ColorExtension on Color {
|
|||||||
final hsl = HSLColor.fromColor(this);
|
final hsl = HSLColor.fromColor(this);
|
||||||
return hsl
|
return hsl
|
||||||
.withLightness(
|
.withLightness(
|
||||||
clampDouble(hsl.lightness * amount, 0.0, 1.0),
|
clampDouble(hsl.lightness * (1 - amount), 0.0, 1.0),
|
||||||
)
|
)
|
||||||
.toColor();
|
.toColor();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user