 Canvas = require 'art-canvas'
 Base = require './base'
 {PointLayout, PointLayoutBase} = require '../layout'
-{log, isPlainObject, min, max, createWithPostCreate, isNumber} = Foundation
+{log, isPlainObject, min, max, createWithPostCreate, isNumber, merge} = Foundation
 {color, Color, point, Point, rect, Rectangle, matrix, Matrix, point0, point1} = Atomic
 {GradientFillStyle} = Canvas
 # can be a gradient fill or a solid-color fill


  _prepareDrawOptions: (drawOptions, compositeMode, opacity)->
    super
    {_shadow, _colors} = @
    drawOptions.shadow = _shadow

    drawOptions.colors = null
    drawOptions.gradientRadius1 = null
    drawOptions.gradientRadius2 = null
    drawOptions.from = null
    drawOptions.to = null

    if _colors
      {_from, _to, _gradientRadius, _currentSize} = @
      _from ||= defaultFrom

      drawOptions.colors = _colors

    shadow:
      default: null
      validate: (v) -> !v || isPlainObject v
      preprocess: (v) ->
        if (offset = v?.offset) && !(offset instanceof PointLayoutBase)
          merge v, offset: new PointLayout offset
        else
          v

  _expandRectangleByShadow: _expandRectangleByShadow = (r, shadow) ->
    return r unless shadow
