2013-03-12 2 views
0

캔버스의 내용을 지워야합니다. 'globalCompositeOperation = "destination-out"을 사용하여이 작업을 수행 할 수 있습니다. 내 json 객체에 이미 좌표를 저장했으나 지우는 후에 json 객체를 업데이트해야합니다. 나는 그것을 잡으려고 노력했다. x, y는 마우스를 움직일 때 좌표를 지운다. 그런 다음 이전 상점 개체와 동일한 항목을 일치시키고 업데이트했습니다. 그러나 그것은 나의 성능 저하를 야기하는 큰 과정입니다. 그것을 할 다른 방법이 있습니까?캔버스에서 기능 지우기

+0

코드를 게시하시기 바랍니다. 바람직하게는 당신이 JSFiddle.net – Jodes

+0

this.mousedown =에 무슨 짓을했는지 보여 기능 (이벤트) { \t을 console.log ("mousedown") \t ER.test3 = ER.currentScaleValue; \t \t VAR 캔버스 = $ (event.target) \t \t tool.context = event.target.getContext ('2d'); \t \t tool.context.beginPath(); \t tool.context.moveTo (event._x, event._y); \t tool.obj = new Object(); \t tool.obj.x = event._x; \t tool.obj.y = event._y; \t \t tool.obj.z = ER.currentScaleValue; \t tool.currentCollection.push (tool.obj); \t tool.started = true; \t false를 반환합니다. \t}; – user2123421

+0

this.mousemove = function (이벤트) { \t if (tool.started) { \t \t tool.context.lineTo (event._x, event._y); \t \t tool.context.strokeStyle = 'red'; \t tool.context.stroke(); \t \t tool.obj = new Object(); \t tool.obj.x = event._x; \t tool.obj.y = event._y; \t \t tool.obj.z = ER.currentScaleValue; \t tool.currentCollection.push (tool.obj); \t \t} \t false; \t}; – user2123421

답변

0

이렇게하면 캔버스의 모든 내용이 지워집니다. (즉, CTX를 가정하면 상황이며, 폭과 높이가 캔버스의 폭과 높이입니다.

ctx.clearRect(0, 0, width, height)