private string CompressStrokeLeg(int[] val)
{
StringBuilder sb = new StringBuilder();
char polarity = PLUS;
foreach (int num in val)
{
//Put the number into base30 format
List<int> cell = ToBase30(Math.Abs(num));
//If the polarity has changed, then we need to lay down a polarity indicator
char newpolarity;
if (num == 0) newpolarity = polarity; //Zero indicates no change in polarity
else newpolarity = (num >= 0) ? PLUS : MINUS;
if (newpolarity != polarity)
{
sb.Append(newpolarity);
polarity = newpolarity;
}
//Now convert into the jSignature Base30 compressed format
for (int i = 0; i < cell.Count; i++)
{
//The first "bitness" characters in the character set are used for the first member of the
//number representation. If the number representation has more than 1 character, the
//offset in the character set is shifted by "bitness"
int charsetoffset = (i > 0) ? bitness : 0;
sb.Append(ALLCHARS[cell[i] + charsetoffset]);
}
}
return sb.ToString();
}