@@ -45,11 +45,13 @@ wpd.BoxMaskTool = (function() {
4545 clearTimeout ( moveTimer ) ;
4646 isDrawing = false ;
4747 wpd . graphicsWidget . resetHover ( ) ;
48- ctx . dataCtx . fillStyle = "rgba(255,255,0,1)" ;
48+ ctx . dataCtx . globalCompositeOperation = "xor" ;
49+ ctx . oriDataCtx . globalCompositeOperation = "xor" ;
50+ ctx . dataCtx . fillStyle = "rgba(255,255,0,0.5)" ;
4951 let canvasPos = wpd . graphicsWidget . canvasPx ( pos . x , pos . y ) ;
5052 ctx . dataCtx . fillRect ( topScreenCorner . x , topScreenCorner . y ,
5153 canvasPos . x - topScreenCorner . x , canvasPos . y - topScreenCorner . y ) ;
52- ctx . oriDataCtx . fillStyle = "rgba(255,255,0,1 )" ;
54+ ctx . oriDataCtx . fillStyle = "rgba(255,255,0,0.5 )" ;
5355 ctx . oriDataCtx . fillRect ( topImageCorner . x , topImageCorner . y ,
5456 imagePos . x - topImageCorner . x ,
5557 imagePos . y - topImageCorner . y ) ;
@@ -117,13 +119,17 @@ wpd.PenMaskTool = (function() {
117119 isDrawing = false ,
118120 moveTimer ,
119121 screen_pos , canvas_pos , image_pos , mouseMoveHandler = function ( ) {
120- ctx . dataCtx . strokeStyle = "rgba(255,255,0,1)" ;
122+ ctx . dataCtx . globalCompositeOperation = "xor" ;
123+ ctx . oriDataCtx . globalCompositeOperation = "xor" ;
124+ ctx . dataCtx . strokeStyle = "rgba(255,255,0,0.5)" ;
121125 ctx . dataCtx . lineTo ( canvas_pos . x , canvas_pos . y ) ;
122126 ctx . dataCtx . stroke ( ) ;
123127
124- ctx . oriDataCtx . strokeStyle = "rgba(255,255,0,1 )" ;
128+ ctx . oriDataCtx . strokeStyle = "rgba(255,255,0,0.5 )" ;
125129 ctx . oriDataCtx . lineTo ( image_pos . x , image_pos . y ) ;
126130 ctx . oriDataCtx . stroke ( ) ;
131+ ctx . dataCtx . globalCompositeOperation = "source-over" ;
132+ ctx . oriDataCtx . globalCompositeOperation = "source-over" ;
127133 } ;
128134
129135 this . onAttach = function ( ) {
@@ -139,15 +145,19 @@ wpd.PenMaskTool = (function() {
139145 let lwidth = parseInt ( document . getElementById ( 'paintThickness' ) . value , 10 ) ;
140146 let canvasPos = wpd . graphicsWidget . canvasPx ( pos . x , pos . y ) ;
141147 isDrawing = true ;
142- ctx . dataCtx . strokeStyle = "rgba(255,255,0,1)" ;
148+ ctx . dataCtx . globalCompositeOperation = "xor" ;
149+ ctx . oriDataCtx . globalCompositeOperation = "xor" ;
150+ ctx . dataCtx . strokeStyle = "rgba(255,255,0,0.5)" ;
143151 ctx . dataCtx . lineWidth = lwidth * wpd . graphicsWidget . getZoomRatio ( ) ;
144152 ctx . dataCtx . beginPath ( ) ;
145153 ctx . dataCtx . moveTo ( canvasPos . x , canvasPos . y ) ;
146154
147- ctx . oriDataCtx . strokeStyle = "rgba(255,255,0,1 )" ;
155+ ctx . oriDataCtx . strokeStyle = "rgba(255,255,0,0.5 )" ;
148156 ctx . oriDataCtx . lineWidth = lwidth ;
149157 ctx . oriDataCtx . beginPath ( ) ;
150158 ctx . oriDataCtx . moveTo ( imagePos . x , imagePos . y ) ;
159+ ctx . dataCtx . globalCompositeOperation = "source-over" ;
160+ ctx . oriDataCtx . globalCompositeOperation = "source-over" ;
151161 } ;
152162
153163 this . onMouseMove = function ( ev , pos , imagePos ) {
@@ -200,6 +210,8 @@ wpd.EraseMaskTool = (function() {
200210 ctx . oriDataCtx . strokeStyle = "rgba(255,255,0,1)" ;
201211 ctx . oriDataCtx . lineTo ( image_pos . x , image_pos . y ) ;
202212 ctx . oriDataCtx . stroke ( ) ;
213+ ctx . dataCtx . globalCompositeOperation = "source-over" ;
214+ ctx . oriDataCtx . globalCompositeOperation = "source-over" ;
203215 } ;
204216
205217 this . onAttach = function ( ) {
@@ -227,6 +239,8 @@ wpd.EraseMaskTool = (function() {
227239 ctx . oriDataCtx . lineWidth = lwidth ;
228240 ctx . oriDataCtx . beginPath ( ) ;
229241 ctx . oriDataCtx . moveTo ( imagePos . x , imagePos . y ) ;
242+ ctx . dataCtx . globalCompositeOperation = "source-over" ;
243+ ctx . oriDataCtx . globalCompositeOperation = "source-over" ;
230244 } ;
231245
232246 this . onMouseMove = function ( ev , pos , imagePos ) {
@@ -300,7 +314,7 @@ wpd.MaskPainter = (function() {
300314 imgData . data [ img_index * 4 ] = 255 ;
301315 imgData . data [ img_index * 4 + 1 ] = 255 ;
302316 imgData . data [ img_index * 4 + 2 ] = 0 ;
303- imgData . data [ img_index * 4 + 3 ] = 255 ;
317+ imgData . data [ img_index * 4 + 3 ] = 255 / 2 ;
304318 }
305319
306320 ctx . oriDataCtx . putImageData ( imgData , 0 , 0 ) ;
0 commit comments