andyhill Posted April 29, 2021 Share Posted April 29, 2021 I am trying to draw a rectangle polyline over a canvas containing a color image, then (via way of a mouse drag move event) remove that rectangle polyline with it's original points and redraw as a new rectangle polyline using the new x,y co-ordinates. Code below paints with or without "xor", my problem is it will not erase when using the same points, happy for any help - Thanks - Andy UniSession.AddJS('var context=fMain.cArea._cc_; '+ 'var polyln = ['+s+']; '+ 'var shape = polyln.slice(0); '+ '{ '+ ' context.globalAlpha = 1; '+ ' context.globalCompositeOperation = ''xor''; '+ ' context.lineWidth = 1; '+ ' context.strokeStyle = "'+LineColourStr+'"; '+ ' context.moveTo(shape.shift(), shape.shift()); '+ ' while(shape.length) '+ ' { '+ ' context.lineTo(shape.shift(), shape.shift()); '+ ' } '+ ' context.stroke(); '+ ' context.globalCompositeOperation = ''source-over''; '+ ' context.globalAlpha = 1; '+ '}; ' ); Quote Link to comment Share on other sites More sharing options...
Sherzod Posted April 29, 2021 Share Posted April 29, 2021 10 hours ago, andyhill said: I am trying to draw a rectangle polyline over a canvas containing a color image, then (via way of a mouse drag move event) remove that rectangle polyline with it's original points and redraw as a new rectangle polyline using the new x,y co-ordinates. Code below paints with or without "xor", my problem is it will not erase when using the same points, happy for any help - Thanks - Andy Hello, Do you have a simple testcase to test? Quote Link to comment Share on other sites More sharing options...
andyhill Posted April 30, 2021 Author Share Posted April 30, 2021 I experimented with Alpha and XOR. Please see README.txt and RequiredResult.jpg showing DrawClosedPolyLine once to show, then once to remove. 1) Fill does not work for me ? 2) XOR in my mind should erase ? Project1.zip Quote Link to comment Share on other sites More sharing options...
andyhill Posted April 30, 2021 Author Share Posted April 30, 2021 Added "context.fill();" now fills fine. Sherzod, please advise how to draw then erase (draw works fine). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.