예제 #1
0
        public void ToSwf(SwfWriter w, ShapeType shapeType)
        {
            FillStyles.ToSwf(w, shapeType);
            LineStyles.ToSwf(w, shapeType);

            w.Align();
            uint fillBits = SwfWriter.MinimumBits((uint)FillStyles.FillStyles.Count);
            uint lineBits = SwfWriter.MinimumBits((uint)LineStyles.LineStyles.Count);

            w.AppendBits(fillBits, 4);
            w.AppendBits(lineBits, 4);
            w.Align();

            for (int i = 0; i < ShapeRecords.Count; i++)
            {
                ShapeRecords[i].ToSwf(w, ref fillBits, ref lineBits, shapeType);
            }
        }
예제 #2
0
        public void ToSwf(SwfWriter w, ref uint fillBits, ref uint lineBits, ShapeType shapeType)
        {
            // TypeFlag				UB[1]	Non-edge record flag. Always 0.
            // StateNewStyles		UB[1]	New styles flag. Used by DefineShape2 and DefineShape3 only.
            // StateLineStyle		UB[1]	Line style change flag.
            // StateFillStyle1		UB[1]	Fill style 1 change flag.
            // StateFillStyle0		UB[1]	Fill style 0 change flag.
            // StateMoveTo			UB[1]	Move to flag.

            if (shapeType == ShapeType.Glyph)
            {
                w.AppendBit(false);
                w.AppendBit(false);   //this.HasNewStyles);

                w.AppendBit(false);   //HasLineStyle);
                w.AppendBit(false);   //HasFillStyle1);
                w.AppendBit(HasFillStyle0);
                w.AppendBit(HasMove); //HasMove);

                if (HasMove)
                {
                    // not relative moves
                    uint bits = SwfWriter.MinimumBits(this.MoveDeltaX, this.MoveDeltaY);
                    w.AppendBits(bits, 5);
                    w.AppendSignedNBits(this.MoveDeltaX, bits);
                    w.AppendSignedNBits(this.MoveDeltaY, bits);
                }

                if (HasFillStyle0)
                {
                    w.AppendBits(this.FillStyle0, fillBits);
                }
            }
            else
            {
                w.AppendBit(false);
                w.AppendBit(this.HasNewStyles);

                w.AppendBit(HasLineStyle);
                w.AppendBit(HasFillStyle1);
                w.AppendBit(HasFillStyle0);
                w.AppendBit(HasMove);

                if (HasMove)
                {
                    uint bits = SwfWriter.MinimumBits(this.MoveDeltaX, this.MoveDeltaY);
                    w.AppendBits(bits, 5);
                    w.AppendSignedNBits(this.MoveDeltaX, bits);
                    w.AppendSignedNBits(this.MoveDeltaY, bits);
                }

                if (HasFillStyle0)
                {
                    w.AppendBits(this.FillStyle0, fillBits);
                }

                if (HasFillStyle1)
                {
                    w.AppendBits(this.FillStyle1, fillBits);
                }

                if (HasLineStyle)
                {
                    w.AppendBits(this.LineStyle, lineBits);
                }

                if (HasNewStyles)
                {
                    w.Align();
                    FillStyles.ToSwf(w, shapeType);
                    LineStyles.ToSwf(w, shapeType);

                    fillBits = SwfWriter.MinimumBits((uint)FillStyles.FillStyles.Count);
                    lineBits = SwfWriter.MinimumBits((uint)LineStyles.LineStyles.Count);;

                    w.AppendBits(fillBits, 4);
                    w.AppendBits(lineBits, 4);
                }
            }
        }