示例#1
0
        private void AddColorizers()
        {
            int       locZ = 490;
            Colorizer color;

            color       = new Colorizer();
            color.Rect  = ERectangleF.FromLTRB(98, 12, 549, 110);
            color.Color = System.Drawing.Color.FromArgb(0, 0, 255);
            color.LocZ  = locZ;
            this.m_interfaceSprites.Add(color);

            color       = new Colorizer();
            color.Rect  = ERectangleF.FromLTRB(98, 110, 549, 202);
            color.Color = System.Drawing.Color.FromArgb(0, 255, 255);
            color.LocZ  = locZ;
            this.m_interfaceSprites.Add(color);

            color       = new Colorizer();
            color.Rect  = ERectangleF.FromLTRB(98, 202, 549, 330);
            color.Color = System.Drawing.Color.FromArgb(0, 0, 255);
            color.LocZ  = locZ;
            this.m_interfaceSprites.Add(color);

            color       = new Colorizer();
            color.Rect  = ERectangleF.FromLTRB(98, 202, 549, 330);
            color.Color = System.Drawing.Color.FromArgb(255, 0, 255);
            color.LocZ  = locZ;
            this.m_interfaceSprites.Add(color);
        }
示例#2
0
 protected EPointF GetWhereOnSides(float fPhase, ERectangleF rct)
 {
     float fCircum = rct.Width*2 + rct.Height*2;
     EPointF pnt = new EPointF();
     if (fPhase < rct.Width/fCircum)
     {
         pnt.X = rct.X+fPhase*fCircum;
         pnt.Y = rct.Y;
     }
     else
     {
         fPhase-= rct.Width/fCircum;
         if (fPhase < rct.Height/fCircum)
         {
             pnt.X = rct.Right;
             pnt.Y = rct.Y+fPhase*fCircum;
         }
         else
         {
             fPhase-= rct.Height/fCircum;
             if (fPhase < rct.Width/fCircum)
             {
                 pnt.Y = rct.Bottom;
                 pnt.X = rct.Right-fPhase*fCircum;
             }
             else
             {
                 fPhase-= rct.Width/fCircum;
                 pnt.X = rct.X;
                 pnt.Y = rct.Bottom-fPhase*fCircum;
             }
         }
     }
     return pnt;
 }
示例#3
0
        public bool GetIsConstrained(Sprite sp, ConstrainArea area)
        {
            if (area.ConstrainRectInsteadOfPoint)
            {
                //when the surrounding rect must be inside the rect
                ERectangleF rctIntersect = area.Snap.Copy();
                rctIntersect.Intersect(sp.Rect);
                if (rctIntersect.Equals(sp.Rect))
                {
                    //the surrounding rect is totally inside the snap rect

                    if (!(sp.Rect.Width > area.Constraint.Width || sp.Rect.Height > area.Constraint.Height))
                    {
                        return(true);                        //it's small enough to fit inside constraint
                    }
                }
            }
            else
            {
                //when the loc must be inside the rect
                if (area.Snap == null)
                {
                    return(true);                    //no snap area defined; it's always snapped
                }
                return(area.Snap.Contains(sp.Loc));
            }
            return(false);
        }
示例#4
0
        public static Bitmap CreateLineBitmap(ERectangleF rctLine, Color clrBg, Color clrPen, float penWidth, out EPointF locOffset)
        {
            //Because GDI+ arrows are so limited
            Bitmap bmp = null;
            locOffset = new EPointF();

            if (rctLine.Width != 0 && rctLine.Height != 0)
            {
                bmp = new Bitmap((int)Math.Abs(rctLine.Width)+1, (int)Math.Abs(rctLine.Height)+1, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                Graphics g = Graphics.FromImage(bmp);

                g.FillRectangle(new SolidBrush(clrBg), 0,0,bmp.Width,bmp.Height);

                ERectangleF rctOrigo = rctLine.Copy();
                rctOrigo.MakeTopLeftAtOrigo();

                Pen pen = new Pen(clrPen, penWidth);
                g.DrawLine(pen, rctOrigo.X, rctOrigo.Y, rctOrigo.X+rctOrigo.Width, rctOrigo.Y+rctOrigo.Height);
                g.Dispose();

                if (rctOrigo.Width < 0)
                    locOffset.X = rctOrigo.Width;
                if (rctOrigo.Height < 0)
                    locOffset.Y = rctOrigo.Height;
            }
            return bmp;
        }
示例#5
0
        public override Endogine.BitmapHelpers.PixelDataProvider TransformIntoRenderTarget(Endogine.BitmapHelpers.PixelDataProvider pdp)
        {
            Surface surf     = ((PixelDataProvider)pdp).Texture.GetSurfaceLevel(0);
            bool    isTarget = ((int)surf.Description.Usage & (int)Usage.RenderTarget) != 0;

            if (isTarget)
            {
                return(pdp);
            }

            Surface oldSurfRT = this._device.GetRenderTarget(0);

            PixelDataProvider pdpRT = new PixelDataProvider(pdp.Width, pdp.Height, pdp.BitsPerPixel / 8, this._device, Usage.RenderTarget);

            this.RenderTarget = pdpRT;

            Endogine.SpriteRenderStrategy rs = this.CreateRenderStrategy();
            rs.Init();
            rs.SetPixelDataProvider(pdp);
            ERectangleF rctDrawTarget = new ERectangleF(0, 0, pdp.Width, pdp.Height);//-pdp.Width, -pdp.Height, pdp.Width * 2, pdp.Height * 2) * 2;

            //rs.SourceClipRect = sourceClipRect;
            rs.CalcRenderRegion(rctDrawTarget, 0, new EPoint(), new EPoint(pdp.Width, pdp.Height));

            //render:
            this.PreUpdate();
            rs.SubDraw();
            this.EndUpdate();

            //reset renderer and finish up:
            this._device.SetRenderTarget(0, oldSurfRT);
            this.PostUpdate();

            return(pdpRT);
        }
示例#6
0
        public static Bitmap CreateLineBitmap(ERectangleF rctLine, Color clrBg, Color clrPen, float penWidth, out EPointF locOffset)
        {
            //Because GDI+ arrows are so limited
            Bitmap bmp = null;

            locOffset = new EPointF();

            if (rctLine.Width != 0 && rctLine.Height != 0)
            {
                bmp = new Bitmap((int)Math.Abs(rctLine.Width) + 1, (int)Math.Abs(rctLine.Height) + 1, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                Graphics g = Graphics.FromImage(bmp);

                g.FillRectangle(new SolidBrush(clrBg), 0, 0, bmp.Width, bmp.Height);

                ERectangleF rctOrigo = rctLine.Copy();
                rctOrigo.MakeTopLeftAtOrigo();

                Pen pen = new Pen(clrPen, penWidth);
                g.DrawLine(pen, rctOrigo.X, rctOrigo.Y, rctOrigo.X + rctOrigo.Width, rctOrigo.Y + rctOrigo.Height);
                g.Dispose();

                if (rctOrigo.Width < 0)
                {
                    locOffset.X = rctOrigo.Width;
                }
                if (rctOrigo.Height < 0)
                {
                    locOffset.Y = rctOrigo.Height;
                }
            }
            return(bmp);
        }
示例#7
0
 public static float CalcMovingLineLineCollision(ERectangleF lineRect1, ERectangleF lineRect2, EPointF vel1, EPointF vel2, out EPointF pntCollision)
 {
     //TODO: will work like this:
     //Check line/line collision from each of the line's endpoints to endpoints+vel against the other line.
     //Do this for both lines, as a collision maybe missed or misinterpreted
     pntCollision = new EPointF();
     return(0f);
 }
示例#8
0
 private void m_resizeCorner_MouseEvent(Sprite sender, System.Windows.Forms.MouseEventArgs e, MouseEventType t)
 {
     if (t == Sprite.MouseEventType.StillDown)
     {
         EPoint pntDiff = new EPoint(e.X - m_resizeCorner.MouseLastLoc.X, e.Y - m_resizeCorner.MouseLastLoc.Y);
         Rect = new ERectangleF(Rect.Location, Rect.Size + pntDiff.ToEPointF());              //SizeF(Rect.Size.Width+pntDiff.X,Rect.Size.Height+pntDiff.Y));
     }
 }
示例#9
0
        public static bool CalcCircleLineCollision(EPointF circleLoc, float radius, EPointF circleMovement, ERectangleF lineRect, out EPointF pntFirstCollision, out EPointF circleLocAtCollision)
        {
            //first calc two lines parallel with line, at radius distance from it
            double dAngleLine = Math.Atan2((double)lineRect.Width, -(double)lineRect.Height);
            double dAnglePerp = dAngleLine+Math.PI/2;
            EPointF pntOffset = new EPointF(radius*(float)Math.Sin(dAnglePerp), -radius*(float)Math.Cos(dAnglePerp));
            ERectangleF lineRect1 = lineRect;
            ERectangleF circleMovementLine = new ERectangleF(circleLoc, new EPointF(circleMovement.X, circleMovement.Y));

            float fTimeFirstCollision = 1000;
            pntFirstCollision = new EPointF(0,0);
            circleLocAtCollision = new EPointF(0,0);
            for (int i = -1; i < 2; i+=2)
            {
                ERectangleF lineRectParallel = lineRect.Copy();
                lineRectParallel.Offset(pntOffset.X*i, pntOffset.Y*i);
                EPointF pntCollision;
                if (CalcLineLineCollision(circleMovementLine, lineRectParallel, out pntCollision))
                {
                    EPointF pntDiff = new EPointF(pntCollision.X-circleMovementLine.X, pntCollision.Y-circleMovementLine.Y); //circleMovementLine.Left, pntCollision.Y-circleMovementLine.Top
                    float fTimeCollision = Endogine.Collision.PointLine.PointIsWhereOnLine(pntDiff, circleMovementLine);
                    if (fTimeCollision < fTimeFirstCollision)
                    {
                        fTimeFirstCollision = fTimeCollision;
                        pntFirstCollision = new EPointF(pntCollision.X-pntOffset.X*i, pntCollision.Y-pntOffset.Y*i);
                        circleLocAtCollision = pntCollision;
                    }
                }
            }
            //also calc circle/circle collision (for line end points)
            ArrayList aLocs, aTimes;
            EPointF pntLinePointToTest = lineRect.Location;
            for (int i = 0; i < 2; i++)
            {
                if (CalcCircleCircleCollisions(circleLoc, pntLinePointToTest, circleMovement, new EPointF(0,0), radius, 0, out aLocs, out aTimes))
                {
                    EPointF pntCollision = (EPointF)aLocs[0];
                    float fTimeCollision = (float)aTimes[0];
                    if (fTimeCollision < 0)
                    {
                        fTimeCollision = (float)aTimes[1];
                        if (fTimeCollision < 0 || fTimeCollision > 1)
                            continue;
                        pntCollision = (EPointF)aLocs[1];
                    }
                    if (fTimeCollision < fTimeFirstCollision)
                    {
                        fTimeFirstCollision = fTimeCollision;
                        pntFirstCollision = pntLinePointToTest;
                        circleLocAtCollision = new EPointF(circleLoc.X+circleMovement.X*fTimeCollision, circleLoc.Y+circleMovement.Y*fTimeCollision);
                    }
                }
                pntLinePointToTest = new EPointF(lineRect.X+lineRect.Width, lineRect.Y+lineRect.Height); //lineRect.Left+lineRect.Width, lineRect.Top
            }
            if (fTimeFirstCollision <= 1)
                return true;
            return false;
        }
示例#10
0
 public static float PointIsWhereOnLine(EPointF pnt, ERectangleF rct)
 {
     //NormalizeRect(ref rct);
     if (rct.Width != 0)
         return pnt.X / rct.Width;
     if (rct.Height != 0)
         return pnt.Y / rct.Height;
     return -1000;
 }
示例#11
0
        public override void EnterFrame()
        {
            base.EnterFrame();

            ERectangleF rct = new ERectangleF(0, 0, 640, 480);
            EPointF     loc = this.ConvParentLocToRootLoc(Loc);

            rct.WrapPointInside(loc);
            Loc = this.ConvRootLocToParentLoc(loc);
        }
示例#12
0
        public void AddArea(ERectangleF rctConstraint, ERectangleF rctSnap, bool bConstrainRectInsteadOfPoint, object tag)
        {
            ConstrainArea area = new ConstrainArea();

            area.Constraint = rctConstraint;
            area.Snap       = rctSnap;
            area.ConstrainRectInsteadOfPoint = bConstrainRectInsteadOfPoint;
            area.Tag = tag;
            this.AddArea(area);
        }
示例#13
0
        public override void CalcInParent()
        {
            base.CalcInParent();

            this.collisionLines = new ArrayList();
            this.collisionLines.Add(ERectangleF.FromLTRB(this.Rect.Left, this.Rect.Top, this.Rect.Right, this.Rect.Top));
            this.collisionLines.Add(ERectangleF.FromLTRB(this.Rect.Right, this.Rect.Top, this.Rect.Right, this.Rect.Bottom));
            this.collisionLines.Add(ERectangleF.FromLTRB(this.Rect.Left, this.Rect.Bottom, this.Rect.Right, this.Rect.Bottom));
            this.collisionLines.Add(ERectangleF.FromLTRB(this.Rect.Left, this.Rect.Top, this.Rect.Left, this.Rect.Bottom));
        }
示例#14
0
        /// <summary>
        /// Stretching sprite
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="t"></param>
        private void spSquare_MouseEvent(Sprite sender, System.Windows.Forms.MouseEventArgs e, Endogine.Sprite.MouseEventType t)
        {
            if (t == Endogine.Sprite.MouseEventType.StillDown)
            {
                EPoint  pntWhichSquare = (EPoint)sender.Tag;
                EPointF pntDiff        = new EPointF(e.X, e.Y) - sender.MouseLastLoc.ToEPointF();

                EPointF pntRestrictTo = new EPointF();
                if (pntWhichSquare.Y == 1)
                {
                    pntRestrictTo.X = 1;
                }
                else if (pntWhichSquare.X == 1)
                {
                    pntRestrictTo.Y = 1;
                }
                else
                {
                    pntRestrictTo = new EPointF(1, 1);
                }

                EPointF     pntMove = pntDiff * pntRestrictTo;
                ERectangleF rct     = this.m_sp.Rect.Copy();

                if (pntWhichSquare.X == 0 || pntWhichSquare.Y == 0)
                {
                    if (pntWhichSquare.X == 0 && pntWhichSquare.Y == 2)
                    {
                        rct.X      += pntMove.X;
                        rct.Width  -= pntMove.X;
                        rct.Height += pntMove.Y;
                    }
                    else if (pntWhichSquare.X == 2 && pntWhichSquare.Y == 0)
                    {
                        rct.Y      += pntMove.Y;
                        rct.Height -= pntMove.Y;
                        rct.Width  += pntMove.X;
                    }
                    else
                    {
                        rct.Location += pntMove;
                        rct.Size     -= pntMove;
                    }
                }
                else
                {
                    rct.Size += pntMove;
                }

                this.m_sp.Rect = rct;

                this.Update();
            }
        }
示例#15
0
        public static double GetNormalAngle(ERectangleF rct)
        {
            double dAngleLine = Math.Atan2((double)rct.Width, -(double)rct.Height);

            dAngleLine += Math.PI / 2;
            if (dAngleLine > Math.PI)
            {
                dAngleLine -= Math.PI;
            }
            return(dAngleLine);
        }
示例#16
0
        private MeterXY Create2DMeter(ERectangleF rct, string prop, float limit)
        {
            MeterXY xy = new MeterXY();

            xy.Rect = rct;
            xy.SetAutoFetch(this._car, prop);
            xy.RangeX.MinIn = -limit;
            xy.RangeX.MaxIn = limit;
            xy.RangeY.MinIn = -limit;
            xy.RangeY.MaxIn = limit;
            return(xy);
        }
示例#17
0
        protected override void EnterFrame()
        {
            base.EnterFrame();

            if (m_sp.Rect == null)
            {
                return;
            }

            ERectangleF rct = new ERectangleF(
                m_sp.ConvParentLocToRootLoc(m_sp.Rect.Location),
                m_sp.ConvParentLocToRootLoc(m_sp.Rect.Size));
        }
示例#18
0
 private static void NormalizeRect(ref ERectangleF rct)
 {
     if (rct.Width < 0)
     {
         rct.Offset(rct.Width, 0);
         rct.Width = -rct.Width;
     }
     if (rct.Height < 0)
     {
         rct.Offset(0, rct.Height);
         rct.Height = -rct.Height;
     }
 }
示例#19
0
 public static float PointIsWhereOnLine(EPointF pnt, ERectangleF rct)
 {
     //NormalizeRect(ref rct);
     if (rct.Width != 0)
     {
         return(pnt.X / rct.Width);
     }
     if (rct.Height != 0)
     {
         return(pnt.Y / rct.Height);
     }
     return(-1000);
 }
示例#20
0
        protected void AdjustVertices(ERectangleF rctfCropped)
        {
            if (_sp != null)
            {
                if (_sp.Member == null)
                {
                    return;
                }
                rctfCropped = _sp.GetPortionOfMemberToDisplay();
            }
            else
            {
                if (rctfCropped == null)
                {
                    rctfCropped = new ERectangleF(0, 0, 1, 1);
                }
            }

            if (_vertexBuffer == null)
            {
                return;
            }

            float[,] aUVs = GenerateUVs(rctfCropped);


            CustomVertex[] vertices = null;
            try
            {
                vertices = _vertexBuffer.Lock(0, 0) as CustomVertex[];
            }
            catch (Exception e)
            {
                //TODO: why does this happen??
                Console.WriteLine(e.Message);
                return;
                //throw new Exception("Failed to lock buffer...");
            }
            //ERectangleF rct = new ERectangleF(0, 0, 1, 1);
            //int nColor = System.Drawing.Color.FromArgb(255,255,0,120).ToArgb(); //255,255,255,255
            //vertices[0] = new CustomVertex(rct.Left,		rct.Top, 0.0f, aUVs[0,0], aUVs[0,1]);//,      nColor);
            //vertices[1] = new CustomVertex(rct.Right,	rct.Top, 0.0f, aUVs[1,0], aUVs[1,1]);//,      nColor);
            //vertices[2] = new CustomVertex(rct.Left,		-rct.Bottom, 0.0f, aUVs[3,0], aUVs[3,1]);//,nColor);
            //vertices[3] = new CustomVertex(rct.Right,	-rct.Bottom, 0.0f, aUVs[2,0], aUVs[2,1]);//,nColor);
            vertices[0] = new CustomVertex(0f, 0f, 0.0f, aUVs[0, 0], aUVs[0, 1]);
            vertices[1] = new CustomVertex(1f, 0f, 0.0f, aUVs[1, 0], aUVs[1, 1]);
            vertices[2] = new CustomVertex(0f, -1f, 0.0f, aUVs[3, 0], aUVs[3, 1]);
            vertices[3] = new CustomVertex(1f, -1f, 0.0f, aUVs[2, 0], aUVs[2, 1]);
            _vertexBuffer.Unlock();
        }
示例#21
0
        protected float[,] GenerateUVs(ERectangleF rctfCropped)
        {
            float tXOffset = 0f;             //.5f/sizeReal.Width;
            float tYOffset = 0f;             //.5f/sizeReal.Height;

            float[,] tUVs = new float[, ] {
                { rctfCropped.X + tXOffset, rctfCropped.Y + tYOffset },
                { rctfCropped.OppositeX - tXOffset, rctfCropped.Y + tYOffset },
                { rctfCropped.OppositeX - tXOffset, rctfCropped.OppositeY - tYOffset },
                { rctfCropped.X + tXOffset, rctfCropped.OppositeY - tYOffset }
            };

            return(tUVs);
        }
示例#22
0
        private ERectangleF[,] CreateRectanglesFromCuttingRect(ERectangleF rct, EPointF fullSize)
        {
            ERectangleF[,] rects = new ERectangleF[3, 3];

            float left  = 0;
            float right = 0;

            for (int x = 0; x < 3; x++)
            {
                if (x == 0)
                {
                    right = rct.Left;
                }
                else if (x == 1)
                {
                    right = rct.Right;
                }
                else
                {
                    right = fullSize.X;
                }

                float top    = 0;
                float bottom = 0;
                for (int y = 0; y < 3; y++)
                {
                    if (y == 0)
                    {
                        bottom = rct.Top;
                    }
                    else if (y == 1)
                    {
                        bottom = rct.Bottom;
                    }
                    else
                    {
                        bottom = fullSize.Y;
                    }

                    //if (!(bottom-top == 0 || right-left == 0)) //right-left: could be optimized outside this loop
                    rects[x, y] = ERectangleF.FromLTRB(left, top, right, bottom);

                    top = bottom;
                }
                left = right;
            }

            return(rects);
        }
示例#23
0
        public Frame()
        {
            this.m_bMeInvisibleButNotChildren = true;
            this.m_bNoScalingOnSetRect = true;
            Name = "Frame";

            m_aSprites = new ArrayList();

            //			for (int i = 0; i < 9; i++)
            //				m_aSprites.Add(new Sprite());

            this._spriteArray = new Sprite[3,3];

            this._cuttingRectFract = new ERectangleF(0.5f,0.5f,0.01f,0.01f);
        }
示例#24
0
        public Frame()
        {
            this.m_bMeInvisibleButNotChildren = true;
            this.m_bNoScalingOnSetRect        = true;
            Name = "Frame";

            m_aSprites = new ArrayList();

//			for (int i = 0; i < 9; i++)
//				m_aSprites.Add(new Sprite());

            this._spriteArray = new Sprite[3, 3];

            this._cuttingRectFract = new ERectangleF(0.5f, 0.5f, 0.01f, 0.01f);
        }
示例#25
0
        public Player()
        {
            this.Color = GameMain.Instance.m_clrOffwhite;

            this.m_keys = new KeysSteering(KeysSteering.KeyPresets.ArrowsSpace);
            this.m_keys.AddKeyPreset(KeysSteering.KeyPresets.awsdCtrlShift);
            this.m_keys.KeyEvent += new KeyEventHandler(m_keys_KeyEvent);

            this.SetGraphics("Player");
            this.CenterRegPoint();

            ERectangleF rct = ERectangleF.FromLTRB(145, 418, 495, 419);

            Endogine.GameHelpers.BhConstrain bh = new Endogine.GameHelpers.BhConstrain();
            bh.AddArea(rct, null, false, null);
            this.AddBehavior(bh);
        }
 public override void CalcRenderRegion(ERectangleF rctDrawTarget, float rotation, EPoint regPoint, EPoint sourceRectSize)
 {
     if (this._effect == null)
         this._matrix = this.CreateMatrix(rctDrawTarget, rotation, regPoint, sourceRectSize);
     else
     {
         //Have to calculate differently when using shaders (haven't looked into why exactly yet)
         System.Drawing.Rectangle rctView = this._device.ScissorRectangle;
         this._matrix = Matrix.Scaling(rctDrawTarget.Width / rctView.Width * 2, rctDrawTarget.Height / rctView.Height * 2, 1); //Matrix.Identity;
         ////EPointF pntRelativeRegPoint = this._sp.RegPoint.ToEPointF() / this._sp.SourceRect.Size.ToEPointF();
         ////EPointF pntRegOff = regPoint.ToEPointF() / new EPointF(sourceRectSize.X, sourceRectSize.Y) * new EPointF(rctDrawTarget.Width, rctDrawTarget.Height);
         ////m2.Multiply(Matrix.Translation(-pntRegOff.X, pntRegOff.Y, 0));
         ////m2.Multiply(Matrix.RotationZ(-rotation));
         ////m2.Multiply(Matrix.Translation(pntRegOff.X, -pntRegOff.Y, 0));
         this._matrix.Multiply(Matrix.Translation(rctDrawTarget.X / rctView.Width * 2 - 1f, 1f - rctDrawTarget.Y / rctView.Height * 2, 0));
     }
 }
示例#27
0
        public Matrix CreateMatrix(ERectangleF rctDrawTarget, float rotation, EPoint regPoint, EPoint sourceRectSize)
        {
            System.Drawing.Rectangle rctView = this._device.ScissorRectangle; //this._device.Viewport

            Matrix  m         = Matrix.Scaling(rctDrawTarget.Width, rctDrawTarget.Height, 1);
            EPointF pntRegOff = regPoint.ToEPointF() / new EPointF(sourceRectSize.X, sourceRectSize.Y) * new EPointF(rctDrawTarget.Width, rctDrawTarget.Height);

            m.Multiply(Matrix.Translation(-pntRegOff.X, pntRegOff.Y, 0));
            m.Multiply(Matrix.RotationZ(-rotation));
            m.Multiply(Matrix.Translation(pntRegOff.X, -pntRegOff.Y, 0));

            EPointF pntLoc = new EPointF(rctDrawTarget.X - rctView.Width / 2, rctDrawTarget.Y - rctView.Height / 2);

            m.Multiply(Matrix.Translation(pntLoc.X, -pntLoc.Y, 0f));
            m.M43 = 9000f;

            return(m);
        }
示例#28
0
        public GameMain()
        {
            Instance = this;

            string path = AppSettings.Instance.GetPath("Media") + "SpaceInv";

            AppSettings.Instance.AddPath("Media", path);
            PicRef.ScanDirectory(path);

            this.m_clrOffwhite = System.Drawing.Color.FromArgb(214, 181, 140);

            this.m_interfaceSprites = new ArrayList();

            this.m_score = new Score();

            this.m_livesLeft = new LivesLeft();

            Sprite sp = new Sprite();

            sp.SetGraphics("Screen");
            sp.LocZ = 500;
            sp.Ink  = RasterOps.ROPs.AddPin;
            this.m_interfaceSprites.Add(sp);

            this.AddColorizers();


            this.m_covers = new ArrayList();
            Cover cover;

            for (int nCoverNum = 0; nCoverNum < 4; nCoverNum++)
            {
                cover     = new Cover();
                cover.Loc = new EPointF(170 + 90 + (nCoverNum - 1) * 90, 369);
                this.m_covers.Add(cover);
            }

            ERectangleF rctPlayArea = ERectangleF.FromLTRB(155, 20, 550, 400);          //new ERectangleF(145,10,350,200); //155 550

            this.m_invadersGrid = new InvadersGrid();

            //ERectangleF rctPlayerConstraints = rctPlayArea+ERectangleF.FromLTRB(-10,0,-55,0);
            this.m_player = new Player();
        }
示例#29
0
 public override void CalcRenderRegion(ERectangleF rctDrawTarget, float rotation, EPoint regPoint, EPoint sourceRectSize)
 {
     if (this._effect == null)
     {
         this._matrix = this.CreateMatrix(rctDrawTarget, rotation, regPoint, sourceRectSize);
     }
     else
     {
         //Have to calculate differently when using shaders (haven't looked into why exactly yet)
         System.Drawing.Rectangle rctView = this._device.ScissorRectangle;
         this._matrix = Matrix.Scaling(rctDrawTarget.Width / rctView.Width * 2, rctDrawTarget.Height / rctView.Height * 2, 1); //Matrix.Identity;
         ////EPointF pntRelativeRegPoint = this._sp.RegPoint.ToEPointF() / this._sp.SourceRect.Size.ToEPointF();
         ////EPointF pntRegOff = regPoint.ToEPointF() / new EPointF(sourceRectSize.X, sourceRectSize.Y) * new EPointF(rctDrawTarget.Width, rctDrawTarget.Height);
         ////m2.Multiply(Matrix.Translation(-pntRegOff.X, pntRegOff.Y, 0));
         ////m2.Multiply(Matrix.RotationZ(-rotation));
         ////m2.Multiply(Matrix.Translation(pntRegOff.X, -pntRegOff.Y, 0));
         this._matrix.Multiply(Matrix.Translation(rctDrawTarget.X / rctView.Width * 2 - 1f, 1f - rctDrawTarget.Y / rctView.Height * 2, 0));
     }
 }
示例#30
0
        public PlayArea()
        {
            //this.m_bNoScalingOnSetRect = true;
            m_spBg            = new Sprite();
            m_spBg.Name       = "Bg";
            m_spBg.MemberName = "PlayArea";
            m_spBg.Parent     = this;
            m_spBg.RegPoint   = new EPoint(30, 30);

            m_spBgFill        = new Sprite();
            m_spBgFill.Parent = this;
            m_spBgFill.Name   = "BgFill";

            m_pathCalc = new PathCalc(this);
            Grid       = new Grid(this);


            m_aCollisionLines = new ArrayList();
            EPointF pntTopLeft     = Grid.GetGfxLocFromGridLoc(new EPointF(-1f, -0.0f));
            EPointF pntBottomRight = Grid.GetGfxLocFromGridLoc(new EPointF(Grid.GridSize.Width + 0.5f, Grid.GridSize.Height));

            //first line is ceiling (where balls stick)
            m_aCollisionLines.Add(ERectangleF.FromLTRB(pntTopLeft.X, pntTopLeft.Y, pntBottomRight.X, pntTopLeft.Y));
            m_aCollisionLines.Add(ERectangleF.FromLTRB(pntTopLeft.X, pntTopLeft.Y, pntTopLeft.X, pntBottomRight.Y));
            m_aCollisionLines.Add(ERectangleF.FromLTRB(pntBottomRight.X, pntTopLeft.Y, pntBottomRight.X, pntBottomRight.Y));

            m_aPlayers = new ArrayList();
            AddPlayer(new Hashtable());

            Hashtable htKeysForPlayer2 = new Hashtable();

            htKeysForPlayer2.Add("left", System.Windows.Forms.Keys.A);
            htKeysForPlayer2.Add("right", System.Windows.Forms.Keys.D);
            htKeysForPlayer2.Add("up", System.Windows.Forms.Keys.W);
            htKeysForPlayer2.Add("shoot", System.Windows.Forms.Keys.S);
            AddPlayer(htKeysForPlayer2);
            //TODO: A fun cooperative mode would be to force players to take turns.


            //TODO: write a main game class which manages levels and multiple playAreas.
            m_level = new LevelManager(this);
            NextLevel();
        }
示例#31
0
        protected override void EnterFrame()
        {
            base.EnterFrame();

            if (m_sp.Rect == null)
                return;

            ERectangleF rct = new ERectangleF(
                m_sp.ConvParentLocToRootLoc(m_sp.Rect.Location),
                m_sp.ConvParentLocToRootLoc(m_sp.Rect.Size));

            for (int i = 0; i < m_aSprites.Count; i++)
            {
                Sprite sp = (Sprite)m_aSprites[i];
                sp.Loc = GetWhereOnSides((float)((m_nCnt+100*i/m_aSprites.Count) % 100)/100, rct);
            }

            m_nCnt++;
        }
示例#32
0
        private EPointF GetForceOnPoint(EPointF pnt)
        {
            //because of error in inclination bitmap edges:
            ERectangleF rct = this.Rect + new ERectangleF(2, 2, -4, -4);

            if (!rct.Contains(pnt))
            {
                return(new EPointF());
            }

            EPointF pntDiff   = pnt - this.Loc;
            EPoint  pntInside = pntDiff.ToEPoint();

            Color clr = this.bmpInclination.GetPixel(pntInside.X, pntInside.Y);
            //EPointF pntForce = EPointF.FromLengthAndAngle((float)clr.B/1000, (float)Math.Atan2((clr.R-128), -(clr.G-128)));
            EPointF pntForce = new EPointF(-(clr.R - 128), -(clr.G - 128)) / 600;

            return(pntForce);
        }
示例#33
0
        public override void SubDraw()
        {
            ERectangleF rctDraw = m_sp.CalcRectInDrawTarget();

//			Matrix QuadMatrix = Matrix.Scaling(rctDraw.Width, rctDraw.Height, 1);

            EPointF pntRegOff = m_sp.RegPoint.ToEPointF() / new EPointF(m_sp.SourceRect.Width, m_sp.SourceRect.Height) * new EPointF(rctDraw.Width, rctDraw.Height);

//			QuadMatrix.Multiply(Matrix.Translation(-pntRegOff.X, pntRegOff.Y,0));
//			QuadMatrix.Multiply(Matrix.RotationZ(-m_sp.Rotation));
//			QuadMatrix.Multiply(Matrix.Translation(pntRegOff.X, -pntRegOff.Y,0));

            EPoint  renderControlSize = new EPoint(800, 600);
            EPointF pntLoc            = new EPointF(rctDraw.X - renderControlSize.X / 2, rctDraw.Y - renderControlSize.Y / 2);

            //QuadMatrix.Multiply(Matrix.Translation(pntLoc.X, -pntLoc.Y, 0f));


            int tx = ((MemberSpriteBitmapRenderStrategyA)this.m_sp.Member.RenderStrategy).TextureId;

            Gl.glBindTexture(Gl.GL_TEXTURE_2D, tx);

            //Gl.glRotatef(m_sp.Rotation, 0, 0, 1);

            Gl.glBegin(Gl.GL_QUADS);
            if (false)
            {
                Gl.glTexCoord2f(0, 0); Gl.glVertex3f(-1, -1, 1);
                Gl.glTexCoord2f(1, 0); Gl.glVertex3f(1, -1, 1);
                Gl.glTexCoord2f(1, 1); Gl.glVertex3f(1, 1, 1);
                Gl.glTexCoord2f(0, 1); Gl.glVertex3f(-1, 1, 1);
            }
            rctDraw = rctDraw * 0.01f;
            rctDraw.Offset(-1f, -1f);
//			rctDraw.Y = 1f-rctDraw.Y;
            Gl.glTexCoord2f(0, 0); Gl.glVertex3f(rctDraw.Left, rctDraw.Top, 1);
            Gl.glTexCoord2f(1, 0); Gl.glVertex3f(rctDraw.Right, rctDraw.Top, 1);
            Gl.glTexCoord2f(1, 1); Gl.glVertex3f(rctDraw.Right, rctDraw.Bottom, 1);
            Gl.glTexCoord2f(0, 1); Gl.glVertex3f(rctDraw.Left, rctDraw.Bottom, 1);

            Gl.glEnd();
        }
示例#34
0
        protected override void EnterFrame()
        {
            base.EnterFrame();

            if (m_sp.Rect == null)
            {
                return;
            }

            ERectangleF rct = new ERectangleF(
                m_sp.ConvParentLocToRootLoc(m_sp.Rect.Location),
                m_sp.ConvParentLocToRootLoc(m_sp.Rect.Size));


            for (int i = 0; i < m_aSprites.Count; i++)
            {
                Sprite sp = (Sprite)m_aSprites[i];
                sp.Loc = GetWhereOnSides((float)((m_nCnt + 100 * i / m_aSprites.Count) % 100) / 100, rct);
            }

            m_nCnt++;
        }
示例#35
0
        public void SetLine(EPointF a_pnt1, EPointF a_pnt2)
        {
            m_rct = ERectangleF.FromLTRB(a_pnt1.X, a_pnt1.Y, a_pnt2.X, a_pnt2.Y);
            if (Member != null)
            {
                Member.Dispose();
            }

            Loc = m_rct.Location;

            Bitmap   bmp = new Bitmap((int)Math.Abs(m_rct.Width), (int)Math.Abs(m_rct.Height), PixelFormat.Format24bppRgb);
            Graphics g   = Graphics.FromImage(bmp);

            //Point pnt1 = a_pnt1;
            //if (a_pnt1.Y <= a_pnt2.Y && a_pnt1.X <= a_pnt2.X)
            g.DrawLine(new Pen(Color.White, 1), new Point(0, 0), new Point((int)m_rct.Width, (int)m_rct.Height));
            g.Dispose();

            MemberSpriteBitmap mb = new MemberSpriteBitmap(bmp);

            Member = mb;
        }
示例#36
0
        protected EPointF GetWhereOnSides(float fPhase, ERectangleF rct)
        {
            float   fCircum = rct.Width * 2 + rct.Height * 2;
            EPointF pnt     = new EPointF();

            if (fPhase < rct.Width / fCircum)
            {
                pnt.X = rct.X + fPhase * fCircum;
                pnt.Y = rct.Y;
            }
            else
            {
                fPhase -= rct.Width / fCircum;
                if (fPhase < rct.Height / fCircum)
                {
                    pnt.X = rct.Right;
                    pnt.Y = rct.Y + fPhase * fCircum;
                }
                else
                {
                    fPhase -= rct.Height / fCircum;
                    if (fPhase < rct.Width / fCircum)
                    {
                        pnt.Y = rct.Bottom;
                        pnt.X = rct.Right - fPhase * fCircum;
                    }
                    else
                    {
                        fPhase -= rct.Width / fCircum;
                        pnt.X   = rct.X;
                        pnt.Y   = rct.Bottom - fPhase * fCircum;
                    }
                }
            }
            return(pnt);
        }
 protected override void SetSourceClipRect(ERectangleF rct)
 {
     this.AdjustVertices(rct);
 }
示例#38
0
        private void PlayerBall_MouseEvent(Sprite sender, System.Windows.Forms.MouseEventArgs e, MouseEventType t)
        {
            if (t == Sprite.MouseEventType.Down)
            {
                forceMarker.Visible = true;
            }
            else if (t == Sprite.MouseEventType.StillDown)
            {
                MemberSpriteBitmap mb = forceMarker.Member;
                if (mb != null)
                {
                    mb.Dispose();
                }

                //this.MouseDownLoc.X, this.MouseDownLoc.Y
                ERectangleF rctLine = ERectangleF.FromLTRB(this.Loc.X, this.Loc.Y, this.MouseLastLoc.X, this.MouseLastLoc.Y);
                forceVector = rctLine.Size;

                if (rctLine.Width != 0 && rctLine.Height != 0)
                {
                    Bitmap   bmp = new Bitmap((int)Math.Abs(rctLine.Width) + 1, (int)Math.Abs(rctLine.Height) + 1, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
                    Graphics g   = Graphics.FromImage(bmp);

                    ERectangleF rctOrigo = rctLine.Copy();
                    rctOrigo.MakeTopLeftAtOrigo();

                    Pen pen = new Pen(Color.Red, 2);
                    g.DrawLine(pen, rctOrigo.X, rctOrigo.Y, rctOrigo.X + rctOrigo.Width, rctOrigo.Y + rctOrigo.Height);
                    g.Dispose();

                    EPointF locOffset = new EPointF();
                    if (rctOrigo.Width < 0)
                    {
                        locOffset.X = rctOrigo.Width;
                    }
                    if (rctOrigo.Height < 0)
                    {
                        locOffset.Y = rctOrigo.Height;
                    }

                    mb = new MemberSpriteBitmap(bmp);
                    forceMarker.Member = mb;
                    forceMarker.Loc    = this.Loc + locOffset;
                }
                else
                {
                    forceMarker.Member = null;
                }
            }
            else if (t == Sprite.MouseEventType.UpOutside || t == Sprite.MouseEventType.Click)
            {
                this.Velocity = forceVector * -0.1f;

                forceMarker.Visible = false;
                MemberSpriteBitmap mb = forceMarker.Member;
                if (mb != null)
                {
                    forceMarker.Member = null;
                    mb.Dispose();
                }
            }
        }
示例#39
0
 public static float CalcMovingLineLineCollision(ERectangleF lineRect1, ERectangleF lineRect2, EPointF vel1, EPointF vel2, out EPointF pntCollision)
 {
     //TODO: will work like this:
     //Check line/line collision from each of the line's endpoints to endpoints+vel against the other line.
     //Do this for both lines, as a collision maybe missed or misinterpreted
     pntCollision = new EPointF();
     return 0f;
 }
示例#40
0
        private ERectangleF[,] CreateRectanglesFromCuttingRect(ERectangleF rct, EPointF fullSize)
        {
            ERectangleF[,] rects = new ERectangleF[3,3];

            float left = 0;
            float right = 0;
            for (int x=0; x<3; x++)
            {
                if (x==0) right = rct.Left;
                else if (x==1) right = rct.Right;
                else right = fullSize.X;

                float top = 0;
                float bottom = 0;
                for (int y=0; y<3; y++)
                {
                    if (y==0) bottom = rct.Top;
                    else if (y==1) bottom = rct.Bottom;
                    else bottom = fullSize.Y;

                    //if (!(bottom-top == 0 || right-left == 0)) //right-left: could be optimized outside this loop
                    rects[x,y] = ERectangleF.FromLTRB(left,top,right,bottom);

                    top = bottom;
                }
                left = right;
            }

            return rects;
        }
示例#41
0
        protected override void EnterFrame()
        {
            base.EnterFrame();

            if (m_sp.Rect == null)
                return;

            ERectangleF rct = new ERectangleF(
                m_sp.ConvParentLocToRootLoc(m_sp.Rect.Location),
                m_sp.ConvParentLocToRootLoc(m_sp.Rect.Size));
        }
示例#42
0
 public static double GetNormalAngle(ERectangleF rct)
 {
     double dAngleLine = Math.Atan2((double)rct.Width, -(double)rct.Height);
     dAngleLine+=Math.PI/2;
     if (dAngleLine > Math.PI)
         dAngleLine-=Math.PI;
     return dAngleLine;
 }
示例#43
0
        public static bool CalcLineLineCollision(ERectangleF lineRect1, ERectangleF lineRect2, out EPointF pntCollision)
        {
            pntCollision = new EPointF(0,0);

            bool bLine1GotA = true;
            bool bLine2GotA = true;

            float line1A = 0;
            float line2A = 0;
            float line1B = 0;
            float line2B = 0;

            if (lineRect1.Width != 0)
            {
                line1A = lineRect1.Height/lineRect1.Width;
                line1B = lineRect1.Y-lineRect1.X*line1A; //lineRect1.Top-lineRect1.Left
            }
            else
                bLine1GotA = false;

            if (lineRect2.Width != 0)
            {
                line2A = lineRect2.Height/lineRect2.Width;
                line2B = lineRect2.Y-lineRect2.X*line2A; //lineRect2.Top-lineRect2.Left
            }
            else
                bLine2GotA = false;

            if (line1A==line2A)
            {
                if (bLine1GotA && bLine2GotA)
                    return false;
            }

            if (line1B == line2B)
            {
                pntCollision.X = 0;
                pntCollision.Y = line1B;
            }
            if (bLine1GotA && bLine2GotA)
            {
                pntCollision.X = (line2B-line1B)/(line1A-line2A);
                pntCollision.Y = line1A*pntCollision.X + line1B;
            }
            else if (bLine1GotA)
            {
                pntCollision.X = lineRect2.X; //.Left;
                pntCollision.Y = line1A*pntCollision.X + line1B;//(pntCollision.Y-line1B)/line1A;
            }
            else if (bLine2GotA)
            {
                pntCollision.X = lineRect1.X; //.Left;
                pntCollision.Y = line2A*pntCollision.X + line2B;
                //pntCollision.Y = lineRect1.Left;
                //pntCollision.X = (pntCollision.Y-line2B)/line2A;
            }

            //is point on both lines' segments?
            float fRoundError = 0.001f;
            NormalizeRect(ref lineRect1);
            NormalizeRect(ref lineRect2);
            if (pntCollision.X - lineRect1.Left < -fRoundError || pntCollision.X - lineRect2.Left < -fRoundError)
                return false;
            if (pntCollision.X - lineRect1.Right > fRoundError || pntCollision.X - lineRect2.Right > fRoundError)
                return false;
            if (pntCollision.Y - lineRect1.Top < -fRoundError|| pntCollision.Y - lineRect2.Top < -fRoundError)
                return false;
            if (pntCollision.Y - lineRect1.Bottom > fRoundError|| pntCollision.Y - lineRect2.Bottom > fRoundError)
                return false;

            return true;
        }
 public override void CalcRenderRegion(ERectangleF rctDrawTarget, float rotation, EPoint regPoint, EPoint sourceRectSize)
 {
     //this._matrix = this.CreateMatrix(rctDrawTarget, rotation, regPoint, sourceRectSize);
 }
        protected float[,] GenerateUVs(ERectangleF rctfCropped)
        {
            float tXOffset = 0f; //.5f/sizeReal.Width;
            float tYOffset = 0f; //.5f/sizeReal.Height;

            float[,] tUVs = new float[,]{
            {rctfCropped.X+tXOffset,			rctfCropped.Y+tYOffset},
            {rctfCropped.OppositeX-tXOffset,		rctfCropped.Y+tYOffset},
            {rctfCropped.OppositeX-tXOffset,		rctfCropped.OppositeY-tYOffset},
            {rctfCropped.X+tXOffset,			rctfCropped.OppositeY-tYOffset}};

            return tUVs;
        }
        protected void AdjustVertices(ERectangleF rctfCropped)
        {
            if (_sp != null)
            {
                if (_sp.Member == null)
                    return;
                rctfCropped = _sp.GetPortionOfMemberToDisplay();
            }
            else
            {
                if (rctfCropped == null)
                    rctfCropped = new ERectangleF(0, 0, 1, 1);
            }

            if (_vertexBuffer == null)
                return;

            float[,] aUVs = GenerateUVs(rctfCropped);

            CustomVertex[] vertices = null;
            try
            {
                vertices = _vertexBuffer.Lock(0, 0) as CustomVertex[];
            }
            catch (Exception e)
            {
                //TODO: why does this happen??
                Console.WriteLine(e.Message);
                return;
                //throw new Exception("Failed to lock buffer...");
            }
            //ERectangleF rct = new ERectangleF(0, 0, 1, 1);
            //int nColor = System.Drawing.Color.FromArgb(255,255,0,120).ToArgb(); //255,255,255,255
            //vertices[0] = new CustomVertex(rct.Left,		rct.Top, 0.0f, aUVs[0,0], aUVs[0,1]);//,      nColor);
            //vertices[1] = new CustomVertex(rct.Right,	rct.Top, 0.0f, aUVs[1,0], aUVs[1,1]);//,      nColor);
            //vertices[2] = new CustomVertex(rct.Left,		-rct.Bottom, 0.0f, aUVs[3,0], aUVs[3,1]);//,nColor);
            //vertices[3] = new CustomVertex(rct.Right,	-rct.Bottom, 0.0f, aUVs[2,0], aUVs[2,1]);//,nColor);
            vertices[0] = new CustomVertex(0f, 0f, 0.0f, aUVs[0, 0], aUVs[0, 1]);
            vertices[1] = new CustomVertex(1f, 0f, 0.0f, aUVs[1, 0], aUVs[1, 1]);
            vertices[2] = new CustomVertex(0f, -1f, 0.0f, aUVs[3, 0], aUVs[3, 1]);
            vertices[3] = new CustomVertex(1f, -1f, 0.0f, aUVs[2, 0], aUVs[2, 1]);
            _vertexBuffer.Unlock();
        }
 protected override void SetSourceClipRect(ERectangleF rct)
 {
     //TODO: replace _sp.SourceRect in SubDraw()
 }
        public Matrix CreateMatrix(ERectangleF rctDrawTarget, float rotation, EPoint regPoint, EPoint sourceRectSize)
        {
            System.Drawing.Rectangle rctView = this._device.ScissorRectangle; //this._device.Viewport

            Matrix m = Matrix.Scaling(rctDrawTarget.Width, rctDrawTarget.Height, 1);
            EPointF pntRegOff = regPoint.ToEPointF() / new EPointF(sourceRectSize.X, sourceRectSize.Y) * new EPointF(rctDrawTarget.Width, rctDrawTarget.Height);
            m.Multiply(Matrix.Translation(-pntRegOff.X, pntRegOff.Y, 0));
            m.Multiply(Matrix.RotationZ(-rotation));
            m.Multiply(Matrix.Translation(pntRegOff.X, -pntRegOff.Y, 0));

            EPointF pntLoc = new EPointF(rctDrawTarget.X - rctView.Width / 2, rctDrawTarget.Y - rctView.Height / 2);
            m.Multiply(Matrix.Translation(pntLoc.X, -pntLoc.Y, 0f));
            m.M43 = 9000f;

            return m;
        }
示例#49
0
        public PathInfo(ImageResource imgRes)
            : base(imgRes)
        {
            BinaryPSDReader reader = imgRes.GetDataReader();

            this.PathNum = this.ID - 2000;
            this.ID = 2000;

            ushort numKnots = 0;
            int cnt = 0;
            this.Commands = new List<object>();
            while (reader.BytesToEnd > 0)
            {
                RecordType rtype = (RecordType)(int)reader.ReadUInt16();
                //Should always start with PathFill (0)
                if (cnt == 0 && rtype != RecordType.PathFill)
                    throw new Exception("PathInfo start error!");

                switch (rtype)
                {
                    case RecordType.InitialFill:
                        reader.BaseStream.Position += 1;
                        bool allPixelStart = reader.ReadBoolean();
                        reader.BaseStream.Position += 22;
                        break;

                    case RecordType.PathFill:
                        if (cnt != 0)
                            throw new Exception("Path fill?!?");
                        reader.BaseStream.Position += 24;
                        break;

                    case RecordType.Clipboard:
                        ERectangleF rct = new ERectangleF();
                        rct.Top = reader.ReadPSDSingle();
                        rct.Left = reader.ReadPSDSingle();
                        rct.Bottom = reader.ReadPSDSingle();
                        rct.Right = reader.ReadPSDSingle();
                        Clipboard clp = new Clipboard();
                        clp.Rectangle = rct;
                        clp.Scale = reader.ReadPSDSingle();
                        reader.BaseStream.Position += 4;
                        this.Commands.Add(clp);
                        break;

                    case RecordType.ClosedPathLength:
                    case RecordType.OpenPathLength:
                        numKnots = reader.ReadUInt16();
                        reader.BaseStream.Position += 22;
                        NewPath np = new NewPath();
                        np.Open = (rtype == RecordType.OpenPathLength);
                        this.Commands.Add(np);
                        break;

                    case RecordType.ClosedPathBezierKnotLinked:
                    case RecordType.ClosedPathBezierKnotUnlinked:
                    case RecordType.OpenPathBezierKnotLinked:
                    case RecordType.OpenPathBezierKnotUnlinked:
                        BezierKnot bz = new BezierKnot();

                        EPointF[] pts = new EPointF[3];
                        for (int i = 0; i < 3; i++)
                        {
                            float y = reader.ReadPSDFixedSingle(); //y comes first...
                            pts[i] = new EPointF(reader.ReadPSDFixedSingle(), y) / 256;
                        }
                        bz.Control1 = pts[0];
                        bz.Anchor = pts[1];
                        bz.Control2 = pts[2];
                        bz.Linked = (rtype == RecordType.ClosedPathBezierKnotLinked || rtype == RecordType.OpenPathBezierKnotLinked);
                        //bz.Open = (rtype == RecordType.OpenPathBezierKnotLinked || rtype == RecordType.OpenPathBezierKnotUnlinked);

                        this.Commands.Add(bz);
                        numKnots--;
                        break;
                }
                cnt++;
            }

            reader.Close();
        }
示例#50
0
 private static void NormalizeRect(ref ERectangleF rct)
 {
     if (rct.Width < 0)
     {
         rct.Offset(rct.Width,0);
         rct.Width = -rct.Width;
     }
     if (rct.Height < 0)
     {
         rct.Offset(0,rct.Height);
         rct.Height = -rct.Height;
     }
 }