コード例 #1
0
        private void DrawGoals(Graphics g)
        {
            Point[] uprights = new Point[8];
            for (int i = 0; i < 4; ++i)
            {
                Coords temp = StaticMathFunctions.SpacePointToDisplayPointTransform(Constants.Uprights[i]);
                uprights[i] = new Point((Int32)(temp.X * _zoom), (Int32)(temp.Y * _zoom));
            }

            double zmultiplierTop    = 0.5 + 0.5 * StaticMathFunctions.SpacePointToDisplayPointZAxis(Constants.GoalTop);
            double zmultiplierBottom = 0.5 + 0.5 * StaticMathFunctions.SpacePointToDisplayPointZAxis(Constants.GoalBottom);

            uprights[4] = new Point(uprights[0].X, (Int32)(uprights[0].Y - Constants.GoalHeight * zmultiplierTop * _zoom));
            uprights[5] = new Point(uprights[1].X, (Int32)(uprights[1].Y - Constants.GoalHeight * zmultiplierBottom * _zoom));
            uprights[6] = new Point(uprights[2].X, (Int32)(uprights[2].Y - Constants.GoalHeight * zmultiplierTop * _zoom));
            uprights[7] = new Point(uprights[3].X, (Int32)(uprights[3].Y - Constants.GoalHeight * zmultiplierBottom * _zoom));

            Pen drawPen = new Pen(Color.Red);

            // Uprights
            g.DrawLine(drawPen, uprights[0], uprights[4]);
            g.DrawLine(drawPen, uprights[1], uprights[5]);
            g.DrawLine(drawPen, uprights[2], uprights[6]);
            g.DrawLine(drawPen, uprights[3], uprights[7]);
            // Crossbars
            g.DrawLine(drawPen, uprights[4], uprights[5]);
            g.DrawLine(drawPen, uprights[6], uprights[7]);
            drawPen.Dispose();
        }
コード例 #2
0
        /*
         * // Used for displaying the grid.
         * private void TileDrawRectangle(Graphics graphicsObj, Coords position)
         * {
         *  RectangleF box = GetRectangle(position);
         *  graphicsObj.DrawRectangle(new Pen(Color.Black), box.X, box.Y, box.Width, box.Height);
         * }
         */
        /*
         * private void TileDrawCoordinates(Graphics g, Coords position)
         * {
         *  StringFormat strFormat = new StringFormat();
         *  strFormat.Alignment = StringAlignment.Center;
         *
         *
         *  g.DrawString(position.ToString(), new Font("Tahoma", Constants.FontSize / 2), Brushes.Black,
         *      new PointF((position.X + 0.5f) * Constants.TileBitmapSize * this._zoom, (position.Y + 0.5f) *
         *          Constants.TileBitmapSize * this._zoom), strFormat);
         * }
         */

        #endregion

        #region Pixel drawers

        private void DrawBitmapAtPixel(Graphics g, Coords pixel, Bitmap image)
        {
            Coords screenPos = StaticMathFunctions.SpacePointToDisplayPointTransform(pixel.X, pixel.Y);

            Point anchor = new Point((Int32)(screenPos.X * _zoom - 0.5f * image.Width), (Int32)(screenPos.Y * _zoom - image.Height));

            // This should be at the middle of the bottom of the image.
            //Point anchor = new Point((Int32)(pixel.X * this._zoom - 0.5f * image.Width), (Int32)(pixel.Y * this._zoom - image.Height));
            g.DrawImageUnscaled(image, anchor);
        }
コード例 #3
0
        // Draws an upper label on a tile (or rather Footballer). Should make it
        // nicer later with color choice, etc.
        private void DrawLabel(Graphics graphicsObj, Vector2d position, String label)
        {
            Coords transformed = StaticMathFunctions.SpacePointToDisplayPointTransform(position.X, position.Y);

            StringFormat strFormat = new StringFormat();

            strFormat.Alignment = StringAlignment.Center;

            graphicsObj.DrawString(label, new Font("Tahoma", Constants.FontSize), Brushes.Black,
                                   new PointF(transformed.X * this._zoom, transformed.Y * this._zoom), strFormat);
        }
コード例 #4
0
        private void DrawLine(Graphics g, Vector2d a, Vector2d b)
        {
            Coords start   = StaticMathFunctions.SpacePointToDisplayPointTransform(a.X, a.Y);
            PointF anchorA = new PointF((start.X * _zoom), (start.Y * _zoom));

            Coords end     = StaticMathFunctions.SpacePointToDisplayPointTransform(b.X, b.Y);
            PointF anchorB = new PointF((end.X * _zoom), (end.Y * _zoom));

            Pen drawPen = new Pen(Color.Red);

            g.DrawLine(drawPen, anchorA, anchorB);
            drawPen.Dispose();
        }
コード例 #5
0
        private void FillPlayerEllipse(Graphics g, Vector2d center, double radx, double rady, Color teamColor)
        {
            Coords transformedCenter = StaticMathFunctions.SpacePointToDisplayPointTransform(center.X, center.Y);

            Point anchor = new Point((Int32)(transformedCenter.X * _zoom), (Int32)(transformedCenter.Y * _zoom));

            Color TransparentColor = Color.FromArgb(80, teamColor.R, teamColor.G, teamColor.B);
            Brush myBrush          = new SolidBrush(TransparentColor);

            g.FillEllipse(myBrush, (Int32)(anchor.X - radx), (Int32)(anchor.Y - rady),
                          (Int32)(radx * 2), (Int32)(rady * 2));

            myBrush.Dispose();
        }
コード例 #6
0
        private void DrawNetZAxis(Graphics g, UInt16 Xposition)
        {
            Pen drawPen = new Pen(Constants.NetsColor);

            // y -axis
            for (sbyte i = 0; i <= (Constants.GoalBottom - Constants.GoalTop) / Constants.NetsSpacing; ++i)
            {
                Int32  yval        = Constants.GoalTop + i * Constants.NetsSpacing;
                Coords leftEnd     = StaticMathFunctions.SpacePointToDisplayPointTransform(Xposition, yval);
                Coords rightEnd    = StaticMathFunctions.SpacePointToDisplayPointTransform(Xposition + Constants.NetsDepth, yval);
                PointF anchorLeft  = new PointF((leftEnd.X * _zoom), (leftEnd.Y * _zoom));
                PointF anchorRight = new PointF((rightEnd.X * _zoom), (rightEnd.Y * _zoom));
                //Coords threadEnd = StaticMathFunctions.SpacePointToDisplayPointTransform(Xposition, Constants.GoalTop + i * Constants.NetsSpacing);
                double zmultiplier = 0.5 + 0.5 * StaticMathFunctions.SpacePointToDisplayPointZAxis(yval);
                float  Zoffset     = (float)(Constants.GoalHeight * _zoom * zmultiplier);

                g.DrawLine(drawPen, anchorLeft.X, anchorLeft.Y - Zoffset, anchorRight.X, anchorRight.Y - Zoffset);
            }

            // x-axis

            double zmultiplierNear = 0.5 + 0.5 * StaticMathFunctions.SpacePointToDisplayPointZAxis(Constants.GoalBottom);
            double zmultiplierFar  = 0.5 + 0.5 * StaticMathFunctions.SpacePointToDisplayPointZAxis(Constants.GoalTop);

            float ZoffsetNear = (float)(Constants.GoalHeight * _zoom * zmultiplierNear);
            float ZoffsetFar  = (float)(Constants.GoalHeight * _zoom * zmultiplierFar);

            for (sbyte i = 0; i <= Constants.NetsDepth / Constants.NetsSpacing; ++i)
            {
                Coords postNear = StaticMathFunctions.SpacePointToDisplayPointTransform(Xposition + i * Constants.NetsSpacing, Constants.GoalBottom);
                Coords postFar  = StaticMathFunctions.SpacePointToDisplayPointTransform(Xposition + i * Constants.NetsSpacing, Constants.GoalTop);

                PointF anchorNear = new PointF((postNear.X * _zoom), (postNear.Y * _zoom));
                PointF anchorFar  = new PointF((postFar.X * _zoom), (postFar.Y * _zoom));

                g.DrawLine(drawPen, anchorNear.X, anchorNear.Y - ZoffsetNear, anchorFar.X, anchorFar.Y - ZoffsetFar);
            }

            drawPen.Dispose();
        }
コード例 #7
0
        private void DrawNetXAxis(Graphics g, UInt16 Xposition, UInt16 Yposition)
        {
            Pen drawPen = new Pen(Constants.NetsColor);

            double zmultiplier = 0.5 + 0.5 * StaticMathFunctions.SpacePointToDisplayPointZAxis(Yposition);
            float  Zoffset     = (float)(Constants.GoalHeight * _zoom * zmultiplier);

            // Vertical
            for (sbyte i = 0; i <= (Constants.NetsDepth) / Constants.NetsSpacing; ++i)
            {
                //Int32 yval = Constants.GoalTop + i * Constants.NetsSpacing;
                Coords threadStart = StaticMathFunctions.SpacePointToDisplayPointTransform(Xposition + i * Constants.NetsSpacing, Yposition);
                PointF anchor      = new PointF((threadStart.X * _zoom), (threadStart.Y * _zoom));
                //Coords threadEnd = StaticMathFunctions.SpacePointToDisplayPointTransform(Xposition, Constants.GoalTop + i * Constants.NetsSpacing);



                g.DrawLine(drawPen, anchor.X, anchor.Y, anchor.X, anchor.Y - Zoffset);
            }

            // Horizontal
            Coords leftEnd  = StaticMathFunctions.SpacePointToDisplayPointTransform(Xposition, Yposition);
            Coords rightEnd = StaticMathFunctions.SpacePointToDisplayPointTransform(Xposition + Constants.NetsDepth, Yposition);

            PointF anchorLeft  = new PointF((leftEnd.X * _zoom), (leftEnd.Y * _zoom));
            PointF anchorRight = new PointF((rightEnd.X * _zoom), (rightEnd.Y * _zoom));

            //double zmultiplierLeft = 0.5 + 0.5 * StaticMathFunctions.SpacePointToDisplayPointZAxis(Constants.GoalBottom);
            //double zmultiplierRight = 0.5 + 0.5 * StaticMathFunctions.SpacePointToDisplayPointZAxis(Constants.GoalTop);

            for (sbyte i = 0; i <= Constants.GoalHeight / Constants.NetsSpacing; ++i)
            {
                float delataZoffset = (float)(i * Constants.NetsSpacing * _zoom * zmultiplier);
                //float ZoffsetFar = (float)(i * Constants.NetsSpacing * _zoom * zmultiplier);
                g.DrawLine(drawPen, anchorLeft.X, anchorLeft.Y - delataZoffset, anchorRight.X, anchorRight.Y - delataZoffset);
            }

            drawPen.Dispose();
        }
コード例 #8
0
        private void DrawNetYAxis(Graphics g, UInt16 Xposition)
        {
            Pen drawPen = new Pen(Constants.NetsColor);

            // Vertical
            for (sbyte i = 0; i <= (Constants.GoalBottom - Constants.GoalTop) / Constants.NetsSpacing; ++i)
            {
                Int32  yval        = Constants.GoalTop + i * Constants.NetsSpacing;
                Coords threadStart = StaticMathFunctions.SpacePointToDisplayPointTransform(Xposition, yval);
                PointF anchor      = new PointF((threadStart.X * _zoom), (threadStart.Y * _zoom));
                //Coords threadEnd = StaticMathFunctions.SpacePointToDisplayPointTransform(Xposition, Constants.GoalTop + i * Constants.NetsSpacing);
                double zmultiplier = 0.5 + 0.5 * StaticMathFunctions.SpacePointToDisplayPointZAxis(yval);
                float  Zoffset     = (float)(Constants.GoalHeight * _zoom * zmultiplier);

                g.DrawLine(drawPen, anchor.X, anchor.Y, anchor.X, anchor.Y - Zoffset);
            }

            // Horizontal
            Coords postNear = StaticMathFunctions.SpacePointToDisplayPointTransform(Xposition, Constants.GoalBottom);
            Coords postFar  = StaticMathFunctions.SpacePointToDisplayPointTransform(Xposition, Constants.GoalTop);

            PointF anchorNear = new PointF((postNear.X * _zoom), (postNear.Y * _zoom));
            PointF anchorFar  = new PointF((postFar.X * _zoom), (postFar.Y * _zoom));

            double zmultiplierNear = 0.5 + 0.5 * StaticMathFunctions.SpacePointToDisplayPointZAxis(Constants.GoalBottom);
            double zmultiplierFar  = 0.5 + 0.5 * StaticMathFunctions.SpacePointToDisplayPointZAxis(Constants.GoalTop);

            for (sbyte i = 0; i <= Constants.GoalHeight / Constants.NetsSpacing; ++i)
            {
                float ZoffsetNear = (float)(i * Constants.NetsSpacing * _zoom * zmultiplierNear);
                float ZoffsetFar  = (float)(i * Constants.NetsSpacing * _zoom * zmultiplierFar);
                g.DrawLine(drawPen, anchorNear.X, anchorNear.Y - ZoffsetNear, anchorFar.X, anchorFar.Y - ZoffsetFar);
            }

            drawPen.Dispose();
        }
コード例 #9
0
        private void DrawSomeBall(Graphics g, Ball someball, Image ballImage)
        {
            Coords ballPos = StaticMathFunctions.SpacePointToDisplayPointTransform(someball.Position3d.X, someball.Position3d.Y);

            Point anchor = new Point((Int32)(ballPos.X * _zoom), (Int32)(ballPos.Y * _zoom));

            Int32 radiusX = (Int32)(0.5 * ballImage.Width);
            Int32 radiusY = (Int32)(0.5 * ballImage.Height);

            double zmultiplier = 0.5 + 0.5 * StaticMathFunctions.SpacePointToDisplayPointZAxis(someball.Position3d.Y);

            Int32 Zoffset = (Int32)(someball.Position3d.Z * _zoom * zmultiplier);

            Color color            = Color.Black;
            Color TransparentColor = Color.FromArgb(150, color.R, color.G, color.B);

            // draw shadow.
            g.FillEllipse(new SolidBrush(TransparentColor), (Int32)(anchor.X - radiusX * zmultiplier), (Int32)(anchor.Y),
                          (Int32)(radiusX * 2 * zmultiplier), (Int32)(radiusY * zmultiplier));

            // draw ball
            g.DrawImage(ballImage, (float)(anchor.X - radiusX * zmultiplier), (float)(anchor.Y - (radiusY) * zmultiplier) - Zoffset,
                        (float)(2 * radiusX * zmultiplier), (float)(2 * radiusX * zmultiplier));
        }