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

Username:   Password: 
 RegisterRegister   
 Turing Graphics Help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
imnerdybutactuallynotnerd




PostPosted: Thu Nov 26, 2015 5:59 pm   Post subject: Turing Graphics Help

In Turing we just started basic graphics. For one of our assignments we have to center the box we made in the middle of the screen.
I made the box using random coordinates but it is not in the middle. Can someone please teach me how to center stuff in the middle? I looked through Turing tutorials
but found nothing on this. People in my class are doing maxx div 2 or something like that but I don't understand what maxx or maxy is and why you have to div them by 2.

This is my code so far without centering

drawline (90, 100, 100, 100, green)
drawline (90, 100, 90, 200, green)
drawline (190, 200, 90, 200, green)
drawline (190, 100, 190, 190, green)

P.S We are using Turing 4.1.1
Sponsor
Sponsor
Sponsor
sponsor
TokenHerbz




PostPosted: Thu Nov 26, 2015 11:08 pm   Post subject: RE:Turing Graphics Help

maxx means MAX X of screen. X is the horizonal axis.

maxy means MAX Y of screen, of the vertical.

so if your screen is 500x400, your maxx is 500 and maxy is 200, so div each by 2 gives you 250x200 x/y cords which is center, depending how you draw your box on it.

if you get a peice of graph paper and you mark some squars or lengths down you may grasp it a bit better, or try this example.

look at how the maxx/maxy are used, and then try to figure out how you use that to put it SMACK IN THE MIDDLE of your box (since your box needs to center, not the corner of it).

code:

setscreen("graphics:800;400")
Draw.FillBox(50,50,maxx,maxy,red)
Draw.FillBox(100,100,maxx div 2, maxy div 2, yellow)
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  [ 2 Posts ]
Jump to:   


Style:  
Search: