Here goes... I need to draw several annular sectors in VisualBasic.NET using a GraphicsPath
.
I would for instance enter the annular sector's outer and inner diameter/radius and a starting and ending degree/radiant. The function must then return a GraphicsPath
that can simply be added to another GraphicsPath
as a closed shape. This seems very easy to do, but I need it to keep a 5 pixel gap between the annular sectors.
I will explain more... If for instance I enter 0 degrees as starting point and 360 degrees as ending point it must return a GraphicsPath
with an annular sector that starts at X degrees (where X is 2.5 pixels offset from 0 degrees) and ends at Y degrees (where Y is -2.5 pixels offset from 360 degrees). Both the outer and inner curves of the annular sector must adhere to the above. It basically must be as if I drew two parallel lines 5 pixels apart through the circle's center at the degrees entered and used the lines as starting and ending points for the arcs. This must hold true for any Degrees entered.
This post: SVG donut slice as path element (annular sector) Almost solves the problem, but it draws all annular sectors from the center point (not unlike Pie slices) outwards causing consecutive outer rings to have bigger and bigger gaps in between if you split them with 1 Degree each time (plus it is for SVG).
I include an image explaining what I am trying to say better: https://onedrive.live.com/redir?resid=79292E5BC057FE03!112&authkey=!AMnkq0bjbsH4BwU&v=3&ithint=photo%2cjpg
This question was solved by valter. Scroll down to EDIT 2 in his answer for the code.
This image: (https://onedrive.live.com/redir?resid=79292E5BC057FE03!113&authkey=!AGxrnpf8MiiEX48&v=3&ithint=photo%2cjpg) shows what can be achieved with his solution.
The following code was used to create the GraphicsPath
used to draw the pie and annular sectors in the image. At the time of writing this negative sweepA
(sweep angle) was not supported.
Dim p As GraphicsPath = New GraphicsPath()
p.AddPie(160.0F, 160.0F, 280.0F, 280.0F, 300.0F, 90.0F)
p.AddPath(DrawAnnular(New Point(300I, 300I), 100I, 70I, 300.0F, 90.0F, 5.0R), False)
p.AddPath(DrawAnnular(New Point(300I, 300I), 100I, 70I, 30.0F, 80.0F, 5.0R), False)
p.AddPath(DrawAnnular(New Point(300I, 300I), 135I, 105I, 300.0F, 90.0F, 5.0R), False)
p.AddPath(DrawAnnular(New Point(300I, 300I), 135I, 105I, 30.0F, 80.0F, 5.0R), False)
Thanks
drifter