PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Nov 10, 2024 7:24 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Fri Mar 22, 2024 12:56 pm 
Offline

Joined: Fri Mar 22, 2024 12:50 pm
Posts: 1
Hi,

I have a rectangle that has width 150mm and height 200mm. I also have a circle that is 200mm.

I've drawn the rectangle.
I'm trying to calculate how to draw an arc that is only the portion of the circle that can fit inside the rectangle.
I can do this manually with the code below, but I'm not sure how to calculate the start and sweep angle of the arc.

Example files of expected output - https://we.tl/t-6RsQRG8qk7

Code:
PdfDocument document = new PdfDocument();
        PdfPage page = document.AddPage();
        XGraphics gfx = XGraphics.FromPdfPage(page, XGraphicsUnit.Millimeter);
        XPen pen = new XPen(XColors.Black, 1); // Pen for drawing

        // Rectangle properties
        double rectWidth = 150;
        double rectHeight = 200;

        // Circle properties
        double circleDiameter = 200;

        gfx.DrawRectangle(pen, 10, 10, rectWidth, rectHeight);

        gfx.DrawArc(pen, 10, 10, circleDiameter, circleDiameter, 60, 240); // Right straight side
        gfx.DrawArc(pen, -40, 10, circleDiameter, circleDiameter, 240, 240); // Left straight side

        const string filename = "TEST1.pdf";
        document.Save(filename);


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group