/// <summary> /// Reads RGBA gradient from the reader. /// </summary> /// <param name="reader">The reader from which to read gradient.</param> /// <returns></returns> public static GradientRGBA ReadGradientRGBA(this ISwfStreamReader reader) { var gradient = new GradientRGBA { SpreadMode = (SpreadMode)reader.ReadUnsignedBits(2), InterpolationMode = (InterpolationMode)reader.ReadUnsignedBits(2) }; var count = reader.ReadUnsignedBits(4); for (var i = 0; i < count; i++) { GradientRecordRGBA record = reader.ReadGradientRecordRGBA(); gradient.GradientRecords.Add(record); } return(gradient); }
public static void WriteGradientRGBA(this ISwfStreamWriter writer, GradientRGBA gradient) { writer.WriteUnsignedBits((uint)gradient.SpreadMode, 2); writer.WriteUnsignedBits((uint)gradient.InterpolationMode, 2); var count = gradient.GradientRecords.Count; if (count > 15) { throw new ArgumentOutOfRangeException("gradient", "Can't serialize more them 15 gradient points"); } writer.WriteUnsignedBits((uint)count, 4); for (var i = 0; i < count; i++) { var record = gradient.GradientRecords[i]; writer.WriteGradientRecordRGBA(ref record); } }
public static void AreEqual(GradientRGBA expected, GradientRGBA actual, string message) { AreEqualBase(expected, actual, message); }
/// <summary> /// Reads RGBA gradient from the reader. /// </summary> /// <param name="reader">The reader from which to read gradient.</param> /// <returns></returns> public static GradientRGBA ReadGradientRGBA(this ISwfStreamReader reader) { var gradient = new GradientRGBA { SpreadMode = (SpreadMode)reader.ReadUnsignedBits(2), InterpolationMode = (InterpolationMode)reader.ReadUnsignedBits(2) }; var count = reader.ReadUnsignedBits(4); for (var i = 0; i < count; i++) { GradientRecordRGBA record = reader.ReadGradientRecordRGBA(); gradient.GradientRecords.Add(record); } return gradient; }
public static void WriteGradientRGBA(this ISwfStreamWriter writer, GradientRGBA gradient) { writer.WriteUnsignedBits((uint)gradient.SpreadMode, 2); writer.WriteUnsignedBits((uint)gradient.InterpolationMode, 2); var count = gradient.GradientRecords.Count; if (count > 15) throw new ArgumentOutOfRangeException("gradient", "Can't serialize more them 15 gradient points"); writer.WriteUnsignedBits((uint)count, 4); for (var i = 0; i < count; i++) { var record = gradient.GradientRecords[i]; writer.WriteGradientRecordRGBA(ref record); } }