PDFsharp & MigraDoc Foundation http://forum.pdfsharp.com/ |
|
ExcludeClip in PDFSharp.Drawing.XGraphics? http://forum.pdfsharp.com/viewtopic.php?f=4&t=2382 |
Page 1 of 1 |
Author: | inexorabletash [ Sun Mar 24, 2013 12:01 am ] |
Post subject: | ExcludeClip in PDFSharp.Drawing.XGraphics? |
Basically, a request for implementation of XCombineMode.Exclude support so that XGraphics.ExcludeClip can be implemented. I use the GDI+ build and target GDI+ and PDF. |
Author: | rtseuztz [ Thu Jun 30, 2022 9:36 pm ] | ||
Post subject: | Re: ExcludeClip in PDFSharp.Drawing.XGraphics? | ||
I have spent about a week figuring out how to do this and I finally have. To simulate an exclude path,
2. Add the shapes you want removed from the final shape. ex: Code: clipPath.AddRectangle(temp.X , temp.Y , width , height)
** For paths/polygons, instead of adding paths to the clip path, you should: a. call Code: clipPath.StartFigure() b. Add all of the lines from your path/polygon into the clip path. Code: clipPath.AddLine(oldPoint, newPoint) c. call Code: clipPath.CloseFigure() d. Do this for each path you have. 4. Set the clip path's fill mode to alternate. This is the even-odd fill that SVGs and other stuff has. Code: clipPath.FillMode = XFillMode.Alternate 5. Call the intersect clip on your XGraphics object with this clip path. Code: gfx.IntersectClip(clipPath) 6. Draw the final shape with your XGraphics object. This should be the same shape you added in step 3. Code: gfx.DrawRectangle(xPen, xBrush, bigRect.X, bigRect.Y, bigWidth, bigHeight) You can also call gfx.Save() before clipping and gfx.Restore() after drawing the final rectangle if you want. I am 9 years late but hopefully this helps others.
|
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |