# Tag Archives: ellipse

## Use XAML and code behind to draw and outline shapes with gradients in WPF and C#

My unofficial slogan for WPF is, “Twice and flexible and only five times as hard,” and that applies to working with gradients. Gradients are undoubted cool and very flexible, but they are verbose and a bit tricky to use. How … Continue reading

## Use sines and cosines to draw circles and ellipses in C#

This example shows how you can use trigonometric functions to draw circles. It’s such a basic technique that I often forget that it’s not completely obvious to everyone. Given a radius R and an angle θ, the equations x = … Continue reading

## Calculate where a line segment and an ellipse intersect in C#

Finding the intersection between a line segment and an ellipse requires a lot of mathematics. It’s not particularly hard mathematics, but if you’d rather skip it, you can use the following links to jump to the other parts of this … Continue reading

## Determine which pie slice is under the mouse in C#

When the program starts, the following code initializes the pie chart’s parameters. // The pie chart’s center. private Point EllipseCenter; // The pie chart’s drawing area. private Rectangle EllipseRect; // The ellipse’s X and Y radii. private float EllipseRx, EllipseRy; … Continue reading

## Let the user draw rubber band ellipses (or other shapes) in C#

The following code shows how the program lets the user draw rubber band ellipses. // The ellipses to draw. private List<Rectangle> Ellipses = new List<Rectangle>(); // The points for the new ellipse we are drawing. private Point StartPoint, EndPoint; private … Continue reading

## Render an ellipse in a WPF program using C#

This example shows how you can render an ellipse in a WPF program. Normally to draw shapes in WPF you use some sort of object. You can add Ellipse, Line, Path, Polygon, Polyline, and Rectangle objects to a window and … Continue reading

Posted in drawing, geometry, graphics, wpf, XAML | | 2 Comments

## Draw on a bitmap in C#

This example shows how you can draw on a bitmap and display the result on a form. The example Draw in a Paint event handler in C# shows how to draw in a form’s Paint event handler. This is simple, … Continue reading

Posted in drawing, graphics | | 4 Comments

## Draw in a Paint event handler in C#

Using images and drawing in the Paint event handler are the two most common ways to display graphics. Drawing in the Paint event handler is easy, but there are a couple of things you should keep in mind when you … Continue reading

Posted in drawing, graphics | | 24 Comments

## See where a line intersects a conic section in C#

This example shows how you can see where a line intersects a conic section. You can use the more general method described in the post See where two conic sections intersect in C#. This example takes advantage of the simpler … Continue reading

## See where two conic sections intersect in C#

This example uses techniques demonstrated in several earlier posts to let you see where two conic sections intersect. To use the example, click the left mouse button five times each to select one conic section> Then click the right mouse … Continue reading