Skip to main content

Posts

Showing posts with the label Graphics

...

....

C# - Creating Rounded Rectangles Using A Graphics Path [Beginner]

Do you ever do UI development in C#? Do you know what a GraphicsPath is, or how to use it? No? Well, then this tutorial is for you. We will be covering how to create a graphics path and use it, by coding a way to easily create and draw rounded rectangles. When we are done, you will have a set of functions for creating rounded rectangles, and hopefully a new way to think about certain types of custom painting in C#. First off, what is a graphics path? The short tooltip in Visual Studio is that a graphics path "represents a series of lines and curves." All well and good, but what that really means is that you can easily create and work with custom shapes. What we are going to cover today only scratches the surface of what can be done with a graphics path, but for more information you can always read the MSDN documentation . So lets get down to it - lets create a rounded rectangle. Now, like any rectangle, we are going to need an (x,y) coordinate for the upper left