Tag Archives: example program

Create oval images in C#

This example lets you create oval images with transparent backgrounds. It includes some features such as menus that let you load and save files. Download the example to see those details. The more interesting part is the code that creates … Continue reading

Posted in Uncategorized | Tagged , , , , , , , , , , | Leave a comment

Draw a randomly colored Sierpinski octagon in C#

This example draws a randomly colored Sierpinski octagon. It’s basically the same as the example Draw a randomly colored Sierpinski pentagon in C# except it draws an octagon instead of a pentagon. See that example for most of the details. … Continue reading

Posted in algorithms, fractals, graphics, recursion | Tagged , , , , , , , , , , | Leave a comment

Let the user draw lines in C#

This example lets the user click and draw to draw lines. To make working with lines easier, the program uses the following Segment class. class Segment { public Pen Pen; public Point Point1, Point2; public Segment(Pen pen, Point point1, Point … Continue reading

Posted in drawing, events, graphics | Tagged , , , , , , , , , , , | Leave a comment

Use a standard Windows dialog to let the user select folders in C#

The .NET OpenFileDialog and SaveFileDialog are fairly full-featured. They’re a lot like Windows Explorer with some added file selection capabilities thrown in. In contrast, the FolderBrowserDialog is pretty pathetic. It only lets you use a hierarchical tree-like display, doesn’t provide … Continue reading

Posted in API, controls, files | Tagged , , , , , , , , , , , , , , , , | 13 Comments

Gary Beene’s gbUnSnarl game

Check out Gary Bene’s gbUnSnarl game. Your job is to drag the nodes in a network to unsnarl it. Basically it asks you to find a way to rearrange a planar network so none of its edges intersect. Algorithms to … Continue reading

Posted in algorithms, games | Tagged , , , , , , , , | Leave a comment

Find happy numbers in C#

Before I show you the code, let me explain what happy numbers are. Happy Numbers To find happy numbers, start with any integer. Replace it with the sum of the squares off its digits. Repeat the process until the numbers … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , | Leave a comment

Draw words on a circle in WPF and C#

This example shows one way that you can draw words on a circle in WPF. Note that it does not show how to draw words where each character is rotated to follow the circle’s curve. Each word is rotated as … Continue reading

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

Draw a hyperbolic spiral in C#

A hyperbolic spiral, which is also called an reciprocal spiral, is the inverse of an Archimedes spiral. It uses the equation r = A / θ to generate points on a spiral. This spiral has a couple of interesting properties. … Continue reading

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

Draw a logarithmic spiral in C#

The post Draw an Archimedes spiral in C# uses the equation r = A˙θ to generate the points on a spiral. This example is almost exactly the same except it uses the equation to r = A˙eB˙θ to generate its … Continue reading

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

Draw a filled spiral in C#

My post Draw an Archimedes spiral in C# explained how to draw multiple Archimedes spirals starting at a common center point. This post shows how you can fill the spaces between the spirals with colors. The basic idea is to … Continue reading

Posted in algorithms, graphics, mathematics | Tagged , , , , , , , , , , | 2 Comments