I guess icon's height has to be 80% of rectangle's height. Actually I want to resize all my icons in artboard proportionally / keeping the aspect ratio. Let's say my rectangle should be 500x500px. My icon's height should be not more than 400px.
here's some pseudo code that may help..
var icon = the icon artwork
var background = the background square
var iconDimension,scale;
//get the largest dimension of the icon
if icon.width > icon.height
iconDimension = icon.width;
else
iconDimension = icon.height;
//get the scale percentage
if iconDimension < background.width
scale = (iconDimension / background.width) * 100
else
scale = (background.width / iconDimension) * 100
//get 80% of the scale
scale = scale*.8;
//resize the icon
icon.resize(scale,scale);
//make sure the icon is still centered in the background box
icon.left = (background.left + background.width/2) - icon.width/2
icon.top = (background.top - background.width/2) + icon.height/2