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 522919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:24:13+00:00 2026-05-13T08:24:13+00:00

Drawing circles on PostScript is easy, and I’m surprised that PDF apparently doesn’t carry

  • 0

Drawing circles on PostScript is easy, and I’m surprised that PDF apparently doesn’t carry over those same primitives. There are plenty of commercial libraries that will do it, but shouldn’t it be simpler than that?

There are also some tricks using Bézier curves, but you don’t get a perfect circle and you have to draw them in connecting segments. I don’t need a perfect circle as long as it look close to perfect.

I’m doing this as an addition to the PDF-EasyPDF Perl module, but the language isn’t the part I need help with.

  • 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-05-13T08:24:14+00:00Added an answer on May 13, 2026 at 8:24 am

    That’s always going to be the case. PDF doesn’t have circles in the primitives, only beziers. The PDF imaging model was built from the PostScript imaging model, which itself only provides circles using the arc/arcto primitives, which themselves are implemented in terms of beziers.

    Oddly enough, I had call to do this exact task in some test code I’m working on that generates PDF’s. Here’s how I did it:

        private void DrawEllipse(PdfGraphics g, double xrad, double yrad)
        {
            const double magic = 0.551784;
            double xmagic = xrad * magic;
            double ymagic = yrad * magic;
            g.MoveTo(-xrad, 0);
            g.CurveTo(-xrad, ymagic, -xmagic, yrad, 0, yrad);
            g.CurveTo(xmagic, yrad, xrad, ymagic, xrad, 0);
            g.CurveTo(xrad, -ymagic, xmagic, -yrad, 0, -yrad);
            g.CurveTo(-xmagic, -yrad, -xrad, -ymagic, -xrad, 0);
        }
    
        private void DrawCircle(PdfGraphics g, double radius)
        {
            DrawEllipse(g, radius, radius);
        }
    

    Assume that PdfGraphics is a class that spews out PDF commands, so g.MoveTo(x, y) will turn into “x y m” in the content stream. I took my math and my magic number from Don Lancaster’s fabulous explanation (PDF, naturally). This assumes that the circle or ellipse will be drawn at the origin. To move it somewhere else, do a translation transform first or modify the code to subtract add in the desired origin. This code gives a worst case error of roughly 1/1250 (about .08 %) and average of 1/2500 (about .04%).

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

Sidebar

Ask A Question

Stats

  • Questions 301k
  • Answers 301k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try implementing the - (void) viewDidAppear:(BOOL)animated method to display the… May 13, 2026 at 8:11 pm
  • Editorial Team
    Editorial Team added an answer You could have your service operation return some kind of… May 13, 2026 at 8:11 pm
  • Editorial Team
    Editorial Team added an answer Description of Rspec says: RSpec is the original Behaviour Driven… May 13, 2026 at 8:11 pm

Related Questions

I have an image that the user can zoom/scroll. I want to draw some
I'm creating an application where I will be drawing two circles onto the screen,
I have an opengl scene rendering on an EAGLView layer and some other elements
I've been looking for a good cross-platform 2D drawing library that can be called
I'm having an odd issue with CALayer drawing for the iPhone. I have a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.