fix aspect ratio of hex grid

This commit is contained in:
Kjell Wooding 2016-06-04 15:08:18 -07:00
parent 3d77ab264b
commit cc1604fe36
3 changed files with 17 additions and 5 deletions

View File

@ -565,6 +565,15 @@
" size_hint: 1, .33\n" " size_hint: 1, .33\n"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,

View File

@ -48,12 +48,10 @@ class StrategyGame(FloatLayout):
class HexMapCell(label.Label): class HexMapCell(label.Label):
def __init__(self, row=0, col=0, **kwargs): def __init__(self, row=0, col=0, **kwargs):
self.region_in_map = MapCoords(row, col) self.region_in_map = MapCoords(row, col)
super(HexMapCell, self).__init__(**kwargs) super(HexMapCell, self).__init__(**kwargs)
self.size_hint = (1,None)
self.height = self.width / math.sqrt(3)
class BU(HexMapCell): class BU(HexMapCell):
pass pass

View File

@ -1,10 +1,10 @@
#:import math math
#:include debug.kv #:include debug.kv
<StrategyGame>: <StrategyGame>:
id: _game id: _game
main_map: _main_map main_map: _main_map
map_rows: 10 map_rows: 30
map_cols: 10 map_cols: 10
BoxLayout: BoxLayout:
orientation: 'horizontal' orientation: 'horizontal'
@ -23,6 +23,7 @@
text: 'mini-map' text: 'mini-map'
size_hint: 1, .33 size_hint: 1, .33
<BU>: <BU>:
canvas: canvas:
Color: Color:
@ -51,3 +52,7 @@
Line: Line:
points: (self.right, self.y, self.right, self.top) points: (self.right, self.y, self.right, self.top)
width: 2 width: 2
<HexMapCell>:
size_hint: 1, None
height: self.width / math.sqrt(3)