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

Username:   Password: 
 RegisterRegister   
 Getting with Font
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Clayton




PostPosted: Thu Oct 19, 2006 11:32 am   Post subject: Getting with Font

Well, I've seen the question a couple times "Can you get, and have the text show in a specific font?". So I decided to create a function to show that it is possible. Here is the code:

Turing:

function gets (xpos, ypos, font, clr : int) : string
    var a : string (1)
    var word : string := ""
    loop
        getch (a)
        exit when a = '\n'
        if word ~= "" and ord (a) = 8 then
            word := word (1 .. * -1)
        else
            if a ~= "\b" then
                word += a
            end if
        end if
        cls
        Font.Draw (word, xpos, ypos, font, clr)
    end loop
    result word
end gets


an example of its use:

Turing:

var name : string := ""
put "Please enter your name"
name := gets (0,0, Font.New ("times new roman : 20"), red)


all you need for this function to function (no pun intended) properly is an ordered pair (x,y) coordinates, your font, and a color to display the font in. Have fun with it if you want to use it.
Sponsor
Sponsor
Sponsor
sponsor
Prince Pwn




PostPosted: Tue Jan 02, 2007 6:12 pm   Post subject: (No subject)

This is cool!
Clayton




PostPosted: Tue Jan 02, 2007 6:18 pm   Post subject: (No subject)

It's not perfect, for instance it clears the screen every iteration through a loop, so if you have anything on the screen, you will lose it. It's just a rough model to work with.
CodeMonkey2000




PostPosted: Tue Jan 02, 2007 7:44 pm   Post subject: (No subject)

well, once it's done this would be pretty useful
Clayton




PostPosted: Tue Jan 02, 2007 7:53 pm   Post subject: (No subject)

I don't plan on finishing it. The only reason I posted was because people kept asking if it could be done. So I posted a half done version to prove the point, and have them do the work instead of saying "This is Freakman of compsci.ca's 'gets' function, but I have no idea how it works".
lord




PostPosted: Mon Jan 15, 2007 9:23 pm   Post subject: Re: Getting with Font

to be to the point ....................................................................................................... Exclamation :!:LOL Exclamation Exclamation
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: