Open puckey opened 5 years ago
Another approach would be to limit the used colors in the spec & sandcastle demos to a smaller set of 16 instead of 147.
Color.js in Cesium is an helper but yes , it grows the lib . It can be a good idea to use Color.js as an addon.
Is the use of the canvas not problematic for performance ?
Performance is ok.. But I would go for keeping a small subset of this huge list.
I noticed 147 named static colors located in
Core/Color.js
. Removing them saved 9,71kb minified in bundle size.Aside from one or two uses in the core library, they seem to only be used in sandcastle examples and specs, leading me to believe they could do with being extracted or adapted.
An adaption could be to extend
Color.fromCssColorString('string')
to also accept color names: instead of usingColor.PINK
we could haveColor.fromCssColorString('pink')
.In
Color.fromCssColorString
you could get the color through a canvas object and cache it by name. We did this inPaper.js
and it works well: https://github.com/paperjs/paper.js/blob/e5d7bafd39db546e6c78bdbd89212c1685e05e1b/src/style/Color.js#L111Color.fromCssColorString
could also be shortened toColor.fromCss
..