Use double underscores to avoid clashes between math operators and 'private' methods.

Path already defines a #_add() method...
This commit is contained in:
Jürg Lehni 2013-12-05 21:11:12 +01:00
parent 6d5e4329c1
commit ee7fd8cdbe

View file

@ -44,18 +44,18 @@ paper.PaperScope.prototype.PaperScript = (function(root) {
var binaryOperators = { var binaryOperators = {
// The hidden math functions are to be injected specifically, see below. // The hidden math functions are to be injected specifically, see below.
'+': '_add', '+': '__add',
'-': '_subtract', '-': '__subtract',
'*': '_multiply', '*': '__multiply',
'/': '_divide', '/': '__divide',
'%': '_modulo', '%': '__modulo',
// Use the real equals. // Use the real equals.
'==': 'equals', '==': 'equals',
'!=': 'equals' '!=': 'equals'
}; };
var unaryOperators = { var unaryOperators = {
'-': '_negate', '-': '__negate',
'+': null '+': null
}; };
@ -63,7 +63,9 @@ paper.PaperScope.prototype.PaperScript = (function(root) {
var fields = Base.each( var fields = Base.each(
['add', 'subtract', 'multiply', 'divide', 'modulo', 'negate'], ['add', 'subtract', 'multiply', 'divide', 'modulo', 'negate'],
function(name) { function(name) {
this['_' + name] = '#' + name; // Create an alias for ach math function to be injected into the
// classes using Straps.js' #inject()
this['__' + name] = '#' + name;
}, },
{} {}
); );