Author Archives: RodStephens

About RodStephens

Rod Stephens is a software consultant and author who has written more than 30 books and 250 magazine articles covering C#, Visual Basic, Visual Basic for Applications, Delphi, and Java.

Find drawn characters under the mouse in C#

The following examples find the positions of drawn characters in a string that is drawn by using the Graphics object’s DrawString method. Measure character positions in a drawn string in C# Measure character positions when drawing long strings in C# … Continue reading

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

Clip an image to a polygon in C#

This example lets you select a polygon and then uses it to clip an image to it. It uses the technique described in my previous post Build a polygon selector class in C# to let you select the polygon. The … Continue reading

Posted in drawing, graphics, image processing | Tagged , , , , , , , , , | Leave a comment

Build a polygon selector class in C#

This example shows how to make a polygon selector class that makes it easy to let the user select a polygon. I call this kind of class that provides a service for another class a symbiont. In a symbiotic relationship, … Continue reading

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

Arrange images on the corners of a polygon in C#

This post shows a way to arrange images on top of a background image as shown in the image above. How to Use the Program Enter the names of the background and foreground image files, or use the File menu’s … Continue reading

Posted in graphics, image processing, mathematics | Tagged , , , , , , , , , | Leave a comment

Make an improved diagonal picture montage in C#

My earlier example Make a Pinterest-style diagonal picture montage in C# showed how you could make a picture montage showing parts of images rotated by a desired angle. While using that program today I found a small bug. The areas … Continue reading

Posted in drawing, graphics, image processing, tools | Tagged , , , , , , , , , , , , , | Leave a comment

Use VBA to randomize Excel selections

The post Use VBA to randomize cells in Excel explains how you can randomize a simple selection’s rows. Unfortunately that method cannot randomize Excel selections in general. In particular it doesn’t work if the current selection includes multiple areas on … Continue reading

Posted in Excel, VBA | Tagged , , , , , , , , , , | Leave a comment

Understand range areas in Excel VBA

Most of my VBA examples assume that the current selection is a single block of cells. If the selection includes a single area, then you can easily loop through the cells that it contains. Unfortunately if the selection includes multiple … Continue reading

Posted in Excel, VBA | Tagged , , , , , , , , , | 1 Comment

Let the user draw rotated skewed polygons in C#

The example Let the user draw rotated polygons with right angles in C# draws polygons with edges that are parallel or perpendicular to a baseline. This example is very similar except its polygons have edges that are parallel to one … Continue reading

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

Let the user draw rotated polygons with right angles in C#

This example lets the user draw rotated polygons where all edges are either parallel or perpendicular to a defined baseline direction. As a result, all of the polygon’s angles are right angles. (And yes, I know that the polygons aren’t … Continue reading

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

Let the user save an image of a smooth curve in C#

The post Let the user draw a smooth curve in C# shows how you can let the user draw a smooth curve. This example extends that one to let you save the curve in an image file. There are a … Continue reading

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