mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Add definition of Base.capitalize() and remove dependencies of String#capitalize().
This commit is contained in:
parent
702899b382
commit
93c3920505
3 changed files with 12 additions and 6 deletions
|
@ -79,10 +79,10 @@ var GrayColor = this.GrayColor = Color.extend({
|
||||||
};
|
};
|
||||||
|
|
||||||
Base.each(componentWeights, function(weight, key) {
|
Base.each(componentWeights, function(weight, key) {
|
||||||
fields['get' + key.capitalize()] = function() {
|
fields['get' + Base.capitalize(key)] = function() {
|
||||||
return 1 - this._gray;
|
return 1 - this._gray;
|
||||||
};
|
};
|
||||||
fields['set' + key.capitalize()] = function(value) {
|
fields['set' + Base.capitalize(key)] = function(value) {
|
||||||
this._cssString = null;
|
this._cssString = null;
|
||||||
this._gray = this._gray * (1 - weight) + weight * (1 - value);
|
this._gray = this._gray * (1 - weight) + weight * (1 - value);
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,7 +21,7 @@ var PathStyle = this.PathStyle = Base.extend(new function() {
|
||||||
Item.inject(Base.each(keys, function(key) {
|
Item.inject(Base.each(keys, function(key) {
|
||||||
|
|
||||||
var isColor = !!(key.match(/Color$/));
|
var isColor = !!(key.match(/Color$/));
|
||||||
fields['set' + key.capitalize()] = function(value) {
|
fields['set' + Base.capitalize(key)] = function(value) {
|
||||||
if (this.item && this.item.children) {
|
if (this.item && this.item.children) {
|
||||||
for (var i = 0, l = this.item.children.length; i < l; i++) {
|
for (var i = 0, l = this.item.children.length; i < l; i++) {
|
||||||
this.item.children[i].style[key] = value;
|
this.item.children[i].style[key] = value;
|
||||||
|
@ -31,7 +31,7 @@ var PathStyle = this.PathStyle = Base.extend(new function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fields['get' + key.capitalize()] = function() {
|
fields['get' + Base.capitalize(key)] = function() {
|
||||||
if (this.item && this.item.children) {
|
if (this.item && this.item.children) {
|
||||||
var style;
|
var style;
|
||||||
for (var i = 0, l = this.item.children.length; i < l; i++) {
|
for (var i = 0, l = this.item.children.length; i < l; i++) {
|
||||||
|
@ -50,11 +50,11 @@ var PathStyle = this.PathStyle = Base.extend(new function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this['set' + key.capitalize()] = function(value) {
|
this['set' + Base.capitalize(key)] = function(value) {
|
||||||
this.style[key] = value;
|
this.style[key] = value;
|
||||||
};
|
};
|
||||||
|
|
||||||
this['get' + key.capitalize()] = function() {
|
this['get' + Base.capitalize(key)] = function() {
|
||||||
return this.style[key];
|
return this.style[key];
|
||||||
};
|
};
|
||||||
}, { beans: true }));
|
}, { beans: true }));
|
||||||
|
|
|
@ -9,6 +9,12 @@ var paper = new function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Base.capitalize = function(str) {
|
||||||
|
return str.replace(/\b[a-z]/g, function(match) {
|
||||||
|
return match.toUpperCase();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
//#include "basic/Point.js"
|
//#include "basic/Point.js"
|
||||||
//#include "basic/Size.js"
|
//#include "basic/Size.js"
|
||||||
//#include "basic/Rectangle.js"
|
//#include "basic/Rectangle.js"
|
||||||
|
|
Loading…
Reference in a new issue