Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8541815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:54:59+00:00 2026-06-11T11:54:59+00:00

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

  • 0
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Test
{
    public partial class Form1 : Form
    {
        int circleDiameter;

        public Form1()
        {
            InitializeComponent();

            circleDiameter = 100;
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Point CenterPoint = new Point()
            {
                X = this.ClientRectangle.Width / 2,
                Y = this.ClientRectangle.Height / 2
            };
            Point topLeft = new Point()
            {
                X = (this.ClientRectangle.Width - circleDiameter) / 2,
                Y = (this.ClientRectangle.Height - circleDiameter) / 2
            };
            Point topRight = new Point()
            {
                X = (this.ClientRectangle.Width + circleDiameter) / 2,
                Y = (this.ClientRectangle.Height - circleDiameter) / 2
            };
            Point bottomLeft = new Point()
            {
                X = (this.ClientRectangle.Width - circleDiameter) / 2,
                Y = (this.ClientRectangle.Height + circleDiameter) / 2
            };
            Point bottomRight = new Point()
            {
                X = (this.ClientRectangle.Width + circleDiameter) / 2,
                Y = (this.ClientRectangle.Height + circleDiameter) / 2
            };

            e.Graphics.DrawEllipse(Pens.Red,topLeft.X, topLeft.Y, circleDiameter, circleDiameter);
            e.Graphics.DrawLine(Pens.Red, CenterPoint, topLeft);
            e.Graphics.DrawLine(Pens.Red, CenterPoint, topRight);
            e.Graphics.DrawLine(Pens.Red, CenterPoint, bottomLeft);
            e.Graphics.DrawLine(Pens.Red, CenterPoint, bottomRight); 
        }
    }
}

The result is a circle in the center of the Form and inside an X but the X is getting out of the circle bounds and i want the X inside the topLeft topRight bottomLeft bottomRight to get exactly to the circle bounds. How can i repair it ?

Before it was e.Graphics.DrawEllipse it was e.Graphics.DrawRectangle and it was ok but once i changed it to DrawEllipse the X inside is getting out of the circle bounds borders.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:55:00+00:00Added an answer on June 11, 2026 at 11:55 am

    It’s been a while since I’ve done this. You can use Cos and Sin to calculate a point on a circle, something like this:

        private Point GetPointOnCircle(Point centre, double angle, double diameter)
        {
            return new Point((int)(Math.Cos(angle) * diameter) + centre.X, (int)(Math.Sin(angle) * diameter) + centre.Y);
        }
    

    I can’t remember if cos is x or y but it doesn’t really matter it just changes what you consider to be the 0 degree point on the circle. Anyway, because your angle is always 45 degrees and cos(45) and sin(45) are the same you just need to multiply your distance by 0.70710678118654752440084436210485 or as someone said 1/sqrt(2)

    eg

            Point topRight = new Point()
            {
                X = (this.ClientRectangle.Width + (int)(circleDiameter * 0.70710678118654752440084436210485)) / 2,
                Y = (this.ClientRectangle.Height - (int)(circleDiameter * 0.70710678118654752440084436210485)) / 2
            };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.