src/illustrator/swatches.js
function drawSwatchRect(top, left, width, height, name, color) {
  var layer = doc.layers[0];

  var rect = layer.pathItems.rectangle(top, left, width, height);
  rect.filled = true;
  rect.fillColor = color;
  rect.stroked = false;

  var textBounds = layer.pathItems.rectangle(top - height * config.swatchRect.textPosition, left + width * config.swatchRect.textPosition, width * (1 - config.swatchRect.textPosition * 2), height * (1 - config.swatchRect.textPosition * 2));
  var text = layer.textFrames.areaText(textBounds);
  text.contents = name + '\n' + colorToString(color);

  charStyles['swatchRectTitle'].applyTo(text.textRange);

  return rect;
}
function drawSwatchRect(top, left, width, height, name, color) {
  var layer = doc.layers[0];

  var rect = layer.pathItems.rectangle(top, left, width, height);
  rect.filled = true;
  rect.fillColor = color;
  rect.stroked = false;

  var textBounds = layer.pathItems.rectangle(top - height * config.swatchRect.textPosition, left + width * config.swatchRect.textPosition, width * (1 - config.swatchRect.textPosition * 2), height * (1 - config.swatchRect.textPosition * 2));
  var text = layer.textFrames.areaText(textBounds);
  text.contents = name + '\n' + colorToString(color);

  charStyles['swatchRectTitle'].applyTo(text.textRange);

  return rect;
}
function drawSwatchRect ( top , left , width , height , name , color ) { var layer = doc . layers [ 0 ] ; var rect = layer . pathItems . rectangle ( top , left , width , height ) ; rect . filled = true ; rect . fillColor = color ; rect . stroked = false ; var textBounds = layer . pathItems . rectangle ( top - height * config . swatchRect . textPosition , left + width * config . swatchRect . textPosition , width * ( 1 - config . swatchRect . textPosition * 2 ) , height * ( 1 - config . swatchRect . textPosition * 2 ) ) ; var text = layer . textFrames . areaText ( textBounds ) ; text . contents = name + '\n' + colorToString ( color ) ; charStyles [ 'swatchRectTitle' ] . applyTo ( text . textRange ) ; return rect ; }
Draws rectangle on artboard.

@param   {Number} top
@param   {Number} left
@param   {Number} width
@param   {Number} height
@param   {String} name
@param   {Color} color
@returns {PathItem}
Draws rectangle on artboard .