mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-22 07:19:57 -05:00
Clean up last commit a bit.
This commit is contained in:
parent
0d173e39bf
commit
e0753179e3
1 changed files with 4 additions and 4 deletions
|
@ -20,8 +20,8 @@ var Color = this.Color = Base.extend(new function() {
|
|||
var context;
|
||||
return function(name) {
|
||||
var color = cachedColors[name];
|
||||
if(color === undefined) {
|
||||
if(!context) {
|
||||
if (color === undefined) {
|
||||
if (!context) {
|
||||
var canvas = CanvasProvider.getCanvas(Size.create(1, 1));
|
||||
context = canvas.getContext('2d');
|
||||
context.globalCompositeOperation = 'copy';
|
||||
|
@ -34,10 +34,10 @@ var Color = this.Color = Base.extend(new function() {
|
|||
context.restore();
|
||||
var components = context.getImageData(0, 0, 1, 1).data;
|
||||
var rgb = new Array(3);
|
||||
for(var i = 0; i < 3; i++)
|
||||
for (var i = 0; i < 3; i++)
|
||||
rgb[i] = components[i] / 255;
|
||||
// If the name wasn't found, rgb is [0, 0, 0]
|
||||
if((rgb.join('') == '000' && name != 'black')) {
|
||||
if ((rgb.join('') == '000' && name != 'black')) {
|
||||
throw new Error('The named color "' + name
|
||||
+ '" does not exist.');
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue