def drawTiles(self,dc):
dc.SetFont(self.scFont)
for row in range(4):
for col in range(4):
value = self.data[row][col]
color = self.colors[value]
if value==2 or value==4:
dc.SetTextForeground((119,110,101))
else:
dc.SetTextForeground((255,255,255))
dc.SetBrush(wx.Brush(color))
dc.SetPen(wx.Pen(color))
dc.DrawRoundedRectangle(30+col*115,165+row*115,100,100,2)
size = dc.GetTextExtent(str(value))
while size[0]>100-15*2:
self.scFont = wx.Font(self.scFont.GetPointSize()*4/5,wx.SWISS,wx.NORMAL,wx.BOLD,face=u"Roboto")
dc.SetFont(self.scFont)
size = dc.GetTextExtent(str(value))
if value!=0: dc.DrawText(str(value),30+col*115+(100-size[0])/2,165+row*115+(100-size[1])/2)
评论列表
文章目录