[gnome-2048] Move and clean code.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-2048] Move and clean code.
- Date: Thu, 7 Feb 2019 11:15:42 +0000 (UTC)
commit a62b7300f2d68a14d8ebc2f637067f9382948ae2
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed Feb 6 15:31:48 2019 +0100
Move and clean code.
src/view.vala | 36 +++++++++++++++++-------------------
1 file changed, 17 insertions(+), 19 deletions(-)
---
diff --git a/src/view.vala b/src/view.vala
index 5165738..61af9d7 100644
--- a/src/view.vala
+++ b/src/view.vala
@@ -123,11 +123,25 @@ private class TileView : RoundedRectangle
\*/
private static Clutter.Color _pick_color (uint8 tile_value)
+ requires (tile_value != 0)
{
- if (tile_value <= 11)
- return _pick_palette_color (tile_value);
- else
+ if (tile_value > 11)
return _calculate_color (tile_value);
+ else
+ return _pick_palette_color (tile_value);
+ }
+
+ private static Clutter.Color _calculate_color (uint8 tile_value)
+ requires (tile_value != 0)
+ {
+ Clutter.Color color = _pick_palette_color ((tile_value - 1) % 11 + 1);
+
+ uint8 sbits = (uint8) (Math.pow (2, tile_value) % 7);
+ color.red <<= sbits;
+ color.green <<= sbits;
+ color.blue <<= sbits;
+
+ return color;
}
private static Clutter.Color _pick_palette_color (uint8 tile_value)
@@ -150,20 +164,4 @@ private class TileView : RoundedRectangle
default: assert_not_reached ();
}
}
-
- private static Clutter.Color _calculate_color (uint8 tile_value)
- {
- uint8 norm_val = (tile_value - 1) % 11 + 1;
- Clutter.Color? nullable_color = _pick_palette_color (norm_val);
- if (nullable_color == null)
- assert_not_reached ();
- Clutter.Color color = (!) nullable_color;
-
- uint8 sbits = (uint8) (Math.pow (2, tile_value) % 7);
- color.red <<= sbits;
- color.green <<= sbits;
- color.blue <<= sbits;
-
- return color;
- }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]