StyleChangeRecord is used to change the drawing environment when a shape is drawn.

Three operations can be performed:

  • Select a line style or fill style.
  • Move the current drawing point.
  • Define a new set of line and fill styles.

An StyleChangeRecord object can specify one or more of the operations rather than specifying them in separate StyleChangeRecord objects - compacting the size of the binary data when the object is encoded. Conversely if an operation is not defined then the values may be omitted.

A new drawing point is specified using the absolute x and y coordinates. If an StyleChangeRecord object is the first in a shape then the current drawing point is the origin of the shape (0,0).

New fill and line styles can be added to the StyleChangeRecord object to change the way shapes are drawn.

This was introduced in Flash 1.

Inheritance: NonEdgeRecord
        /// <summary>
        /// Reads the data.
        /// </summary>
        /// <param name="binaryReader">Binary reader.</param>
        /// <param name="shapeType">Shape type.</param>
        public void ReadData(BufferedBinaryReader binaryReader, ShapeType shapeType)
        {
            binaryReader.SynchBits();
            byte numFillBits = (byte)binaryReader.ReadUBits(4);
            byte numLineBits = (byte)binaryReader.ReadUBits(4);

            bool readEndShapeRecord = false;

            while (!readEndShapeRecord)
            {
                bool type  = binaryReader.ReadBoolean();
                byte flags = (byte)binaryReader.ReadUBits(5);

                if (type == false)
                {
                    //Non-edge record
                    if (flags == 0)
                    {
                        //EndShapeRecord
                        readEndShapeRecord = true;
                        this.Add(new EndShapeRecord());
                    }
                    else
                    {
                        //StyleChangerecord
                        StyleChangeRecord styleChange = new StyleChangeRecord();
                        styleChange.ReadData(binaryReader, flags, ref numFillBits, ref numLineBits, shapeType);
                        this.Add(styleChange);
                    }
                }
                else
                {
                    //Edge record
                    if ((flags & 0x10) != 0)
                    {
                        //StraightedEdgeRecord
                        StraightEdgeRecord straight = new StraightEdgeRecord();
                        straight.ReadData(binaryReader, flags);
                        this.Add(straight);
                    }
                    else
                    {
                        //CurvedEdgeRecord
                        CurvedEdgeRecord curved = new CurvedEdgeRecord();
                        curved.ReadData(binaryReader, flags);
                        this.Add(curved);
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Reads the data.
        /// </summary>
        /// <param name="binaryReader">Binary reader.</param>
        /// <param name="shapeType">Shape type.</param>
        public void ReadData(BufferedBinaryReader binaryReader, ShapeType shapeType)
        {
            binaryReader.SynchBits();
            byte numFillBits = (byte)binaryReader.ReadUBits(4);
            byte numLineBits = (byte)binaryReader.ReadUBits(4);

            bool readEndShapeRecord = false;
            while (!readEndShapeRecord)
            {
                bool type = binaryReader.ReadBoolean();
                byte flags = (byte)binaryReader.ReadUBits(5);

                if (type == false)
                {
                    //Non-edge record
                    if (flags == 0)
                    {
                        //EndShapeRecord
                        readEndShapeRecord = true;
                        this.Add(new EndShapeRecord());
                        if (log.IsInfoEnabled)
                            log.Info("Shape: EndShapeRecord");
                    }
                    else
                    {
                        //StyleChangerecord
                        StyleChangeRecord styleChange = new StyleChangeRecord();
                        styleChange.ReadData(binaryReader, flags, ref numFillBits, ref numLineBits, shapeType);
                        this.Add(styleChange);
                        if (log.IsInfoEnabled)
                            log.Info("Shape: StyleChangeRecord");
                    }
                }
                else
                {
                    //Edge record
                    if ((flags & 0x10) != 0)
                    {
                        //StraightedEdgeRecord
                        StraightEdgeRecord straight = new StraightEdgeRecord();
                        straight.ReadData(binaryReader, flags);
                        this.Add(straight);
                        if (log.IsInfoEnabled)
                            log.Info("Shape: StraightedEdgeRecord");
                    }
                    else
                    {
                        //CurvedEdgeRecord
                        CurvedEdgeRecord curved = new CurvedEdgeRecord();
                        curved.ReadData(binaryReader, flags);
                        this.Add(curved);
                        if (log.IsInfoEnabled)
                            log.Info("Shape: CurvedEdgeRecord");
                    }
                }
            }
        }