Image which is drawn on canvas, disappears when i try to draw a path on canvas

493 views
Skip to first unread message

Rishi Khandelwal

unread,
Jul 16, 2014, 2:49:58 AM7/16/14
to pap...@googlegroups.com
Hello,

I tried to draw a path on a canvas. That canvas has a image drawn already . As i press mouse to draw a path, that image disappears.

I am not getting the way, how to do this ??

My scenario : image drawn on canvas , then i want to draw paths over the canvas.

Thank You

Sergey

unread,
Jul 25, 2014, 6:39:42 AM7/25/14
to pap...@googlegroups.com
Look this code, it work's.

paper.install(window);
paper.setup('draw');
var tool = new Tool();
    
tool.minDistance = 10;
    
var backgroundImg = new Raster({
            source: 'images/myBackImg.jpg',
            position: view.center
        });

var path;

tool.onMouseDown = function(event) {
// Create a new path and give it a stroke color:
path = new Path();
path.strokeColor = '#00000';

// Add a segment to the path where
// you clicked:
path.add(event.point);
}

tool.onMouseDrag = function(event) {
// Every drag event, add a segment
// to the path at the position of the mouse:
path.add(event.point);
}          

среда, 16 июля 2014 г., 10:49:58 UTC+4 пользователь Rishi Khandelwal написал:

Jürg Lehni

unread,
Jul 25, 2014, 9:55:11 AM7/25/14
to pap...@googlegroups.com
Sounds like you're drawing directly to the canvas, using the Canvas API?

Paper.js will regularly clear the canvas, so you will loose things you're drawing outside of the Paper.js APi.

--
You received this message because you are subscribed to the Google Groups "Paper.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to paperjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages