Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 169787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:41:34+00:00 2026-05-11T12:41:34+00:00

I have been trying to draw an annulus (ring with thickness) with a transparent

  • 0

I have been trying to draw an annulus (ring with thickness) with a transparent hole and a gradient rim in C# with very little success. Does anyone have any suggestions on how to do this?

here’s a nice Blend Utility

Here’s the Final result – thanks to BlueMonkMN

 Rectangle GetSquareRec(double radius, int x, int y)     {         double r = radius;         double side = Math.Sqrt(Math.Pow(r, 2) / 2);         Rectangle rec = new Rectangle(x - ((int)side), y - ((int)side), (int)(side * 2) + x, (int)(side * 2) + y);          return rec;     }     void Form1_Paint(object sender, PaintEventArgs e)     {           Graphics gTarget = e.Graphics;         gTarget.SmoothingMode = SmoothingMode.AntiAlias;           GraphicsPath pTemp = new GraphicsPath();          Rectangle r = GetSquareRec(200, 225, 225);         pTemp.AddEllipse(r);         pTemp.AddEllipse(GetSquareRec(50, 225, 225));          Color[] colors = new Color[5];         colors[0] = Color.FromArgb(192, 192, 192);         colors[1] = Color.FromArgb(105, 0, 0);         colors[2] = Color.FromArgb(169, 169, 169);         colors[3] = Color.FromArgb(0, 0, 0);         colors[4] = Color.FromArgb(0, 0, 0);          float[] positions = new float[5];         positions[0] = 0f;         positions[1] = 0.1f;         positions[2] = 0.35f;         positions[3] = 0.5f;         positions[4] = 1f;          ColorBlend Cb = new ColorBlend();         Cb.Colors = colors;         Cb.Positions = positions;          PathGradientBrush pgb = new PathGradientBrush(pTemp);         pgb.InterpolationColors = Cb;         pgb.CenterPoint = new PointF(r.X + (r.Width / 2), r.Y + (r.Height / 2));         gTarget.FillPath(pgb, pTemp);      } 

http://www.freeimagehosting.net/uploads/th.515733e62e.jpg

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T12:41:35+00:00Added an answer on May 11, 2026 at 12:41 pm

    This is how I did it in the Scrolling Game Development Kit:

    pTemp = new GraphicsPath(); pTemp.AddEllipse(Start.X, Start.Y, End.X - Start.X, End.Y - Start.Y); pTemp.AddEllipse((Start.X * 3 + End.X) / 4f,                  (Start.Y * 3 + End.Y) / 4f,                  (End.X - Start.X) / 2f,                  (End.Y - Start.Y) / 2f); PathGradientBrush pgb = new PathGradientBrush(pTemp); Blend b = new Blend(); b.Factors = new float[] { 0, 1, 1 }; b.Positions = new float[] { 0, .5F, 1 }; pgb.Blend = b; pgb.CenterColor = ((SolidBrush)CurrentBrush).Color; pgb.SurroundColors = new Color[] {CurrentPen.Color}; gTarget.FillPath(pgb, pTemp); pgb.Dispose(); pTemp.Dispose(); 

    annulus screenshot
    (source: enigmadream.com)

    I edited the original SGDK code for this sample because originally I wasn’t smart enough to scale the gradient to exclude the hole, but now I guess I am :).

    If you would rather see the gradient like this:

    alt text
    (source: enigmadream.com)

    Then change the blend code to look like this:

    Blend blend = new Blend(); blend.Factors = new float[] { 0, 1, 0, 0 }; blend.Positions = new float[] { 0, 0.25F, .5F, 1 }; pgb.Blend = blend; 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new to android development and have been trying to draw a
I have been trying to implement Win32's MessageBox using GTK. The app uses SDL/OpenGL,
I have been trying to find a really fast way to parse yyyy-mm-dd [hh:mm:ss]
I have been trying to determine a best case solution for registering a COM
I have been trying to work my way through Project Euler, and have noticed
I have been trying to get around this error for a day now and
I have been trying to explain the difference between switch statements and pattern matching(F#)
I have been trying to read a picture saved in Access DB as a
I have been trying to learn multi-threaded programming in C# and I am confused
I have been trying to make a case for using Python at my work.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.