Add a method to Path.Circle objects

43 views
Skip to first unread message

Endash

unread,
Jan 27, 2012, 10:44:46 PM1/27/12
to Paper.js
Hi,

I am using paperjs directly with javacript.

I can't find any documentation showing how to prototype a new method.

The code below returns an error: >>> pointer.display is not a
function

/*************************************************************/

window.onload = function(){

// Get a reference to the canvas object
var canvas = document.getElementById('myCanvas');

// Create an empty project and a view for the canvas:
paper.setup(canvas);

// Create the event handler
var tool = new paper.Tool();

// Create pointer
var pointer = new paper.Path.Circle(new paper.Point(-300, 0), 20);

// Set the display
pointer.display(5);

// Define display() method
PaperScope.Path.Circle.prototype.display = function(strokeWidth) {
this.strokeWidth = strokeWidth;
this.strokeColor = 'blue';
}

// Add listener
tool.onMouseMove = function(event) { pointer.position =
event.point; }

// Draw the view now:
paper.view.draw();
}


/*************************************************************/

Can anyone help me ?

Endash

unread,
Jan 27, 2012, 11:57:45 PM1/27/12
to Paper.js
Reply all
Reply to author
Forward
0 new messages