Category Archives: geometry

Draw an interesting pattern of circles in C#

This program simply draws an interesting arrangement of circles. I wrote it because a C# Helper post was mentioned on this Factal [sic] Patterns & Art page. This program uses the following code to draw the circles and connecting lines. … Continue reading

Posted in algorithms, drawings, geometry, graphics, mathematics | Tagged , , , , , , , , , , , , | Leave a comment

Circumscribe three tangent circles in C#

The first step in the example Draw an Apollonian gasket in C# is to circumscribe three circles that all meet tangentially with a larger circle as shown in this example. In the previous example I glossed over how the program … Continue reading

Posted in algorithms, drawing, geometry, graphics, mathematics | Tagged , , , , , , , , , , , , , , , | Leave a comment

Find the shortest distance between a point and a line segment in C#

This example treats the segment as parameterized vector where the parameter t varies from 0 to 1. It finds the value of t that minimizes the distance from the point to the line. If t is between 0.0 and 1.0, … Continue reading

Posted in algorithms, geometry, graphics, mathematics | Tagged , , , , , , , , , , , , , , | 21 Comments

Make a Region from non-transparent pixels in C#

The example Make shaped PictureBoxes in C# sets the Region property of two PictureBox controls to circular regions. That works well in that example where the images are round volleyballs with transparent backgrounds, but it would be hard to manually … Continue reading

Posted in algorithms, geometry, graphics, image processing | Tagged , , , , , , , , , , , , , | Leave a comment

Make shaped PictureBoxes in C#

This example shows how to use regions to make shaped PictureBoxes. The PNG image format allows you to define transparent pixels. As you might guess, if you draw an image with transparent pixels, those pixels are not drawn and whatever … Continue reading

Posted in algorithms, geometry, graphics, image processing | Tagged , , , , , , , , , , , , , , , , , | 1 Comment

Draw smooth cones using WPF and C#

The example Draw cones using WPF and C# shows how to draw cones in WPF and C#. This example shows how to draw smooth cones. Or at least smoother cones. To make smooth cones, the program simply ensures that adjacent … Continue reading

Posted in algorithms, drawing, geometry, graphics, mathematics, wpf, XAML | Tagged , , , , , , , , , , , , , , , , , , | 1 Comment

Draw cones using WPF and C#

This example shows how to draw cones in WPF and C#. The program uses a method very similar to the one used by the example Draw cylinders using WPF and C#. The picture on the right shows the approach used … Continue reading

Posted in algorithms, drawing, geometry, graphics, mathematics, wpf, XAML | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | 1 Comment

Fill and draw pie slices in C#

Of the many methods for filling and drawing shapes provided by the Graphics class, DrawPie and FillPie are two of the most confusing. These methods draw and fill elliptical pie slices. They take as parameters: A brush or pen indicating … Continue reading

Posted in geometry, graphics | Tagged , , , , , , , , , , | 2 Comments

Draw a hexagonal grid in C#

The post Draw a triangular grid in C# shows how to draw a triangular grid. This post shows how to make a similar hexagonal grid. Row and column numbering is a bit easier with a hexagonal grid than it is … Continue reading

Posted in algorithms, drawing, geometry, graphics, mathematics | Tagged , , , , , , , , , , , , , , , | Leave a comment

Get font metrics in a WPF program using C#

This example explains how to get font metrics in a WPF application. It’s actually not too hard, it’s just hard to figure out how to do it. The font metrics are tucked away inside the FormattedText object and the Typeface … Continue reading

Posted in drawing, geometry, graphics, wpf, XAML | Tagged , , , , , , , , , , , , , , , , , , , , , | Leave a comment