Can DrawLine handle coordinates outside the defined area?
For example myGraphics.DrawLine(MyPen, -20, -80, 20, 90);
I would expect this to produce a line correctly as though it had used an infinite canvas but plotting only the section within my graphic.
My code is as follows. I am plotting movement from coordinates recorded in a database. Occasionally the subject moves further than expected, beyond the edges of my bitmap. I do not check for this occurrence as I was relying on DrawLine to handle it.
Bitmap Border = new Bitmap(5000, 5000);
Border.SetResolution(254, 254);
Graphics MyGraphics= Graphics.FromImage(Border);
Pen MyPen = new Pen(Color.Black, 1);
for (Int32 Point = 1; Point <= Points; Point++)
{
XCoord2 = XCoord1;
YCoord2 = YCoord1;
XCoord1 = *READ FROM DATABASE*
YCoord1 = *READ FROM DATABASE*
if (Point > 1)
{
MyGraphics.DrawLine(MyPen, XCoord1, YCoord1, XCoord2, YCoord2);
}
}
In reality, my plots work most of the time. However I do get an occasional graphic with missing lines or with an obscure line originating from a strange coordinate.
In summary, should the behaviour of DrawLine predictable with unusual parameters. Should I introduce some trigonometry to force the plots to always be within my grid?