comparison orpg/map/_grid.py @ 0:4385a7d0efd1 grumpy-goblin

Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
author sirebral
date Tue, 14 Jul 2009 16:41:58 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4385a7d0efd1
1 import wx
2
3 import orpg.dirpath
4 from orpg.orpgCore import *
5 from orpg.tools.rgbhex import RGBHex
6
7 class GridLayer:
8 def __init__(self, canvas):
9 self.canvas = canvas
10 self.RGBHex = RGBHex()
11
12 def Draw(self, dc):
13 r, g, b = self.RGBHex.rgb_tuple(self.canvas.gridColor)
14 pen = wx.Pen(wx.Color(r, g, b, 255), 1, self.canvas.gridLines)
15 dc.SetPen(pen)
16
17 path = dc.CreatePath()
18
19 if self.canvas.gridType == 'Square':
20 self._DrawSquare(dc, path)
21
22 dc.SetPen(wx.NullPen)
23
24 def _DrawSquare(self, dc, path):
25 path.MoveToPoint(0, 0)
26 y = 0
27 while y < self.canvas.size[1]:
28 path.AddLineToPoint(self.canvas.size[0], y)
29 y += self.canvas.gridSize
30 path.MoveToPoint(0, y)
31
32 path.MoveToPoint(0, 0)
33 x = 0
34 while x < self.canvas.size[0]:
35 path.AddLineToPoint(x, self.canvas.size[0])
36 x += self.canvas.gridSize
37 path.MoveToPoint(x, 0)
38
39 dc.StrokePath(path)