-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Description This PR makes this package compatible with the Dart SDK. In order to achieve this I changed 3 things: - Replace `dart:ui`'s Color with a simple ColorData class - Replaced `Rect` from `flame` with `Rectangle` from `dart:math` - Replaced `flutter_test` with `test` package The `ColorData` class is used excatly once for which I prepared a flame_tiled PR (however I need to wait until this is merged right) including conversion extensions. No `Rectangle` attribute is ever read in `flame_tiled`, evenso `flame` already contains conversion extensions! ## Checklist - [x] The title of my PR starts with a [Conventional Commit] prefix (`fix:`, `feat:`, `docs:` etc). - [x] I have read the [Contributor Guide] and followed the process outlined for submitting PRs. --> `melos run analyze` fails due to `XmlData.value` however I think this requires another issue/PR - [x] I have updated/added tests for ALL new/updated/fixed functionality. - [x] I have updated/added relevant documentation in `docs` and added dartdoc comments with `///`. - [x] I have updated/added relevant examples in `examples`. --> I don't think there are any exmaples necessary for this ## Breaking Change - [x] Yes, this is a breaking change. - [ ] No, this is *not* a breaking change. I think this should result in a minor version bump to 0.11.0 to indicate these breaking changes! In order to achieve dart comaptibilty only two things changed: - Color: Custom data class --> `flame_tiled` contains a conversion extension - Rect: Instead using `dart:math`'s Rectangle --> Use `flame`'s `toRect()` method to convert ## Related Issues - #69 --------- Co-authored-by: benni-tec <me@benni-tec.de> Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
- Loading branch information
1 parent
581391c
commit 5ffc8bf
Showing
46 changed files
with
209 additions
and
126 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
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,53 @@ | ||
import 'package:meta/meta.dart'; | ||
|
||
/// Basic data class holding a Color in ARGB format. | ||
/// This can be converted to dart:ui's Color using the flame_tiled package | ||
@immutable | ||
class ColorData { | ||
static int _sub(int hex, int index) => (hex >> index * 8) & 0x000000ff; | ||
|
||
final int _hex; | ||
|
||
int get alpha => _sub(_hex, 3); | ||
|
||
int get red => _sub(_hex, 2); | ||
|
||
int get green => _sub(_hex, 1); | ||
|
||
int get blue => _sub(_hex, 0); | ||
|
||
/// Parses the Color from an int using the lower 32-bits and tiled's format: | ||
/// 0xaarrggbb | ||
const ColorData.hex(this._hex); | ||
|
||
const ColorData.rgb(int red, int green, int blue, [int alpha = 255]) | ||
: assert(red >= 0 && red <= 255), | ||
assert(green >= 0 && green <= 255), | ||
assert(blue >= 0 && blue <= 255), | ||
assert(alpha >= 0 && alpha <= 255), | ||
_hex = (alpha << 3 * 8) + | ||
(red << 2 * 8) + | ||
(green << 1 * 8) + | ||
(blue << 0 * 8); | ||
|
||
const ColorData.argb(int alpha, int red, int green, int blue) | ||
: assert(red >= 0 && red <= 255), | ||
assert(green >= 0 && green <= 255), | ||
assert(blue >= 0 && blue <= 255), | ||
assert(alpha >= 0 && alpha <= 255), | ||
_hex = (alpha << 3 * 8) + | ||
(red << 2 * 8) + | ||
(green << 1 * 8) + | ||
(blue << 0 * 8); | ||
|
||
@override | ||
bool operator ==(Object other) { | ||
if (other is! ColorData) { | ||
return false; | ||
} | ||
return _hex == other._hex; | ||
} | ||
|
||
@override | ||
int get hashCode => _hex.hashCode; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
part of '../../tiled.dart'; | ||
|
||
class Flips { | ||
final bool horizontally; | ||
final bool vertically; | ||
|
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
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
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
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
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
Oops, something went wrong.