Computer Science Canada

Quick question on co-ordinates

Author:  xHoly-Divinity [ Tue Nov 30, 2004 10:20 pm ]
Post subject:  Quick question on co-ordinates

Ok, the default location for the coordinates (0,0) is at location 0,0 (bottom left corner). I was wondering if you could change this to set the default location of 0,0 in the middle because I am making a graph and this would be much easier..... is this possible?

Author:  Delos [ Tue Nov 30, 2004 10:50 pm ]
Post subject: 

No, you can't change this. But, you can alter your code to make as if your centre is in the middle...

code:

var cX, cY : int
% Centre x and y.

cX := maxx div 2
cY := maxy div 2
% set them to centres.

drawline (cX, cY, cX + 100, cY + 100, 7)
% Draw a line from (0, 0) [by your new coords] to (100, 100).

Author:  Mazer [ Wed Dec 01, 2004 8:40 am ]
Post subject: 

And if you don't want to be adding to the coordinates each time manually, you could make your own draw procedures that just call the regular ones.

eg:
code:
procedure myDrawFillBox(x1, y1, x2, y2, clr : int)
    drawfillbox(x1 + 50, y1 + 50, x2 + 50, y2 + 50, clr)
end myDrawFillBox

In this case, we're making the origin 50. You could change that to whatever you'd like (it'd probably be best to make that a constant so you could make changes easier).

Author:  wtd [ Wed Dec 01, 2004 2:05 pm ]
Post subject: 

Ack! All of those variables...

Records, people, records! Smile

code:
type Point :
   record
      x, y : int := 0
   end record

var center, max : Point

max.x := 80
max.y := 24

center.x = max.x div 2
center.y = max.y div 2

Author:  SuperGenius [ Wed Dec 01, 2004 5:41 pm ]
Post subject: 

Records might be a little confusing for a lot of people...I never learned them in gr. 10 myself.

Author:  wtd [ Wed Dec 01, 2004 6:27 pm ]
Post subject: 

SuperGenius wrote:
Records might be a little confusing for a lot of people...I never learned them in gr. 10 myself.


Everything's confusing the first time you see it. You just have to use them to get used to them.


: