paper.js/src/path/SegmentPoint.js

57 lines
1,014 B
JavaScript
Raw Normal View History

2011-04-21 08:21:56 -04:00
/**
* An internal version of Point that notifies its segment of each change
* Note: This prototype is not exported.
*/
var SegmentPoint = Point.extend({
beans: true,
set: function(x, y) {
this._x = x;
this._y = y;
this._segment._changed(this);
2011-04-21 08:21:56 -04:00
return this;
},
getX: function() {
return this._x;
},
setX: function(x) {
this._x = x;
this._segment._changed(this);
2011-04-21 08:21:56 -04:00
},
getY: function() {
return this._y;
},
setY: function(y) {
this._y = y;
this._segment._changed(this);
2011-04-21 08:21:56 -04:00
},
2011-04-21 12:06:06 -04:00
setSelected: function(selected) {
this._segment._setSelected(this, selected);
2011-04-21 12:06:06 -04:00
},
isSelected: function() {
return this._segment._isSelected(this);
2011-04-21 12:06:06 -04:00
},
2011-04-21 08:21:56 -04:00
statics: {
create: function(segment, x, y) {
if (y === undefined) {
// Use the normal point constructor to read in point values
var tmp = new Point(x);
x = tmp.x;
y = tmp.y;
2011-04-21 08:21:56 -04:00
}
var point = new SegmentPoint(SegmentPoint.dont);
point._x = x;
point._y = y;
2011-04-21 08:21:56 -04:00
point._segment = segment;
return point;
}
}
});