javascript - Copy user selection from one canvas to another -


I am trying to implement a simple, select area on the canvas and then copying it to the area canvasab, Part I work has got the work done, but drawing of the copy area does not work. The idea is that the user will select an area and then that selection will appear on the second canvas, when they will end the selection, i.e. drag the mousewood, rectangular area, mouseup (appears to be copied)

I I agree a front end developer is not so much scared I am missing something about this thing how it works because I am trying to prove only one thing so that one Awadh I can prove Dana and understand the basics right now. JSFiddle is here -

HTML

  & lt; Canvas ID = "Basic" width = 300 height = 300 & gt; & Lt; / Canvas & gt; & Lt; Canvas ID = "CopyBit" width = 300 height = 300 & gt; & Lt; / Canvas & gt;   

javascript

  var original = document.getElementById ("original"); var CTXoriginal = original.getContext ("2D"); var copybit = document.getElementById ("copybit"); var CTXcopybit = copybit.getContext ("2D"); Var background = new image (); Background src = "https://i.imgur.com/F1pJYM1.jpg"; Background.onload = function () {CTXoriginal.drawImage (background, 0, 0)} var imageData = CTXoriginal.getImageData (10, 10, 100, 100); CTXcopybitbit.ImageData (imageData, 0,0);   

Any indicators appreciated.

C

<

< P>

where S is source, and de destination is.

From there, you have to determine that click and drag to work co-ordinates and width / heights.

I updated your Bella to update it, it is very raw, so click somewhere in the upper left of the image, then click somewhere else at the bottom right.



Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -