Monthly Archives: December 2015

Make a truncated cube in WPF and C#

Sorry but this is a pretty long post with a lot of details. If you don’t want to read about how the example program does its tricks, you can just read the first section and look at the pretty pictures. … Continue reading

Posted in algorithms, graphics, mathematics, wpf | Tagged , , , , , , , , , , , , | 1 Comment

Initialize a Dictionary in C#

The post Initialize two-dimensional arrays in C# explains how to initialize a two-dimensional array. Even though a Dictionary is a more complicated data type, you can use a similar method to initialize one. Simply enclose each of the Dictionary‘s key/value … Continue reading

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

A quick note about the .NET Graphics book Kickstarter

Several people have told me, “I will definitely buy the book when it’s finished.” Unfortunately that’s not the way Kickstarter works. You need to sign up now to receive a copy of the book. If we reach the project goal, … Continue reading

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

Draw round circles in scaled coordinate systems in C#

In other posts I explain how you can use transformations to draw objects in a coordinate system other than the one provided “natively” by a PictureBox, Bitmap, and other objects that support drawing. Basically a transformation (represented by a Matrix … Continue reading

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

Initialize an array of arrays in C#

The example Initialize two-dimensional arrays in C# explains how to initialize a two-dimensional array. An array of arrays is somewhat similar to a two-dimensional array but with some syntax differences. The following code shows how this example declares and initializes … Continue reading

Posted in arrays, syntax | Tagged , , , , , , , , , , , | Leave a comment

Perform binary contrast enhancement interactively in C#

The example Perform binary contrast enhancement on an image in C# performs binary contrast enhancement by setting each pixel to black or white depending on whether the sum of its red, green, and blue component values is greater than 3 … Continue reading

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

Perform binary contrast enhancement on an image in C#

In binary contrast enhancement, you change every pixel in an image to either black or white depending on whether it is brighter than some cutoff value. This example takes a simple approach and makes a pixel white if the sum … Continue reading

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

Initialize two-dimensional arrays in C#

The example Initialize arrays, lists, and class instances in C# explains how to initialize a one-dimensional array. You can use a similar syntax to initialize multi-dimensional arrays. Use a new statement to indicate the type of array you are initializing. … Continue reading

Posted in arrays, syntax | Tagged , , , , , , , , , , | 1 Comment

Draw text with a moving brush in C#

This example uses a technique similar to the one used by the example Make a moving background in C#. It uses a gradient brush to draw its text. When the program’s Timer fires, its Tick event handler refreshes the PictureBox … Continue reading

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

Make a moving background in C#

This example displays text with a moving background color gradient. The following ShadeRect method contains the program’s most interesting code. // Fill the rectangle with a gradient that // shades from red to white to red. private void ShadeRect(Graphics gr, … Continue reading

Posted in drawing, graphics | Tagged , , , , , , , , , , | 1 Comment