Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Drawing pie with parts excluded.

Drawing pie with parts excluded.

Scheduled Pinned Locked Moved .NET (Core and Framework)
comgraphicsquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AndrewVos
    wrote on last edited by
    #1

    Hi all, I'm trying to find a way to draw a sort of section of a pie. Check this image: http://img186.imageshack.us/img186/9095/piesectionsqv7.png[^] I'm trying to draw an antialiased line around the blue section. I have filled that blue section by adding a pie to a path, then adding another pie using the size of the inner circle, which effectively removes the inner ellipse area. I can't get the same code working for drawing a border line. The only other way I can think of is using regions and Exclude, but this will break antialiasing. Am I missing something here? PS. I can't change my draw order, because the image could contain transparent sections. Thanks in advance


    www.wickedorange.com www.andrewvos.com

    A realJSOPR 2 Replies Last reply
    0
    • A AndrewVos

      Hi all, I'm trying to find a way to draw a sort of section of a pie. Check this image: http://img186.imageshack.us/img186/9095/piesectionsqv7.png[^] I'm trying to draw an antialiased line around the blue section. I have filled that blue section by adding a pie to a path, then adding another pie using the size of the inner circle, which effectively removes the inner ellipse area. I can't get the same code working for drawing a border line. The only other way I can think of is using regions and Exclude, but this will break antialiasing. Am I missing something here? PS. I can't change my draw order, because the image could contain transparent sections. Thanks in advance


      www.wickedorange.com www.andrewvos.com

      A Offline
      A Offline
      AndrewVos
      wrote on last edited by
      #2

      Err, sorry I didn't see GDI+ when I hovered over the Graphics section :zzz:


      www.wickedorange.com www.andrewvos.com

      A 1 Reply Last reply
      0
      • A AndrewVos

        Err, sorry I didn't see GDI+ when I hovered over the Graphics section :zzz:


        www.wickedorange.com www.andrewvos.com

        A Offline
        A Offline
        AndrewVos
        wrote on last edited by
        #3

        Hmmm. This is a tad messy, but it works: public class PieWithExclusionEllipse : IDisposable { private GraphicsPath path; public GraphicsPath Path { get { return this.path; } } public PieWithExclusionEllipse(Rectangle pie, float startAngle, float sweepAngle, Rectangle exclusionEllipse) { GraphicsPath outerLine = new GraphicsPath(); GraphicsPath innerLine = new GraphicsPath(); outerLine = new GraphicsPath(); outerLine.AddPie(pie, startAngle, sweepAngle); if ((exclusionEllipse.Width != 0) && (exclusionEllipse.Height != 0)) { outerLine = this.removePointFromPath(outerLine, 0); outerLine = this.changePathPointType(outerLine, outerLine.PointCount - 1, PathPointType.Bezier); innerLine.AddPie(exclusionEllipse, startAngle, sweepAngle); innerLine = this.removePointFromPath(innerLine, 0); innerLine = this.changePathPointType(innerLine, innerLine.PointCount - 1, PathPointType.Bezier); innerLine.Reverse(); outerLine.AddPath(innerLine, true); outerLine.CloseFigure(); } this.path = outerLine; } private GraphicsPath changePathPointType(GraphicsPath path, int pointIndex, PathPointType pointType) { List points = new List(); List pointTypes = new List(); for (int index = 0; index < path.PointCount; index++) { points.Add(path.PathPoints[index]); if (index == pointIndex) { pointTypes.Add((byte)pointType); } else { pointTypes.Add(path.PathTypes[index]); } } return new GraphicsPath(points.ToArray(), pointTypes.ToArray()); } private GraphicsPath removePointFromPath(GraphicsPath path, int removeIndex) { List points = new List(); List pointTypes = new List(); for (int index = 0; index < path.PointCount; index++) { if (index != removeIndex) { points.Add(path.PathPoints[index]); pointTypes.Add(path.PathTypes[index]); } } return new GraphicsPath(points.ToArray(), pointTypes.ToArray()); } #region IDisposable Members public void Dispose() { if (this.path != null) { this.path.Dispose(); } } #endregion }


        www.wickedorange.com www.andrewvos.com

        1 Reply Last reply
        0
        • A AndrewVos

          Hi all, I'm trying to find a way to draw a sort of section of a pie. Check this image: http://img186.imageshack.us/img186/9095/piesectionsqv7.png[^] I'm trying to draw an antialiased line around the blue section. I have filled that blue section by adding a pie to a path, then adding another pie using the size of the inner circle, which effectively removes the inner ellipse area. I can't get the same code working for drawing a border line. The only other way I can think of is using regions and Exclude, but this will break antialiasing. Am I missing something here? PS. I can't change my draw order, because the image could contain transparent sections. Thanks in advance


          www.wickedorange.com www.andrewvos.com

          realJSOPR Offline
          realJSOPR Offline
          realJSOP
          wrote on last edited by
          #4

          Why don't you use ZedGraph? there's an article posted on CP about it.

          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
          -----
          "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups