PDFsharp & MigraDoc Foundation http://forum.pdfsharp.com/ |
|
Drawing partial circles inside rectangles http://forum.pdfsharp.com/viewtopic.php?f=2&t=4568 |
Page 1 of 1 |
Author: | jdavey1996 [ Fri Mar 22, 2024 12:56 pm ] |
Post subject: | Drawing partial circles inside rectangles |
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); |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |