
-----------------------------------
xHoly-Divinity
Tue Nov 30, 2004 10:20 pm

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?

-----------------------------------
Delos
Tue Nov 30, 2004 10:50 pm


-----------------------------------
No, you can't change this.  But, you can alter your code to make as if your centre is in the middle...


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).


-----------------------------------
Mazer
Wed Dec 01, 2004 8:40 am


-----------------------------------
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:
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).

-----------------------------------
wtd
Wed Dec 01, 2004 2:05 pm


-----------------------------------
Ack!  All of those variables...

Records, people, records!  :)

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

-----------------------------------
SuperGenius
Wed Dec 01, 2004 5:41 pm


-----------------------------------
Records might be a little confusing for a lot of people...I never learned them in gr. 10 myself.

-----------------------------------
wtd
Wed Dec 01, 2004 6:27 pm


-----------------------------------
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.
