Draw a filled chrysanthemum curve in C#

filled chrysanthemum curve

This example is very similar to Draw a chrysanthemum curve in C# except it draws a filled chrysanthemum curve. It fills the curve by coloring the triangles connecting each of the curve segments to the origin. The following code shows how the program fills the triangles.

Color the_color = GetColor(t);

// Fill the triangle from this edge to the origin.
the_brush.Color = Color.FromArgb(64,
    the_color.R, the_color.G, the_color.B);
PointF[] pts = { pt0, pt1, new PointF(0, 0) };
e.Graphics.FillPolygon(the_brush, pts);

// Draw the curve's outer edge.
the_pen.Color = the_color;
e.Graphics.DrawLine(the_pen, pt0, pt1);

The fill color has opacity 64 so it is only 64/256 = 25% opaque and previously drawn triangles can show through.

See the previous example for details about how the program calculates the curve’s points.

Download Example   Follow me on Twitter   RSS feed   Donate

This entry was posted in algorithms, fractals, graphics, mathematics and tagged , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.