@@ -22,6 +22,8 @@ function PaintTool:CreateCanvasPanel()
2222 self .snapToGrid = true
2323 self .mousePos = NewPoint ()
2424
25+ self .maskId = - 1
26+
2527 -- self.scale = 1
2628 self .scaledViewport = NewRect ()
2729 self .scaleValues = {.5 , 1 , 2 , 4 , 8 }-- , 8}
@@ -602,7 +604,7 @@ function PaintTool:DrawCanvasPanel()
602604 end
603605
604606 -- Redraw the background of the canvas
605- if (self .backgroundMode ~= 1 ) then
607+ if (self .maskId > - 1 ) then
606608 self .backgroundLayerCanvas :DrawPixels (self .viewportRect .X , self .viewportRect .Y , DrawMode .TilemapCache , self .scale , 0 , 0 , self .scaledViewport )
607609 end
608610
@@ -615,20 +617,17 @@ function PaintTool:DrawCanvasPanel()
615617
616618 end
617619
618- -- TODO need to tie this into the mask color selection (which is not implemented yet so default to 0)
619- local tmpMaskId = 0
620-
621620 -- Draw the pixel data in the upper left hand corner of the tool's window
622- self .imageLayerCanvas :DrawPixels (self .viewportRect .X , self .viewportRect .Y , DrawMode .TilemapCache , self .scale , self .colorOffset , tmpMaskId , self .scaledViewport )
621+ self .imageLayerCanvas :DrawPixels (self .viewportRect .X , self .viewportRect .Y , DrawMode .TilemapCache , self .scale , self .colorOffset , self . maskId , self .scaledViewport )
623622
624623 -- Only draw the flag layer when we need to
625624 if (self .pickerMode == FlagMode ) then
626- self .flagLayerCanvas :DrawPixels (self .viewportRect .X , self .viewportRect .Y , DrawMode .TilemapCache , self .scale , self .colorOffset , tmpMaskId , self .scaledViewport )
625+ self .flagLayerCanvas :DrawPixels (self .viewportRect .X , self .viewportRect .Y , DrawMode .TilemapCache , self .scale , self .colorOffset , self . maskId , self .scaledViewport )
627626 end
628627
629628 -- Only draw the temp layer when we need to
630629 if (self .drawTmpLayer == true ) then
631- self .tmpLayerCanvas :DrawPixels (self .viewportRect .X , self .viewportRect .Y , DrawMode .TilemapCache , self .scale , self .colorOffset , tmpMaskId , self .scaledViewport )
630+ self .tmpLayerCanvas :DrawPixels (self .viewportRect .X , self .viewportRect .Y , DrawMode .TilemapCache , self .scale , self .colorOffset , self . maskId , self .scaledViewport )
632631 end
633632
634633 -- if(self.showGrid == true) then
@@ -1296,30 +1295,30 @@ end
12961295
12971296function PaintTool :InvalidateBackground ()
12981297
1299- -- Mode 1 will render the transparent canvas texture for the background
1300- -- if(self.backgroundMode == 1) then
1298+ -- Mode 1 shows all the colors, no masking
1299+ if (self .backgroundMode == 1 ) then
13011300
13021301 -- print("Sprite", dump(Sprite(MetaSprite("emptymaskcolor").Sprites[1].Id)))
1303-
1304-
13051302
1303+ self .maskId = - 1
13061304
1307- -- Mode 2 will render the background color
1308- -- else
1309- if (self .backgroundMode == 2 ) then
1305+ -- Mode 2 uses the mask and transparent background
1306+ elseif (self .backgroundMode == 2 ) then
13101307
1311- self .backgroundLayerCanvas : fill ( self . backgroundColorId + self . colorOffset )
1308+ self .maskId = 0 -- TODO this needs to be provided by the selected mask color
13121309
1310+ self .backgroundLayerCanvas :DrawRectangle (0 , 0 , self .backgroundLayerCanvas .Width , self .backgroundLayerCanvas .Height , true )
1311+
1312+ -- Mode 3 shows the background color
13131313 else
13141314
1315- -- Use the mask color as the default background
1316- -- self.backgroundLayerCanvas:fill(self.colorOffset)
1315+ self .maskId = 0 -- TODO this needs to be provided by the selected mask color
13171316
1318- self .backgroundLayerCanvas :DrawRectangle ( 0 , 0 , self .backgroundLayerCanvas . Width , self .backgroundLayerCanvas . Height , true )
1317+ self .backgroundLayerCanvas :fill ( self .backgroundColorId + self .colorOffset )
13191318
13201319 end
13211320
1322- -- Invalidate the canvas to force it to redraw
1321+
13231322 self :InvalidateCanvas ()
13241323
13251324end
0 commit comments