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

Username:   Password: 
 RegisterRegister   
 Help with using a canvas!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
chibitenshi_03




PostPosted: Wed Jan 07, 2004 6:37 pm   Post subject: Help with using a canvas!

umm..i have a canvas made using gui but when i draw lines it goes all over the place so i want to limit the user inside the canvas when drawing.
This is what i have:
import GUI
View.Set ("graphics:700;500,nobuttonbar")
var canvas : int := GUI.CreateCanvas (100, 55, 560, 360)
%The color panel
drawfillbox (8, 55, 72, 85, 114)
drawfillbox (8, 85, 72, 115, 7)
drawfillbox (8, 115, 72, 145, 31)
drawfillbox (8, 145, 72, 175, 8)
drawfillbox (8, 175, 72, 205, 11)
drawfillbox (8, 205, 72, 235, 58)
drawfillbox (8, 235, 72, 265, 60)
drawfillbox (8, 265, 72, 295, 108)
drawfillbox (8, 295, 72, 325, 42)
drawfillbox (8, 325, 72, 355, 48)
drawfillbox (8, 355, 72, 385, 44)
drawfillbox (8, 385, 72, 415, 40)
drawfillbox (8, 415, 72, 445, 33)
Mouse.ButtonChoose ("singlebutton")
var x, y, b, col, thickness, window, window2 : int
window := Window.Open ("position:top;center,graphics:300;200")
put "How thick do you want the line to be?"
get thickness
Window.Close(window)
loop
Mouse.Where (x, y, b)
if x >= 8 and x <= 72 and y >= 55 and y <= 85 and b = 1 then
col := 114
elsif x >= 8 and x <= 72 and y >= 85 and y <= 115 and b = 1 then
col := 7
elsif x >= 8 and x <= 72 and y >= 115 and y <= 145 and b = 1 then
col := 31
elsif x >= 8 and x <= 72 and y >= 145 and y <= 175 and b = 1 then
col := 8
elsif x >= 8 and x <= 72 and y >= 175 and y <= 205 and b = 1 then
col := 11
elsif x >= 8 and x <= 72 and y >= 205 and y <= 235 and b = 1 then
col := 58
elsif x >= 8 and x <= 72 and y >= 235 and y <= 265 and b = 1 then
col := 60
elsif x >= 8 and x <= 72 and y >= 265 and y < 295 and b = 1 then
col := 108
elsif x >= 8 and x <= 72 and y >= 295 and y < 325 and b = 1 then
col := 42
elsif x >= 8 and x <= 72 and y >= 325 and y < 355 and b = 1 then
col := 48
elsif x >= 8 and x <= 72 and y >= 355 and y < 385 and b = 1 then
col := 44
elsif x >= 8 and x <= 72 and y >= 385 and y < 415 and b = 1 then
col := 40
elsif x >= 8 and x <= 72 and y >= 415 and y < 445 and b = 1 then
col := 33
delay (10)
end if
if b = 1 then
drawfilloval (x, y, thickness, thickness, col)
end if
end loop
Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: Wed Jan 07, 2004 10:06 pm   Post subject: (No subject)

well i never liked the turing gui fuctions, so when i made a progame just like this i just usesd colsion dection to tell whenther the mouse was out side of a box i derw to represten the drawing area. when the mouse is out of the box make it so they can not draw anthing.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
chibitenshi_03




PostPosted: Thu Jan 08, 2004 6:39 am   Post subject: (No subject)

How did you do that? Can you show me an example of what you did?
AsianSensation




PostPosted: Thu Jan 08, 2004 10:31 am   Post subject: (No subject)

well, basicly, something like this:

code:
if mx < 350 and mx > 100 and my < 500 and my > 100 then

     blah blah blah

end if


this checks to see whether your x and y position of your mouse is inside the box bounded by (100, 100), (350, 100), (100, 500), (350, 500)
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  [ 4 Posts ]
Jump to:   


Style:  
Search: