Category Archives: geometry

Make silly eyes that track the mouse without flicker in C#

The example Make silly eyes that track the mouse in C# shows how to make eyes track the mouse position, but if you look closely as that program runs you will see a noticeable flicker. The solution is quite simple: … Continue reading

Posted in games, geometry, graphics | Tagged , , , , , , , , , , , , | 1 Comment

Make silly eyes that track the mouse in C#

This example uses a Timer named tmrTick to track the mouse. Its Tick event handler, which is shown in the following code, updates the eyes. // The previous mouse location. private Point OldMousePos = new Point(-1, -1); // See if … Continue reading

Posted in games, geometry, graphics | Tagged , , , , , , , , , , , , | 1 Comment

Make a 3D globe in WPF and C#

This example shows how you can draw a 3D globe. More generally it shows how you can make a three-dimensional textured sphere in WPF. The example Draw smooth spheres using WPF and C# shows how to make smooth colored spheres. … Continue reading

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

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