/**
* @function getShapeColor
* @summary
* Get the color of an existing shape (or '' if there is no Fill command on the shape)
*
* @param {Object} options
* @param {createjs.Shape} options.shape
* @returns {string} color or ''
*/
function getShapeColor (options) {
var msg = 'Must call getShapeColor with an options.shape'
if ((typeof options !== 'object') || !options.shape) {
console.error(msg)
return
}
if (!(options.shape instanceof window.createjs.Shape)) {
console.error(msg)
return
}
var fillCommands = options.shape.graphics.getInstructions().filter(
function (inst) {
return inst instanceof window.createjs.Graphics.Fill
}
)
if (fillCommands.length) {
return fillCommands.pop().style
} else {
return ''
}
}
window.$b = window.$b || {}
window.$b.snippets = window.$b.snippets || {}
var snippets = window.$b.snippets
snippets.getShapeColor = getShapeColor
if (window.module) {
window.module.exports = getShapeColor
}