Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Quick question on co-ordinates
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
xHoly-Divinity




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Tue Nov 30, 2004 10:50 pm   Post subject: (No 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).
Mazer




PostPosted: Wed Dec 01, 2004 8:40 am   Post subject: (No 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).
wtd




PostPosted: Wed Dec 01, 2004 2:05 pm   Post subject: (No 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
SuperGenius




PostPosted: Wed Dec 01, 2004 5:41 pm   Post subject: (No subject)

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




PostPosted: Wed Dec 01, 2004 6:27 pm   Post subject: (No 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: