-
-
Notifications
You must be signed in to change notification settings - Fork 931
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix brighten and darken alpha issue (#3414)
Fix brighten and darken alpha issue. This is all thanks to @jtmcdole's insight & fixes [here](#3407). --------- Co-authored-by: Lukas Klingsbo <[email protected]> Co-authored-by: Erick Zanardo <[email protected]> Co-authored-by: Lukas Klingsbo <[email protected]> Co-authored-by: John McDole <[email protected]>
- Loading branch information
1 parent
de74a93
commit de8e3bc
Showing
7 changed files
with
204 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import 'package:flame/components.dart'; | ||
import 'package:flame/extensions.dart'; | ||
import 'package:flame/game.dart'; | ||
|
||
class ImageBrightnessExample extends FlameGame { | ||
ImageBrightnessExample({ | ||
required this.brightness, | ||
}); | ||
|
||
final double brightness; | ||
|
||
static const String description = ''' | ||
Shows how a dart:ui `Image` can be brightened using Flame Image extensions. | ||
Use the properties on the side to change the brightness of the image. | ||
'''; | ||
|
||
@override | ||
Future<void> onLoad() async { | ||
final image = await images.load('flame.png'); | ||
final brightenedImage = await image.brighten(brightness / 100); | ||
|
||
add( | ||
SpriteComponent( | ||
sprite: Sprite(image), | ||
position: (size / 2) - Vector2(0, image.height / 2), | ||
size: image.size, | ||
anchor: Anchor.center, | ||
), | ||
); | ||
|
||
add( | ||
SpriteComponent( | ||
sprite: Sprite(brightenedImage), | ||
position: (size / 2) + Vector2(0, brightenedImage.height / 2), | ||
size: image.size, | ||
anchor: Anchor.center, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import 'package:flame/components.dart'; | ||
import 'package:flame/extensions.dart'; | ||
import 'package:flame/game.dart'; | ||
|
||
class ImageDarknessExample extends FlameGame { | ||
ImageDarknessExample({ | ||
required this.darkness, | ||
}); | ||
|
||
final double darkness; | ||
|
||
static const String description = ''' | ||
Shows how a dart:ui `Image` can be darkened using Flame Image extensions. | ||
Use the properties on the side to change the darkness of the image. | ||
'''; | ||
|
||
@override | ||
Future<void> onLoad() async { | ||
final image = await images.load('flame.png'); | ||
final darkenedImage = await image.darken(darkness / 100); | ||
|
||
add( | ||
SpriteComponent( | ||
sprite: Sprite(image), | ||
position: (size / 2) - Vector2(0, image.height / 2), | ||
size: image.size, | ||
anchor: Anchor.center, | ||
), | ||
); | ||
|
||
add( | ||
SpriteComponent( | ||
sprite: Sprite(darkenedImage), | ||
position: (size / 2) + Vector2(0, darkenedImage.height / 2), | ||
size: image.size, | ||
anchor: Anchor.center, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters