Drawing a wheel

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eric

    #1

    Drawing a wheel

    I need to draw a wheel. It should look about like the Wheel of Fortune wheel. I also need to be able to change the colors in each section. I know how to draw circles and lines but I have no idea how to fill each section with different colors. Can someone post a little sample code. Perhaps a circle in 2 pieces that you can change the color?
  • Sunil TG

    #2
    Drawing a wheel

    DrawArc() and FillRegion() methods inside System.Drawing
    namespace are the methods you might prabably be looking
    for.... but I'm sorry I don't have any sample code with
    me...

    HTH
    Sunil
    [color=blue]
    >-----Original Message-----
    >I need to draw a wheel. It should look about like the[/color]
    Wheel of Fortune wheel. I also need to be able to change
    the colors in each section. I know how to draw circles
    and lines but I have no idea how to fill each section with
    different colors. Can someone post a little sample code.
    Perhaps a circle in 2 pieces that you can change the color?[color=blue]
    >.
    >[/color]

    Comment

    • Nicholas Paldino [.NET/C# MVP]

      #3
      Re: Drawing a wheel

      Eric,

      You will want to use the FillRegion method on the Graphics class to fill
      the region of the "wheel" that you are painting. Basically, the region will
      consist of the rounded part of the slice, as well as the sides. You will
      want to use an instance of the GraphicsPath class to create a path that
      defines the region.

      Hope this helps.


      --
      - Nicholas Paldino [.NET/C# MVP]
      - mvp@spam.guard. caspershouse.co m

      "Eric" <anonymous@disc ussions.microso ft.com> wrote in message
      news:4954F3FC-E4C7-4E06-B422-6563E3940305@mi crosoft.com...[color=blue]
      > I need to draw a wheel. It should look about like the Wheel of Fortune[/color]
      wheel. I also need to be able to change the colors in each section. I know
      how to draw circles and lines but I have no idea how to fill each section
      with different colors. Can someone post a little sample code. Perhaps a
      circle in 2 pieces that you can change the color?


      Comment

      • Eric

        #4
        RE: Drawing a wheel

        I see how fillRegion() works but I don't see how to adapt it to the parts of the circle. They are pie shaped.

        Comment

        • Nicholas Paldino [.NET/C# MVP]

          #5
          Re: Drawing a wheel

          Eric,

          You will have to define the region, using lines and arcs to declare your
          "slices" of the pie. You can use the GraphicsPath class to do this, and
          then get a region from that.


          --
          - Nicholas Paldino [.NET/C# MVP]
          - mvp@spam.guard. caspershouse.co m

          "Eric" <anonymous@disc ussions.microso ft.com> wrote in message
          news:CFBABABD-65B5-4D14-ADAA-3ACC264385FB@mi crosoft.com...[color=blue]
          > I see how fillRegion() works but I don't see how to adapt it to the parts[/color]
          of the circle. They are pie shaped.


          Comment

          • Michael A. Covington

            #6
            Re: Drawing a wheel

            "Eric" <anonymous@disc ussions.microso ft.com> wrote in message
            news:4954F3FC-E4C7-4E06-B422-6563E3940305@mi crosoft.com...[color=blue]
            > I need to draw a wheel. It should look about like the Wheel of Fortune[/color]
            wheel. I also need to be able to change the colors in each section. I know
            how to draw circles and lines but I have no idea how to fill each section
            with different colors. Can someone post a little sample code. Perhaps a
            circle in 2 pieces that you can change the color?


            System.Graphics .Games.WheelOfF ortune.Wheel();

            (Just kidding!)


            Comment

            • Bob Powell [MVP]

              #7
              Re: Drawing a wheel

              Something like this perhaps?

              Random r=new Random(DateTime .Now.Millisecon d);

              private void Form1_Paint(obj ect sender, System.Windows. Forms.PaintEven tArgs
              e)

              {

              e.Graphics.Fill Ellipse(Brushes .BlanchedAlmond ,0,0,this.Clien tSize.Width,thi s
              ..ClientSize.He ight);

              for(double a=0; a<360; a+=30)

              {

              SolidBrush b=new SolidBrush(Colo r.FromArgb(r.Ne xt(255),
              r.Next(255),r.N ext(255)));

              e.Graphics.Fill Pie(b,10,10,thi s.ClientSize.Wi dth-20,this.ClientS ize.Height-2
              0,(float)a,25);

              }

              }


              --
              Bob Powell [MVP]
              C#, System.Drawing

              The October edition of Well Formed is now available.
              Find out how to use DirectX in a Windows Forms control


              Answer those GDI+ questions with the GDI+ FAQ


              Blog http://bobpowelldotnet.blogspot.com

              "Eric" <anonymous@disc ussions.microso ft.com> wrote in message
              news:4954F3FC-E4C7-4E06-B422-6563E3940305@mi crosoft.com...[color=blue]
              > I need to draw a wheel. It should look about like the Wheel of Fortune[/color]
              wheel. I also need to be able to change the colors in each section. I know
              how to draw circles and lines but I have no idea how to fill each section
              with different colors. Can someone post a little sample code. Perhaps a
              circle in 2 pieces that you can change the color?


              Comment

              Working...