var film2d = use('film2d')

var sprite_proto = {
  type: 'sprite',
  
  destroy: function() {
    film2d.unregister(this._id)
  }
}

return function(props) {
  var defaults = {
    type: 'sprite',
    pos: {x: 0, y: 0},
    image: null,
    width: 1,
    height: null,
    fit: 'contain',
    fit_anchor_x: 0.5,
    fit_anchor_y: 0.5,
    anchor_x: 0,
    anchor_y: 0,
    flip: {x: false, y: false},
    rotation: 0,
    color: {r: 1, g: 1, b: 1, a: 1},
    opacity: 1,
    tint: {r: 1, g: 1, b: 1, a: 1},
    filter: 'nearest',
    uv: {offset: {x: 0, y: 0}, scale: {x: 1, y: 1}, rotate: 0},
    plane: 'default',
    layer: 0,
    groups: [],
    visible: true
  }

  var data = object(defaults, props)
  
  // Ensure groups is array
  if (!data.groups) data.groups = []
  if (is_text(data.groups)) data.groups = [data.groups]

  var s = meme(sprite_proto, data)
  film2d.register(s)
  return s
}