Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on a project creating a gauge package in software, but I am posting here because it is more of a mathematical question.

In short, I need a function to create a color gradient to fill in the rest of the rim of the gauge (See images below).

The graphics software allows you to draw a radial gradient by specifying the center and radius for two circles. You specify color stops by giving it a positional value between 0 and 1. It then draws the gradient between the two curves of the circle.

The part that I am stuck on is that the angle of the connecting color changes based on the angle of the gauge. Therefore, it seems like the circles defining the gradient are dependent on the angle of the gauge.

Any help that you could provide would be great. If you need any further information, please feel free to ask.

share|cite|improve this question
up vote 2 down vote accepted

The gradient shouldn't depend on the angle; the only thing that should change is the angle of the circle sector that connects the two sides.

By the way, if you want the outer edges of the rim to join together smoothly, that angle should be the supplement of the inner angle, not equal to it as you've shown in the pictures. That way, you also won't need to change the radius of the corners depending on the angle (although you seem to have figured out a formula for that already, unless you drew those pictures by hand).

Here's a quick sketch I drew in GeoGebra to show what I mean:

$\hspace{130px}$Illustration of circle sector with offset border

Here, the three small circles all have radius $r$, and the angle $\beta = 180^\circ - \alpha$. All other corners between the black lines (and circles) in this picture are (multiples of) $90^\circ$.

share|cite|improve this answer
Using the supplemental angle to find the inner arc did the trick. I ended up setting it equal to the angle because the formula for the lines were more apparent at first. I always forget the simple things, like supplement angles, lol. Thank you for your time and your help. – jyore Nov 29 '11 at 19:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.