mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
More uppercase changes.
This commit is contained in:
parent
96d9b6730f
commit
6029f59494
3 changed files with 12 additions and 11 deletions
|
@ -54,7 +54,7 @@ var Color = this.Color = Base.extend(new function() {
|
||||||
colorCache = {},
|
colorCache = {},
|
||||||
colorCtx;
|
colorCtx;
|
||||||
|
|
||||||
function nameToRgb(name) {
|
function nameToRGB(name) {
|
||||||
var cached = colorCache[name];
|
var cached = colorCache[name];
|
||||||
if (!cached) {
|
if (!cached) {
|
||||||
// Use a canvas to draw to with the given name and then retrieve rgb
|
// Use a canvas to draw to with the given name and then retrieve rgb
|
||||||
|
@ -81,7 +81,7 @@ var Color = this.Color = Base.extend(new function() {
|
||||||
return cached.slice();
|
return cached.slice();
|
||||||
}
|
}
|
||||||
|
|
||||||
function hexToRgb(string) {
|
function hexToRGB(string) {
|
||||||
var hex = string.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
|
var hex = string.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
|
||||||
if (hex.length >= 4) {
|
if (hex.length >= 4) {
|
||||||
var components = [0, 0, 0];
|
var components = [0, 0, 0];
|
||||||
|
@ -499,8 +499,8 @@ var Color = this.Color = Base.extend(new function() {
|
||||||
values = slice.call(values, 0, length);
|
values = slice.call(values, 0, length);
|
||||||
} else if (argType === 'string') {
|
} else if (argType === 'string') {
|
||||||
components = arg.match(/^#[0-9a-f]{3,6}$/i)
|
components = arg.match(/^#[0-9a-f]{3,6}$/i)
|
||||||
? hexToRgb(arg)
|
? hexToRGB(arg)
|
||||||
: nameToRgb(arg);
|
: nameToRGB(arg);
|
||||||
type = 'rgb';
|
type = 'rgb';
|
||||||
} else if (argType === 'object') {
|
} else if (argType === 'object') {
|
||||||
if (arg._class === 'Color') {
|
if (arg._class === 'Color') {
|
||||||
|
@ -1028,10 +1028,10 @@ var Color = this.Color = Base.extend(new function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Expose RgbColor, RGBColor, etc. constructors for backward compatibility.
|
// Expose Color.RGB, etc. constructors, as well as RgbColor, RGBColor, etc.for
|
||||||
|
// backward compatibility.
|
||||||
Base.each(Color._types, function(properties, type) {
|
Base.each(Color._types, function(properties, type) {
|
||||||
var ctor = this[Base.capitalize(type) + 'Color'] =
|
var ctor = this[Base.capitalize(type) + 'Color'] = function(arg) {
|
||||||
function(arg) {
|
|
||||||
var argType = arg != null && typeof arg,
|
var argType = arg != null && typeof arg,
|
||||||
components = argType === 'object' && arg.length != null
|
components = argType === 'object' && arg.length != null
|
||||||
? arg
|
? arg
|
||||||
|
@ -1042,6 +1042,8 @@ Base.each(Color._types, function(properties, type) {
|
||||||
? new Color(type, components)
|
? new Color(type, components)
|
||||||
: new Color(arg);
|
: new Color(arg);
|
||||||
};
|
};
|
||||||
if (type.length == 3)
|
if (type.length == 3) {
|
||||||
this[type.toUpperCase() + 'Color'] = ctor;
|
var acronym = type.toUpperCase();
|
||||||
|
Color[acronym] = this[acronym + 'Color'] = ctor;
|
||||||
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
|
@ -65,7 +65,7 @@ test('Creating Colors', function() {
|
||||||
new Color(1, 0, 0).convert('hsb'), 'Color from hsb object literal');
|
new Color(1, 0, 0).convert('hsb'), 'Color from hsb object literal');
|
||||||
|
|
||||||
compareColors(new Color([1, 0, 0]), new Color(1, 0, 0),
|
compareColors(new Color([1, 0, 0]), new Color(1, 0, 0),
|
||||||
'Rgb Color from array');
|
'RGB Color from array');
|
||||||
|
|
||||||
compareColors(new Color([1]), new Color(1),
|
compareColors(new Color([1]), new Color(1),
|
||||||
'Gray Color from array');
|
'Gray Color from array');
|
||||||
|
|
|
@ -55,7 +55,6 @@ test('Path#clone() with gradient Color', function() {
|
||||||
var colors = ['red', 'green', 'black'];
|
var colors = ['red', 'green', 'black'];
|
||||||
var gradient = new Gradient(colors, true);
|
var gradient = new Gradient(colors, true);
|
||||||
var color = new Color(gradient, [0, 0], [20, 20], [10, 10]);
|
var color = new Color(gradient, [0, 0], [20, 20], [10, 10]);
|
||||||
|
|
||||||
var path = new Path([10, 20], [30, 40]);
|
var path = new Path([10, 20], [30, 40]);
|
||||||
path.fillColor = color;
|
path.fillColor = color;
|
||||||
cloneAndCompare(path);
|
cloneAndCompare(path);
|
||||||
|
|
Loading…
Reference in a new issue