BLOG.CSHARPHELPER.COM: Draw a non-intersecting star in C#
Draw a non-intersecting star in C#
The NonIntersectingStarPoints function generates the points needed to draw a non-intersecting star and returns them in an array.
// Return PointFs to define a non-intersecting star. private PointF[] NonIntersectingStarPoints( int num_points, Rectangle bounds) { // Make room for the points. PointF[] pts = new PointF[2 * num_points];
The function allocates room for two PointFs for each of the star's points, one for the point and one for the inside corner next to the point. It then uses a loop to generate the PointFs. The variable theta determines the direction of each point form the center of the star. For each theta value, the program creates the point and the neighboring inside corner.
The program uses this function as shown in the following code.
Comments