mirror of
https://github.com/nasa/openmct.git
synced 2025-06-01 23:20:50 +00:00
[Service] ColorPalette is now ColorService
This commit is contained in:
parent
889a5c6ea9
commit
48f345a46b
@ -84,6 +84,13 @@
|
|||||||
"model": {"composition": []},
|
"model": {"composition": []},
|
||||||
"properties": []
|
"properties": []
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"services": [
|
||||||
|
{
|
||||||
|
"key": "colorService",
|
||||||
|
"implementation": "services/ColorService.js",
|
||||||
|
"description": "Provides objects for working with colors."
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,9 +108,8 @@ define(
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A color palette which returns colors from a predefined palette.
|
* A color palette stores a set of colors and allows for different
|
||||||
* When all colors in the palette have been allocated, it starts reusing
|
* methods of color allocation.
|
||||||
* colors.
|
|
||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
@ -122,15 +121,34 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @returns {Color} the next unused color in the palette. If all colors
|
||||||
* @return {Color} the next color in the palette.
|
* have been allocated, it will wrap around.
|
||||||
*/
|
*/
|
||||||
ColorPalette.prototype.getColor = function () {
|
ColorPalette.prototype.getNextColor = function () {
|
||||||
var color = this.colors[this.nextColor % this.colors.length];
|
var color = this.colors[this.nextColor % this.colors.length];
|
||||||
this.nextColor++;
|
this.nextColor++;
|
||||||
return color;
|
return color;
|
||||||
};
|
};
|
||||||
|
|
||||||
return ColorPalette;
|
/**
|
||||||
|
* @param {number} index the index of the color to return. An index
|
||||||
|
* value larger than the size of the index will wrap around.
|
||||||
|
* @returns {Color}
|
||||||
|
*/
|
||||||
|
ColorPalette.prototype.getColor = function (index) {
|
||||||
|
return this.colors[index % this.colors.length];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function ColorService() {}
|
||||||
|
|
||||||
|
ColorService.prototype.ColorPalette = ColorPalette;
|
||||||
|
ColorService.prototype.Color = Color;
|
||||||
|
|
||||||
|
function getColorService() {
|
||||||
|
return new ColorService();
|
||||||
|
}
|
||||||
|
|
||||||
|
return getColorService;
|
||||||
}
|
}
|
||||||
);
|
);
|
Loading…
x
Reference in New Issue
Block a user