diff --git a/experiment.py b/experiment.py new file mode 100644 index 0000000..27ad6a8 --- /dev/null +++ b/experiment.py @@ -0,0 +1,25 @@ +import random + +from kivy import properties +from kivy.app import App +from kivy.uix.label import Label + + +class HexMeshApp(App): + map_location = properties.StringProperty("Untouched") + + def update_press(self, text): + self.map_location = "Pressed {}".format(text) + + +class Hex(Label): + tile_color = properties.ListProperty([0, 1, 0, 0.5]) + + def __init__(self, **kwargs): + super(Hex, self).__init__(**kwargs) + for hue in range(0, 3): + self.tile_color[hue] = random.random() + + +if __name__ == '__main__': + HexMeshApp().run() diff --git a/hexmesh.kv b/hexmesh.kv new file mode 100644 index 0000000..54bca4e --- /dev/null +++ b/hexmesh.kv @@ -0,0 +1,50 @@ +#: import utils kivy.utils + +FloatLayout: + Label: + pos_hint: + { + "center_x": 0.5, + "center_y": 0.8 + } + text: app.map_location + Hex: + text: "H1" + center_x: 200 + center_y: 200 + Hex: + text: "H2" + center_x: 270 + center_y: 200 + Hex: + text: "H3" + center_x: 235 + center_y: 140 + + + +: + size_hint: None, None + size: "75dp", "75dp" + pos_hint: {} + on_touch_up: app.update_press(self.text) + canvas: + Color: + rgba: self.tile_color + Ellipse: + pos: self.pos + size: self.size + segments: 6 + Color: + rgb: utils.get_color_from_hex("#AB7B29") + Line: + width: 2 + circle: + [ + self.center_x, + self.center_y, + (self.width / 2) + dp(2), + 360, + 0, + 6 + ]