Example #1
0
        /// <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);
        }
Example #2
0
        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);
            }
        }
Example #3
0
 public static void AreEqual(GradientRGBA expected, GradientRGBA actual, string message)
 {
     AreEqualBase(expected, actual, message);
 }
Example #4
0
 /// <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;
 }
Example #5
0
 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);
     }
 }
Example #6
0
 public static void AreEqual(GradientRGBA expected, GradientRGBA actual, string message)
 {
     AreEqualBase(expected, actual, message);
 }