forked from flame-engine/tiled.dart
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'flame-engine#69-dart-sdk'
- Loading branch information
Showing
10 changed files
with
37 additions
and
19 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 |
---|---|---|
@@ -1,9 +1,29 @@ | ||
part of tiled; | ||
|
||
const _mask = 0xff; | ||
int _sub(int hex, int index) => (hex & (_mask << index * 8)) >> index * 8; | ||
|
||
class Color extends RgbColor { | ||
int _sub(int hex, int index) { | ||
final value = (hex & (_mask << index * 8)) >> index * 8; | ||
assert(value >= 0 && value < 256); | ||
return value; | ||
} | ||
|
||
class Color { | ||
final int red; | ||
final int green; | ||
final int blue; | ||
final int alpha; | ||
|
||
/// Format: aarrggbb | ||
Color(int hex) : super(_sub(hex, 2), _sub(hex, 1), _sub(hex, 0), _sub(hex, 3)); | ||
Color.hex(int hex) | ||
: alpha = _sub(hex, 3), | ||
red = _sub(hex, 2), | ||
green = _sub(hex, 1), | ||
blue = _sub(hex, 0); | ||
|
||
const Color.rgb(this.red, this.green, this.blue, [this.alpha = 255]) | ||
: assert(red >= 0 && red <= 255), | ||
assert(green >= 0 && green <= 255), | ||
assert(blue >= 0 && blue <= 255), | ||
assert(alpha >= 0 && alpha <= 255); | ||
} |
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