From f85263f27126f4fafa5211981fee75f71f68bed4 Mon Sep 17 00:00:00 2001 From: Gnarhard Date: Sat, 18 Jan 2025 19:38:57 -0700 Subject: [PATCH] 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. --- examples/lib/stories/image/image.dart | 4 ++-- packages/flame/lib/src/extensions/color.dart | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/lib/stories/image/image.dart b/examples/lib/stories/image/image.dart index 181c9862f..5b0a4410d 100644 --- a/examples/lib/stories/image/image.dart +++ b/examples/lib/stories/image/image.dart @@ -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'), diff --git a/packages/flame/lib/src/extensions/color.dart b/packages/flame/lib/src/extensions/color.dart index 4c78ae28e..e55fc6ede 100644 --- a/packages/flame/lib/src/extensions/color.dart +++ b/packages/flame/lib/src/extensions/color.dart @@ -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(); }