Sub ScaleToSize(fSize As Float, bAdjDensity As Boolean, nsX As Long, nsY As Long)
Dim rate, slopeA, slopeB, scale, newsize, sd, d, ds As Float
If nsX > nsY Then
slopeA = Sqrt(Power(270,2) + Power(480,2))
Else
slopeA = Sqrt(Power(455,2) + Power(320,2))
End If
slopeB = (Sqrt(Power(100%Y,2) + Power(100%X,2)))
scale = slopeB - slopeA
rate = slopeA / fSize
newsize = (scale / rate) + fSize
d = 1
sd = Density
ds = d/sd
If bAdjDensity Then
Return newsize * ds
Else
Return newsize
End If
End Sub