0
votes

I use the following code to draw on a 32x32 px canvas, using the MouseMoveEvent to draw pixel sized rectangles and create Pixel graphics.

Ive created a class called RectItem

public class RectItem
    {
        public double X { get; set; }
        public double Y { get; set; }
        public double Width { get; set; }
        public double Height { get; set; }
        public SolidColorBrush Col { get; set; }
    }

and an ObservableCollection

public ObservableCollection<RectItem> RectItems { get; set; }

I add the pixel sized rectangle via (cv is the canvas with the binding to RectItems)

RectItem rec = new RectItem { X = (int)e.GetPosition(cv).X, Y = (int)e.GetPosition(cv).Y, Width = 1, Height = 1, Col = new SolidColorBrush(CurrentColor) };
RectItems.Add(rec);

This all works fine, but how would i go about adding a pixel ellipse(like the one you can use when creating a cursor file within VS)

like the following, just without the margins.PixelRectangle

1
In exactly the same way you've shown here. The difference would be in the ItemTemplate of the ItemsControl you're using to visualize your items. - Clemens

1 Answers

0
votes

Place rectangles where the pixels are plotted in a non-antialised ellipse drawing routine, e.g. Brensenham: https://sites.google.com/site/ruslancray/lab/projects/bresenhamscircleellipsedrawingalgorithm/bresenham-s-circle-ellipse-drawing-algorithm, making appropriate transformations and scalings etc.