2d Drawing

Windows specific forum
sbishop
New User
New User
Posts: 1
Joined: Wed Aug 23, 2006 11:31 am

2d Drawing

Post by sbishop »

Hi, I am new to Pure Basic and I am interested in doing 2d drawings. Playing with the 2D Drawing example I noticed that it plots the y from top to bottom. Is there an easy way to get it to plot from bottom to top?
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Y = BottomY-Y.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Is there an easy way to get it to plot from bottom to top?
It's a windows thing.

Basically, the orientation of the axes depend upon which 'mapping mode' is selected. The default mapping mode is what is referred to as #MM_TEXT, where of course text is read from top-to-bottom and left-to-right. Hence the orientation of the axes etc.

Now, whilst it is possible (using WIN API) to move the origin within the default mode, switching the axes around requires that we change mapping modes. For example, in the mode #MM_LOMETRIC, our origin is still the top-left of the screen (easily changed), but positive y-coordinates do indeed move up the screen. However, the #MM_LOMETRIC changes the 'scaling' of the coordinate axes and forces us to work in tenths of a millimetre rather than 'device coordinates' etc. Useful for many programs though.

It's a bit of a minefield if you're just starting out. Trond's suggestion will effectively place the origin at the bottom left of the screen, but you will still have the problem that positive y-coordinates move down the screen, so you'll need to take this into account.

E.g. to draw a line from the bottom left of the window, 10 units across (to the right), 20 units (up the screen) you'll need:

Code: Select all

Line(0, WindowHeight(#win), 10, -20)
etc.

If I were you I'd simply get used to working with the default origin / axes. It's not really a problem when you get used to it.
I may look like a mule, but I'm not a complete ass.
Post Reply