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

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




PostPosted: Sat Jan 03, 2004 12:20 am   Post subject: Fonts and music

Does anyone know how to change the style of font and its size in a prgram? If so, can you please show me a working example?

And music... how can I play an mp3 file? I tried using Music.PlayFile or whatever that command is, and all it says is that the program has been executed, but nothing actually happens. So if you have any advice on that, it would be greatly appreciated. Exclamation Thanks.
Sponsor
Sponsor
Sponsor
sponsor
Ashkan




PostPosted: Sat Jan 03, 2004 1:11 am   Post subject: Music and Text

font:
Play with this code:
code:

var font1 := Font.New ("arial:14")
Draw.Text ("Angel", maxx div 2, maxy div 2, font1, red)


MP3:
change the name music to what you have.

code:

process playmusic
    Music.PlayFile ("music.mp3")
end playmusic

fork playmusic


Good Luck! =)
Angel




PostPosted: Sat Jan 03, 2004 1:43 am   Post subject: Colourback and sliding effect

Oh my God!!! I love you! It worked! And I've been trying to get it to work for so long! The font and the music!!! Very Happy Thanks so much.

Just one quick question though. I have pictures up in the background behind my font. Now I want to add a colourback background behind the font and if possible, make it slide onto the screen. Is there any way to do that? Thanks.
Tony




PostPosted: Sat Jan 03, 2004 3:02 am   Post subject: (No subject)

you should check out text effects to see all the cool things you can do with Font.Draw 8)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Angel




PostPosted: Sat Jan 03, 2004 12:05 pm   Post subject: Colourback and Background colour

Hey thanks. I took a look at some of the text effects and they look pretty good, but the thing is, I tried doing colourback behind my text which appears on top of some pictures and I guess I can do the delay effect... I was thinking maybe a sliding effect but I'm guessing no one really knows how to do that. But thanks anyway.

If you have any suggestions on how I can fix the colourback on my text, and also put a colour background on the screen, then I would really like to hear them. Thanks. Smile
Tony




PostPosted: Sat Jan 03, 2004 4:01 pm   Post subject: (No subject)

well to have colorback with Font.Draw, you just draw a colored rectangle behind each letter. You can find out proper coordinates assuming that height of the font = it's size in pixels and use Font.Width() to find the length
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Angel




PostPosted: Sat Jan 03, 2004 4:12 pm   Post subject: (No subject)

Can you please give me an example of how to do that? I have my text showing up in the following code:

code:
var word := "W E L C O M E  T O  M O V I E  T R I V I A"
var font1 := Font.New ("ravie:18")
var x := (maxx - Font.Width (word, font1)) div 2
var y := (maxy - 36) div 2
for rep : 1 .. length (word)
    delay (100)
    Font.Draw (word (rep), x, y, font1, white)
    x += (Font.Width (word (rep), font1))
end for


So can you please give me a code that shows how I can draw the boxes behind each letter? (And I would preferably like to stick with that code up there). Thanks.
Ashkan




PostPosted: Sat Jan 03, 2004 7:37 pm   Post subject: Back color

No problem =)
this way you can basicly have a back color for your text =P

code:

var word := "W E L C O M E  T O  M O V I E  T R I V I A"
var font1 := Font.New ("ravie:18")
var x := (maxx - Font.Width (word, font1)) div 2
var y := (maxy - 36) div 2
for rep : 1 .. length (word)
    delay (100)
    Draw.FillBox (x, y, x+30, y+20, red)
    Font.Draw (word (rep), x, y, font1, white)
    x += (Font.Width (word (rep), font1))
end for
Sponsor
Sponsor
Sponsor
sponsor
AsianSensation




PostPosted: Sat Jan 03, 2004 11:08 pm   Post subject: (No subject)

just making it neater.....a bit more flexible

code:
var word := "W E L C O M E  T O  M O V I E  T R I V I A"
var height := 18
var font1 := Font.New ("ravie:" + intstr (height))
var x := (maxx - Font.Width (word, font1)) div 2
var y := (maxy - height) div 2
for rep : 1 .. length (word)
    delay (100)
    Draw.FillBox (x, y, x + Font.Width (word (rep), font1), y + height, red)
    Font.Draw (word (rep), x, y, font1, white)
    x += (Font.Width (word (rep), font1))
end for
Angel




PostPosted: Sat Jan 03, 2004 11:25 pm   Post subject: (No subject)

I like the code and all and that's pretty much what I was going for, except I was thinking that maybe each letter can have its own separate box instead of it all being together, but if that's not possible then it's alright.
Btw, I know I've asked a lot of question but this is a really important ISP so I hope you don't mind helping. Can you possibly explain each step in the code using % because not only do I have to make a program, I have to explain each step in the process and I don't really understand what's going on. And can I increase the size (in height) of the boxes? Thanks.
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  [ 10 Posts ]
Jump to:   


Style:  
Search: