Quick experiment to figure out a rough hex map layout using floatlayouts.

This commit is contained in:
Dorian 2017-02-22 08:47:48 -05:00
parent 81f23f7d28
commit e440d5fc66
2 changed files with 75 additions and 0 deletions

25
experiment.py Normal file
View File

@ -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()

50
hexmesh.kv Normal file
View File

@ -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
<Hex>:
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
]