paper.js/src/path/SegmentPoint.js

78 lines
1.5 KiB
JavaScript
Raw Normal View History

2011-05-08 04:59:37 -04:00
/*
* Paper.js
*
* This file is part of Paper.js, a JavaScript Vector Graphics Library,
* based on Scriptographer.org and designed to be largely API compatible.
* http://paperjs.org/
* http://scriptographer.org/
*
* Distributed under the MIT license. See LICENSE file for details.
*
* Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
* http://lehni.org/ & http://jonathanpuckey.com/
*
* All rights reserved.
*/
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.
2011-05-22 22:20:11 -04:00
*
2011-05-22 22:18:21 -04:00
* @ignore
2011-04-21 08:21:56 -04:00
*/
var SegmentPoint = Point.extend({
beans: true,
set: function(x, y) {
this._x = x;
this._y = y;
this._owner._changed(this);
2011-04-21 08:21:56 -04:00
return this;
},
getX: function() {
return this._x;
},
setX: function(x) {
this._x = x;
this._owner._changed(this);
2011-04-21 08:21:56 -04:00
},
getY: function() {
return this._y;
},
setY: function(y) {
this._y = y;
this._owner._changed(this);
2011-04-21 08:21:56 -04:00
},
2011-04-21 12:06:06 -04:00
setSelected: function(selected) {
this._owner._setSelected(this, selected);
2011-04-21 12:06:06 -04:00
},
isSelected: function() {
return this._owner._isSelected(this);
2011-04-21 12:06:06 -04:00
},
2011-04-21 08:21:56 -04:00
statics: {
create: function(segment, x, y, selected) {
if (y === undefined) {
// Use the normal point constructor to read in point values
var pt = x instanceof Point ? x : new Point(x);
x = pt.x;
y = pt.y;
selected = pt.selected;
2011-04-21 08:21:56 -04:00
}
var point = new SegmentPoint(SegmentPoint.dont);
point._x = x;
point._y = y;
point._owner = segment;
if (selected)
point.setSelected(true);
2011-04-21 08:21:56 -04:00
return point;
}
}
});