private Gradient ReadGradient(SWFDataTypeReader shapeReader, Tag format)
{
GradientSpread spread = (GradientSpread)shapeReader.ReadUBits(2);
GradientInterpolation interp = (GradientInterpolation)shapeReader.ReadUBits(2);
int numRecs = (int)shapeReader.ReadUBits(4);
GradientRecord[] recs = new GradientRecord[numRecs];
for (int i = 0; i < recs.Length; i++)
{
GradientRecord rec = new GradientRecord();
rec.Ratio = shapeReader.ReadUI8();
if (format == Tag.DefineShape || format == Tag.DefineShape2)
{
rec.Colour = shapeReader.ReadRGB();
}
else if (format == Tag.DefineShape3 || format == Tag.DefineShape4)
{
rec.Colour = shapeReader.ReadRGBA();
}
else
{
throw new SWFModellerException(SWFModellerError.Internal, "Can't read gradient in shape format " + format.ToString());
}
recs[i] = rec;
}
return new Gradient()
{
Records = recs,
Interpolation = interp,
Spread = spread
};
}