Source: change-shape-color.js

/**
 * @function changeShapeColor
 * @summary
 * Change the color of an existing shape.
 *
 * @param {Object} options
 * @param {createjs.Shape} options.shape
 * @param {string} options.color HexColor string (ex. '#FF0000') or WebColor (ex. 'teal')
 */
function changeShapeColor (options) {
  var msg = 'Must call changeShapeColor with options.shape and options.color'
  if ((typeof options !== 'object') || !options.shape || !options.color) {
    console.error(msg)
    return
  }
  var shape = options.shape
  if (!(shape instanceof window.createjs.Shape)) {
    console.error(msg)
    return
  }
  var fillCommands = shape.graphics.instructions.filter(
    function (inst) {
      return inst instanceof window.createjs.Graphics.Fill
    }
  )
  fillCommands.forEach(function (cmd) {
    cmd.style = options.color
  })
}

window.$b = window.$b || {}
window.$b.snippets = window.$b.snippets || {}
var snippets = window.$b.snippets
snippets.changeShapeColor = changeShapeColor

if (window.module) {
  window.module.exports = changeShapeColor
}