示例#1
0
        //        public ColorMatrix ReadColorMatrixWithAlpha()
        //        {
        //            ColorMatrix cmatrix = new ColorMatrix();
        //            bool bHasAddTerms = this.ReadBoolean();
        //            bool bHasMultTerms = this.ReadBoolean();
        //            int nNumBits = (int)this.ReadBits(4);
        //
        //            if (bHasMultTerms)
        //            {
        //                this.ReadBitArray(4, nNumBits, false); //TODO: signed?
        //                //cmatrix. Multiply clr.Red etc...
        //            }
        //            if (bHasAddTerms)
        //            {
        //                this.ReadBitArray(4, nNumBits, false);
        //                //cmatrix. Add clr.Red etc...
        //            }
        //
        //            this.JumpToNextByteStart();
        //
        //            return cmatrix;
        //        }
        //        public ColorMatrix ReadColorMatrix()
        //        {
        //            ColorMatrix cmatrix = new ColorMatrix();
        //            bool bHasAddTerms = this.ReadBoolean();
        //            bool bHasMultTerms = this.ReadBoolean();
        //            int nNumBits = (int)this.ReadBits(4);
        //
        //            if (bHasMultTerms)
        //            {
        //                this.ReadBitArray(3, nNumBits, false); //TODO: signed?
        //                //cmatrix. Multiply clr.Red etc...
        //            }
        //            if (bHasAddTerms)
        //            {
        //                this.ReadBitArray(3, nNumBits, false);
        //                //cmatrix. Add clr.Red etc...
        //            }
        //
        //            this.JumpToNextByteStart();
        //
        //            return cmatrix;
        //        }
        public ArrayList ReadFillStyleArray(bool bWithAlpha, bool bExtended, bool morph)
        {
            ArrayList styles = new ArrayList();

            this.JumpToNextByteStart();
            int nFillStyleCount = this.ReadByte();
            if (nFillStyleCount == 255 && bExtended)
                nFillStyleCount = this.ReadUInt16();

            for (int i = 0; i < nFillStyleCount; i++)
            {
                Style.FillStyle style = new Style.FillStyle(this, bWithAlpha, morph);
                styles.Add(style);
            }
            return styles;
        }
示例#2
0
        public ArrayList CreateMorphedShape(float ratio)
        {
            ArrayList morphedCommands = new ArrayList();
            int       targetIndex     = -1;
            EPoint    ptCurrent       = new EPoint();

            foreach (ShapeCommand.Base cmd in this.CommandList)
            {
                if (!(cmd is ShapeCommand.Style))
                {
                    targetIndex++;
                }

                ShapeCommand.Base cmdTo = (ShapeCommand.Base) this._morphCommandList[targetIndex];

                if (cmd is ShapeCommand.Move)
                {
                    EPoint pt1 = ((ShapeCommand.Move)cmd).Target;
                    EPoint pt2 = ((ShapeCommand.Move)cmdTo).Target;
                    ptCurrent = this.GetPointBetween(pt1, pt2, ratio);
                    morphedCommands.Add(new ShapeCommand.Move(ptCurrent));
                }
                else if ((cmd is ShapeCommand.Line) || (cmd is ShapeCommand.Curve))
                {
                    ShapeCommand.Draw  draw  = (ShapeCommand.Draw)cmd;
                    ShapeCommand.Curve curve = draw.GetAsCurve();

                    if ((cmdTo is ShapeCommand.Line) || (cmdTo is ShapeCommand.Curve))
                    {
                        draw = (ShapeCommand.Draw)cmdTo;
                        ShapeCommand.Curve curveTo = draw.GetAsCurve();

                        EPoint ptControl = this.GetPointBetween(curve.Control, curveTo.Control, ratio);
                        EPoint ptAnchor  = this.GetPointBetween(curve.Anchor, curveTo.Anchor, ratio);

                        morphedCommands.Add(new ShapeCommand.Curve(ptControl, ptAnchor));
                        ptCurrent += ptControl + ptAnchor;
                    }
                    else
                    {
                        ShapeCommand.Move move = (ShapeCommand.Move)cmdTo;

                        EPoint ptFrom = ptCurrent + curve.Control + curve.Anchor;
                        EPoint ptTo   = move.Target;

                        ptCurrent = this.GetPointBetween(ptFrom, ptTo, ratio);
                        morphedCommands.Add(new ShapeCommand.Move(ptCurrent.Copy()));
                    }
                }
                else if (cmd is ShapeCommand.LineStyle)
                {
                    ShapeCommand.LineStyle ls = (ShapeCommand.LineStyle)cmd;
                    if (ls.StyleId > 0)
                    {
                        Style.LineStyle style = (Style.LineStyle) this.LineStyles[ls.StyleId - 1];
                        style.MorphPosition = ratio;
                        morphedCommands.Add(ls);                         //.GetMorphed(ratio));
                    }
                }
                else if (cmd is ShapeCommand.FillStyle)
                {
                    ShapeCommand.FillStyle fs = (ShapeCommand.FillStyle)cmd;
                    if (fs.StyleId > 0)
                    {
                        Style.FillStyle style = (Style.FillStyle) this.FillStyles[fs.StyleId - 1];
                        style.MorphPosition = ratio;
                        morphedCommands.Add(fs);                         //.GetMorphed(ratio));
                    }
                }
            }
            return(morphedCommands);
        }