I'm having problems with the DrawLine method.
Eg. I call DrawLine with x1 and y1 being a point inside the WriteableBitmap and x2 and y2 being a point outside. I would expect that the line to be drawn would be clipped at the point where it intersects with the boundary of the WriteableBitmap. In
stead it seems that x2 is set to 0 if it is below 0 and to the width of the WriteableBitmap if it is above the width of the WriteableBitmap. The same goes for y2 but with the height of the WriteableBitmap as the max value.
This behavior is very apparent in the following example:
bmp.DrawLine(0, -100, 400, -20, Colors.Red);
This is a line that is outside the WriteableBitmap and I wouldn't expect it to draw anything on the bmp. None the less that's what it does. A red line is drawn from (0, 0) to (400, 0) because y1 and y2 are set to 0 when they are below 0.
I guess this is by design, but wouldn't it make more sense to clip it?
I've tried to calculate the intersection and change the endpoint of my line to the intersection point, but this is too slow for my application. Well my intersection code is slow, but it could probably be done faster.