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

  • Home
  • SEARCH
  • 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 8699063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:51:25+00:00 2026-06-13T01:51:25+00:00

I am trying to draw an ellipse onto an html5 canvas by defining a

  • 0

I am trying to draw an ellipse onto an html5 canvas by defining a rectangle via the mouse. I can do this but using my current method, the ellipse is not snuggly fitting into my bounding rectangle. How I can draw this ellipse so it fits perfectly into it’s bounding rectangle?

Here is what I have:

    var a1x = self.x;
    var a1y = self.y - self.h / 2;

    var a2x = self.x;
    var a2y = self.y + self.h / 2;

    var c1x = self.x + self.w / 2;
    var c1y = self.y - self.h / 2;
    var c2x = self.x + self.w / 2;
    var c2y = self.y + self.h / 2;

    var c3x = self.x - self.w / 2;
    var c3y = self.y + self.h / 2;
    var c4x = self.x - self.w / 2;
    var c4y = self.y - self.h / 2;

    context.beginPath();
    context.moveTo(a1x, a1y);

    context.bezierCurveTo(
        c1x, c1y,
        c2x, c2y,
        a2x, a2y
    );

    context.bezierCurveTo(
        c3x, c3y,
        c4x, c4y,
        a1x, a1y
    );

    context.fillStyle = "red";
    context.fill();
    context.closePath();
    context.strokeRect(this.x - this.w / 2, this.y - this.h / 2, this. w, this.h);
  • 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-13T01:51:27+00:00Added an answer on June 13, 2026 at 1:51 am
    CanvasRenderingContext2D.prototype.ellipse =
        CanvasRenderingContext2D.prototype.ellipse ||
            function(x, y, width, height)
            {
                this.save();
                this.translate(x - width/2, y - height/2);
                this.scale(width, height);
                this.arc(0, 0, 1, 0, 2 * Math.PI, false);
                this.restore();
            };
    
    CanvasRenderingContext2D.prototype.circle =
        CanvasRenderingContext2D.prototype.circle ||
            function(x, y, radius)
            {
                this.arc(x, y, radius, 0, 2 * Math.PI, false);
            };
    

    You must call beginPath before and stroke or fill after in order to see them, as with any other path element.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to draw in a web worker using html5 canvas. The worker
ok i can draw ellipse the problem is this, im trying to draw one
I am trying to draw over a canvas by clicking and dragging the mouse.
I'm trying to draw an open rectangle using a Polygon: int[] xPoints = {1,1,3,3};
I'm trying to draw a circle in WP7 Silverlight using EllipseGeometry instead of Ellipse.
I am trying to draw a line using the Graphics 2D but then the
Im trying to draw a Text on a surfaceview using a canvas. The problem
I'm trying draw canvas on a new one but not only to draw it,
I'm trying to draw an ellipse on a particular location of the window upon
I am trying to use System.Drawing.Drawing2D.GraphicsPath.AddArc to draw an arc of an ellipse starting

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.