GraphicsWindow coordinate system origin RRS feed

  • General discussion

  • The coordinates system’s origin for GraphicsWindow is on the upper left corner. This is legacy from the ancient times when it was easy to manage coordinates this way due to memory positions in the video driver buffer.

    The most frequently used coordinate system outside computer's world has the origin in the lower left corner; this is the one we usually see in line or bar charts.

    But probably the most intuitive one has the origin in the center of the window (this is the approach taken by MIT’s Scratch, for example).

    Since for me the primary target audiences of Small Basic are programming illiterate grown up kids and teenagers, I guess it’s important to use a coordinate system they’re familiar with; and IMHO, this is not the one currently used.


    Furthermore, perhaps it has sense to allow the programmer to switch between origins, using something like GraphicsWindow.Origin = Center, GraphicsWindow.Origin = UpperLeftCorner, and GraphicsWindow.Origin = LowerLeftCorner or whatever.


    What do you think?

    Saturday, February 28, 2009 9:09 PM

All replies

  • And what would happens when the window gets resized ? The 'origin' would move ? It's not possible to make consistent UI with that assessement.

    No, the reason of the 'top-center' is only that it's the most consistent way to place objects (for the LTR language systems).
    Fremy VB & C#
    Saturday, February 28, 2009 10:24 PM
  • Perhaps I'm missing something, but I can't see any issue with resizing. When the window gets resized, the center is still the center. Distance from center to borders will change, in the same way distances to (opposite) borders change when the origin is in the left-top corner.

    Monday, March 2, 2009 5:25 AM
  • If the origin moves, you must update your objects' position all the time.

    Then, if you want to put an object on the screen, you will need to introduction Window.Width and Window.Height in the position (because you first need to compute the center).

        Obj.Position = new Point(0, 0) // Top-left used
        Obj.Position = new Point(-Obj.ParentWindow.Width/2, -Obj.ParentWindow.Height/2) // Center used
        // And if you don't have any reference to the ParentWindow ? How do you place your menubar at top of the window ?

    As you usually have to put an object relatives to the top-left of the window, and not its center, you usually prefer the 'top-left' anchoring.
    Fremy VB & C#
    Monday, March 2, 2009 5:38 PM
  • I do not think to location of the origin is that big an issue.  I would prefer it to be in the lower left just to make things a little bit more friendly but most users adjust in about 30 seconds.  If the center starts floating around I am afraid our nice little Small Basic might not be so little.  Besides, it is free.
    Monday, March 2, 2009 7:48 PM
  • First and foremost, thank you so much for taking the time to explaining your point with such a great detail.

    1. I'm not proposing to permantly switching the coordinates origin, so if most of the time you're in the scenario you just described, just keep the origin in the upper-left corner.
    2. On the other side, if you want to use Small Basic for teaching, I'm prety sure it's easier and more natural to use the coordinates origin in the center of the screen. When you draw on a blank sheet of paper, usually you do it in the center, not in the upper-left corner (as opposed to write a letter, for example). Can you imagine young kids trying to draw a house or a stick figure using the origin in the upper-left corner? There's a bunch of calculations involved in putting things in the right place, and if this is not the subject being taught, it's just noise.
    3. Again, thinking on Small Basic as a teaching tool, I guess it's easy for teachers (and kids, but mostly for teachers) if the language provides a coordinate system they're familiar with.
    Monday, March 2, 2009 8:32 PM
  • fmachado said:

    3. Again, thinking on Small Basic as a teaching tool, I guess it's easy for teachers (and kids, but mostly for teachers) if the language provides a coordinate system they're familiar with.

    I agree, the language should provide a coordinate system students are familar with. The thing is, most students are going to be more familiar with graphics/image editing software then they are with the algebraic coordinate plane.

    Most students have experience with one graphics editor or another. All of the ones I can think of, Paint, Photoshop, even Gimp all place the origin (0,0) in the upper left corner.

    Placing 0,0 in the center rather then the upper left corner would be more confusing to anyone who has spent more time with computers then with a math book (at this point pretty much anyone under 18).

    Monday, March 2, 2009 8:40 PM