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

Username:   Password: 
 RegisterRegister   
 Font.Draw Commands. Need Help ASAP!!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
KukuriChan




PostPosted: Tue Jan 13, 2004 7:20 pm   Post subject: Font.Draw Commands. Need Help ASAP!!

I have a question about the font.Draw command. Here's the basic code for my text procedure. It's suppose to get the font, what size they want, and the style of the font. After getting the information, it's suppose to use the same information to write text on the canvas. But everytime I run it, there's always an error. Somewhere around the fontID := Font.Draw line. ^^ If anybody can help me fix it or make my code grateful I'll be really happy. And just in case you're wondering, I'm still doing my paint program. It's due this Friday so the faster I get help the happier I'll be. ^^ Thanks.

import GUI
var x, y, butNum, butupdown, button, buttonnum, buttonupdown, col2 : int
var px, py, absX, absY : int
var words : string
var temppic : int
col2 := 0
var canvas : int := GUI.CreateCanvas (90, 85, 510, 245)
var fontID : int

proc myMouse (var x, y, b : int)
var absX, absY : int
Mouse.Where (absX, absY,
x := absX - 90
y := absY - 85
end myMouse


proc text
var fontName, font, size, style : string
var boxID : int := GUI.CreateTextBox (20, 390, 150, 65)
var winID, font11 : int
font11 := Font.New ("serif:12")
Font.Draw ("Font Names ", 20, 464, font11, 11)
Font.StartName
loop
fontName := Font.GetName
exit when fontName = ""
GUI.AddLine (boxID, fontName)
end loop
winID := Window.Open ("position:center;center,graphics:200;200")
put fontName
put "Type in name of font you wish to use: " ..
get font
put "Size:" ..
get size
put "Style (bold or italic) : " ..
get style
Window.Close (winID)

Mouse.ButtonWait ("down", x, y, butNum, butupdown)
temppic := Pic.New (90, 85, 600, 330)
myMouse (px, py, button)
loop
setscreen ("nocursor")
var ch : string (1)
if hasch then
getch (ch)
exit when ch = "q"
end if
var textbtn : int := GUI.CreateButtonFull (20, 130, 0, "Text", text, 0, '^T', true)
GUI.Disable (textbtn)
fontID := Font.New ("font : size")
GUI.PicDraw (canvas, temppic, 0, 0, picCopy)
loop
Mouse.Where (x, y, button)
setscreen ("cursor")
get words : *
GUI.FontDraw (canvas, words, x - 90, y - 85, fontID, 7)
end loop
end loop
end text

text
Sponsor
Sponsor
Sponsor
sponsor
DanShadow




PostPosted: Tue Jan 13, 2004 7:38 pm   Post subject: (No subject)

This should work, but Im not at my house or school, so I cant test it:
code:

var x,y,size,c:int:=0
var txt:string:=""
put "Enter the text you wish to display: "..
get txt:*
put "What size would you like it: "..
get size
put "Enter the 'x' value of the text: "..
get x
put "Enter the 'y' value of the text: "..
get y
put "[12=red,1=dark blue,2=dark green,54=light blue, 10=light green]"
put "Enter the color of the text: "..
get c
font := Font.New ("serif:size")
Font.Draw (txt,x, y, font, c)
KukuriChan




PostPosted: Tue Jan 13, 2004 8:11 pm   Post subject: (No subject)

it doesn't work.
Dan




PostPosted: Tue Jan 13, 2004 11:03 pm   Post subject: (No subject)

close just messed up that font.new line:

code:

var x,y,c:int:=0
var size:string
var txt:string:=""
put "Enter the text you wish to display: "..
get txt:*
put "What size would you like it: "..
get size
put "Enter the 'x' value of the text: "..
get x
put "Enter the 'y' value of the text: "..
get y
put "[12=red,1=dark blue,2=dark green,54=light blue, 10=light green]"
put "Enter the color of the text: "..
get c
var temp:string:= "serif:" + size;
var font := Font.New (temp)
Font.Draw (txt,x, y, font, c)
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
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: