different drawing origin

Hello!

Does anyone know a nice way to draw on a graphics-object with an origin at the bottom-left corner

+

|
|

0/0 -- +

I know that the default origin is top-left and positive coordinates will extent to bottom-right:

0/0 -- +

|
|

+

Any ideas would be greatly appreciated...

Greetings,
chris



Answer this question

different drawing origin

  • IrvineLewis

    Yes, your code sample was exactly correct. It works without modifications!

    Thanks again,
    .chris

  • #LS

    Easiest way to do it is a matrix transform. You need a y scale value of  -1, to flip the orientation, and an y offset equal to the height of the canvas (clientsize), to move the origin to the bottom. So
    Matrix m = new Matrix();
    m.Scale(1F, -1F);
    m.OffsetY = -ClientSize.Height;

    graphics.Transform = m;

    I did not test -- check the sign on the offset.
    Frank

  • Ben Kitzelman

    Thanks for your replies... I hoped there would be an slightly different method available because matrix transformation requires me to know the exact height of the document.

    I'll test it as soon as possible!

    Greetings,
    chris

  • angelLee

    This is what I thought too, but that flips the image . . .   If a graphic is drawn with respect to standard (0,0), then negating the Y values will flip the image rather than move it.  A vector/scalar transform is needed here.  But, not quite sure how to do that...
  • robbyduffy

    You need both the flip (from the -1 scaling on the y axis) and the offset (from the top to the bottom) to get the right transform.
  • different drawing origin