/// <summary> /// Creates a font object with the correct size to be placed on a player. /// /// Must be disposed of by the calling code. /// </summary> /// <param name="converter"></param> /// <returns></returns> internal static Font CreatePlayerIdFont(PitchScreenCoordConverter converter) { // The player width and length in screen coordinates cannot be 0 // or the drawing will crash. int playerDiameterScreen = converter.pitchToScreenLength(Settings.Default.PlayerDiameter); if (playerDiameterScreen == 0) playerDiameterScreen = 1; int fontSize = playerDiameterScreen > 2 ? playerDiameterScreen - 2 : playerDiameterScreen; Font font = new Font("consolas", fontSize, FontStyle.Regular, GraphicsUnit.Pixel); return font; }
/// <summary> /// The pitch is drawn as a pair of rectangles rather than as a sprite. /// /// All conversion between pitch coordinates and screen coordinates is done /// internally. /// </summary> /// <param name="display"></param> /// <param name="converter"></param> public void DrawPitch(Graphics display, PitchScreenCoordConverter converter) { Rectangle outerPitch = new Rectangle(); Rectangle innerPitch = new Rectangle(); using (Pen linePen = new Pen(mLineColor, mLineWidth)) { Point bottomRight = converter.pitchToScreenCoords( new PointF(sPitchWidth, sPitchLength)); Point innerBottomRight = converter.pitchToScreenCoords( new PointF(sPitchWidth, (sPitchLength - 2.0f * sEndzoneDepth))); Point leftBrick = converter.pitchToScreenCoords( new PointF(sPitchWidth / 2.0f, sEndzoneDepth + sBrickDistance)); Point rightBrick = converter.pitchToScreenCoords( new PointF(sPitchWidth / 2.0f, sPitchLength - sEndzoneDepth - sBrickDistance)); int brickDistanceScreen = converter.pitchToScreenLength(sBrickRadius); outerPitch.Location = converter.pitchToScreenCoords(new PointF(0.0f, 0.0f)); outerPitch.Width = bottomRight.X; outerPitch.Height = bottomRight.Y; innerPitch.Location = converter.pitchToScreenCoords(new PointF(0.0f, sEndzoneDepth)); innerPitch.Width = innerBottomRight.X; innerPitch.Height = innerBottomRight.Y; display.FillRectangle(mPitchBrush, outerPitch); display.DrawRectangle(linePen, outerPitch); display.DrawRectangle(linePen, innerPitch); DrawCross(display, linePen, leftBrick, brickDistanceScreen); DrawCross(display, linePen, rightBrick, brickDistanceScreen); } }