Reputation: 1
I am implementing a draw app. I am trying to use paper.js to simplify lines and make them smooth. I am trying to use method from paper.js how to set up multiple canvases using only javascript. However, it seems not working for me. When I move to each canvas, I want to setup new "paper" so that I can draw stuff on that canvas.
Here are part of my codes:
var page = PDFViewerApplication.page;
var canvas = document.getElementById('annotation'+page);
if(canvas != null && canvas != undefined) {
if (pCanvas.indexOf(page) <= -1) { //make sure for each canvas only setup "paper" once
var mypaper = new paper.PaperScope();
mypaper.setup(canvas);
//paper.setup(canvas);
pCanvas.push(page);
if(mypapers[page] == undefined || mypapers[page] == null) {
mypapers[page] = mypaper;
}
}
}
//if(mypapers[page])
path = new mypapers[page].Path();
path.strokeColor = gcolor;
path.strokeWidth = gline;
path.strokeCap = 'round';
path.strokeJoin = 'round';
path.add(new paper.Point(window.lastMousex.x, window.lastMousex.y));
When mouseup I will use path.Simplify to smooth the line. Sorry about my poor English.
Upvotes: 0
Views: 346
Reputation: 1
I read a lot and finally found...
path.simplify();
//path.smooth();
mypapers[cpage].view.draw();
Use this when mouseup. Everything works fine now.
Upvotes: 0