MiRCART{CanvasJournal,Frame,ToolRect}.py: implements variable brush size.

This commit is contained in:
Lucio Andrés Illanes Albornoz 2018-01-08 00:25:59 +01:00
parent 6a4356568b
commit 54adf3a95c
4 changed files with 23 additions and 10 deletions

View File

@ -221,6 +221,7 @@ class MiRCARTCanvas(wx.Panel):
super().__init__(parent, pos=canvasPos, \ super().__init__(parent, pos=canvasPos, \
size=[w*h for w,h in zip(canvasSize, cellSize)]) size=[w*h for w,h in zip(canvasSize, cellSize)])
self.SetDoubleBuffered(True)
self.Bind(wx.EVT_CLOSE, self.onClose) self.Bind(wx.EVT_CLOSE, self.onClose)
self.Bind(wx.EVT_ENTER_WINDOW, self.onMouseWindowEvent) self.Bind(wx.EVT_ENTER_WINDOW, self.onMouseWindowEvent)
self.Bind(wx.EVT_LEAVE_WINDOW, self.onMouseWindowEvent) self.Bind(wx.EVT_LEAVE_WINDOW, self.onMouseWindowEvent)

View File

@ -60,7 +60,10 @@ class MiRCARTCanvasJournal():
self._popTmp(eventDc, tmpDc) self._popTmp(eventDc, tmpDc)
for patch in mapPatch[1]: for patch in mapPatch[1]:
absMapPoint = self._relMapPointToAbsMapPoint(patch[0], atPoint) absMapPoint = self._relMapPointToAbsMapPoint(patch[0], atPoint)
if mapPatchTmp: if absMapPoint[0] >= self.parentCanvas.canvasSize[0] \
or absMapPoint[1] >= self.parentCanvas.canvasSize[1]:
continue
elif mapPatchTmp:
self._pushTmp(absMapPoint) self._pushTmp(absMapPoint)
self.parentCanvas.onJournalUpdate(mapPatchTmp, \ self.parentCanvas.onJournalUpdate(mapPatchTmp, \
absMapPoint, patch, eventDc, tmpDc, atPoint) absMapPoint, patch, eventDc, tmpDc, atPoint)

View File

@ -340,9 +340,14 @@ class MiRCARTFrame(MiRCARTGeneralFrame):
elif cid == self.CID_DELETE[0]: elif cid == self.CID_DELETE[0]:
pass pass
elif cid == self.CID_INCRBRUSH[0]: elif cid == self.CID_INCRBRUSH[0]:
pass self.panelCanvas.brushSize = \
elif cid == self.CID_DECRBRUSH[0]: [a+1 for a in self.panelCanvas.brushSize]
pass print(self.panelCanvas.brushSize)
elif cid == self.CID_DECRBRUSH[0] \
and self.panelCanvas.brushSize != [0,0]:
self.panelCanvas.brushSize = \
[a-1 for a in self.panelCanvas.brushSize]
print(self.panelCanvas.brushSize)
elif cid == self.CID_SOLID_BRUSH[0]: elif cid == self.CID_SOLID_BRUSH[0]:
pass pass
elif cid == self.CID_RECT[0]: elif cid == self.CID_RECT[0]:
@ -351,7 +356,7 @@ class MiRCARTFrame(MiRCARTGeneralFrame):
pass pass
elif cid == self.CID_LINE[0]: elif cid == self.CID_LINE[0]:
pass pass
elif cid >= self.CID_COLOUR00[0] \ elif cid >= self.CID_COLOUR00[0] \
and cid <= self.CID_COLOUR15[0]: and cid <= self.CID_COLOUR15[0]:
numColour = cid - self.CID_COLOUR00[0] numColour = cid - self.CID_COLOUR00[0]
if event.GetEventType() == wx.wxEVT_TOOL: if event.GetEventType() == wx.wxEVT_TOOL:

View File

@ -33,14 +33,18 @@ class MiRCARTToolRect(MiRCARTTool):
brushColours = brushColours.copy() brushColours = brushColours.copy()
if isLeftDown: if isLeftDown:
brushColours[1] = brushColours[0] brushColours[1] = brushColours[0]
return [[False, [[[0, 0], brushColours, 0, " "]]], \
[True, [[[0, 0], brushColours, 0, " "]]]]
elif isRightDown: elif isRightDown:
brushColours[0] = brushColours[1] brushColours[0] = brushColours[1]
return [[False, [[[0, 0], brushColours, 0, " "]]], \
[True, [[[0, 0], brushColours, 0, " "]]]]
else: else:
brushColours[1] = brushColours[0] brushColours[1] = brushColours[0]
return [[True, [[[0, 0], brushColours, 0, " "]]]] brushPatches = []
for brushRow in range(brushSize[1]):
for brushCol in range(brushSize[0] * 2):
brushPatches.append([[brushCol, brushRow], \
brushColours, 0, " "])
if isLeftDown or isRightDown:
return [[False, brushPatches], [True, brushPatches]]
else:
return [[True, brushPatches]]
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120 # vim:expandtab foldmethod=marker sw=4 ts=4 tw=120