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

Username:   Password: 
 RegisterRegister   
 [source code] Text Effects
Index -> Programming, Turing -> Turing Submissions
Goto page Previous  1, 2, 3, 4, 5  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Dan




PostPosted: Mon Apr 07, 2003 7:03 pm   Post subject: (No subject)

i do not bilve there is a pach for 3.1.1 to 4.X . Also the only site i know of that has pachs for turing is holths site.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Sponsor
Sponsor
Sponsor
sponsor
haujobb




PostPosted: Tue Apr 15, 2003 9:28 am   Post subject: (No subject)

Didn't see this anywhere else so...

code:

var intTextLength : int := 0
var realTextLength : int := 0
var where : int := 0
var text : string := " "

procedure textCenter (text : string, where : int)
    intTextLength := length (text)
    realTextLength := intTextLength / 2
    intTextLength := round (realTextLength)
    locate (where, 60 - intTextLength)
    put text
end textCenter

textCenter ("The text... is centered!", 1)


The first variable passed is the text that you want displayed and the second variable is which row you want it displayed on...

Also... the Y coordinate - in this case 60 - intTextlength - only works with the screen size I used to you might have to alter that value.
Tony




PostPosted: Tue Apr 15, 2003 10:09 am   Post subject: (No subject)

if you replace 60 with maxcol it would work for any window size Wink


Also, there is no patch from v3 to v4 since v4 was rewriten from scrach.

You can take out View.Update and View.Set("offscreenonly") as the rest of the code should be compatible with v3. The only downside is flashing.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
haujobb




PostPosted: Tue Apr 15, 2003 10:16 am   Post subject: (No subject)

60 is the center of the screen, so it would be maxcol \ 2.

Good idea tho, I'm gonna use that now...
Blade




PostPosted: Sat Apr 19, 2003 3:01 pm   Post subject: (No subject)

tony wrote:
if you replace 60 with maxcol it would work for any window size Wink


Also, there is no patch from v3 to v4 since v4 was rewriten from scrach.

You can take out View.Update and View.Set("offscreenonly") as the rest of the code should be compatible with v3. The only downside is flashing.


so thats why sprites dont work in 4.... wierd stuffs..
Blade




PostPosted: Thu May 22, 2003 11:22 am   Post subject: (No subject)

here's my 2 cents worth of text effect Smile it might help some though because there was a question in turing help forum

code:
var x : int := 100
const y := 100
var font : int := Font.New ("Arial:30")
procedure drawword (word : string (30), del : int)
    for i : 1 .. length (word)
        Font.Draw (word (i), x, y, font, black)
        delay (del)
        x += Font.Width (word (i), font)
    end for
    x := 100
    for i : 1 .. length (word)
        Font.Draw (word (i .. *), x, y, font, black)
        delay (del)
        x += Font.Width (word (i), font)
        cls
    end for
    cls
end drawword

drawword ("WAAAZZZAAAP???", 100)
- hope it helps someone

MOD EDIT: Fixed some typos so it actually works. -Asok
AsianSensation




PostPosted: Sun Jul 20, 2003 12:28 pm   Post subject: (No subject)

One more text effect....

3D(sort of) text rising


code:
View.Set ("offscreenonly")
var fontID := Font.New ("Ariel:50:Bold")
var x, y := 50
for rep : 1 .. 15
    Font.Draw ("Hello", x, y + rep, fontID, 16)
    delay (50)
    View.Update
    if rep not= 15 then
        Font.Draw ("Hello", x, y + rep, fontID, 20)
    end if
end for


I got this idea when I was looking back at my midterm mario rpg game. It works the same way with a picture.

readjust the delays for different computer.
AsianSensation




PostPosted: Sun Jul 20, 2003 4:59 pm   Post subject: (No subject)

here is a better version of the above one, more 3D-ish...

code:
View.Set ("offscreenonly")
var clr : int
const depth : int := 15
var counter := 256 + depth
var fontID := Font.New ("Ariel:50:Bold")
var x := (maxx - Font.Width ("AsianSensation", fontID)) div 2 + depth
var y := 200

for rep : 1 .. depth + 1
    clr := RGB.AddColor (1, rep / (depth + 1), 1)
end for

for rep : 1 .. depth
    Font.Draw ("AsianSensation", x - rep, y + rep, fontID, purple)
    delay (50)
    View.Update
    if rep not= depth then
        Font.Draw ("AsianSensation", x - rep, y + rep, fontID, counter)
    end if
    counter -= 1
end for


Tweaking with the RGB value will give you different color displays.

Also, tweak depth for how much it rises.

Edit: Well, fixed some error, and made it look better, especially with the purple color Razz
Sponsor
Sponsor
Sponsor
sponsor
SilverSprite




PostPosted: Tue Jul 22, 2003 2:34 pm   Post subject: (No subject)

Sucky..
AsianSensation




PostPosted: Sun Aug 10, 2003 11:51 am   Post subject: (No subject)

Well, time again for the AsianSensation text effect of the.....um.....month, yeah! 8)

code:
View.Set ("offscreenonly")
colorback (7)
cls

var word := "AsianSensation"
var font := Font.New ("Arial:30:Bold")
const xpos := 200
const ypos := 100

var dot : array xpos .. xpos + Font.Width (word, font), ypos .. ypos + 30 of int

var clr : int
const width := Font.Width (word, font)

for decreasing rep : width .. 0
    clr := RGB.AddColor (rep / (width), rep / (width), rep / (width))
end for
clr := RGB.AddColor (0, 0, 0)
var clrc := maxcolor

Font.Draw (word, xpos, ypos, font, white)

for x : xpos .. xpos + Font.Width (word, font)
    for y : ypos .. ypos + 30
        if whatdotcolor (x, y) = white then
            dot (x, y) := 1
        else
            dot (x, y) := 0
        end if
    end for
end for

for x : xpos .. xpos + Font.Width (word, font)
    for y : ypos .. ypos + 30
        if dot (x, y) = 1 then
            drawdot (x, y, clrc)
            %View.Update
        end if
    end for
    clrc -= 1
end for


Text shading, I haven't seen this up here, just thought it was useful...

now all I need is a sliding shade fade for text...

maybe I'll work it out for next month 8)

Edit: lol, I realized that I spelt AsianSensation wrong, lol. I also "fixed" that outline thing, and spelt Arial correctly, lol
SilverSprite




PostPosted: Sun Aug 10, 2003 12:41 pm   Post subject: (No subject)

this is even crappier lol
PaddyLong




PostPosted: Sun Aug 10, 2003 2:22 pm   Post subject: (No subject)

a good idea ... unfortunately it looks kind of grubby because of that outline or something lol

btw you spelt arial wrong
AsianSensation




PostPosted: Mon Aug 11, 2003 9:47 am   Post subject: (No subject)

lol, I spelt Arial wrong, guess you found another error in the Turing help document, lol. I only copy and pasted what's on the help file.

btw, what outline are you talking about? If you mean that line that goes from left to right while shading, just comment off View.Update, and it shouldn't appear anymore.
PaddyLong




PostPosted: Mon Aug 11, 2003 11:28 am   Post subject: (No subject)

no I mean around some of the first letters you can see a few miscoloured pixels...
Tony




PostPosted: Sat Oct 04, 2003 11:05 pm   Post subject: (No subject)

This weekend I saw foolproof and desided to try and reprocude the text effect they have in the opening. Its basically a random line of hex numbers (well not really hex, but of 2 digit sets) that randomly rotate into the text wanted. This is what I came up with

code:

%text effect from movie "foolproof"
%programmed by Tony Targonski
%Started October 03.2003
%Finished October 04.2003

%draw procedure
procedure draw(picL1:int, picN1:int ,x:int, y:int, step:int)

var picL:int := picL1
var picLtemp:int
var picN:int := picN1
var picNtemp:int


var i:int := step

if step<=20 and step>0 then

picNtemp:=Pic.Scale(picN,21-i,20)
Pic.Draw(picNtemp,x+round(i/2),y,picMerge)
Pic.Free(picNtemp)

elsif step>20 and step<=40 then

picLtemp:=Pic.Scale(picL,i-20,20)
Pic.Draw(picLtemp,x+round((40-i)/2),y,picMerge)
Pic.Free(picLtemp)

end if

if step>40 then
Pic.Draw(picL,x,y,picMerge)
elsif step<0 then
Pic.Draw(picN,x,y,picMerge)
end if

end draw



procedure foolproof(text:string,x:int,y:int, delaytime:int)

var fontID:int := Font.New("Arial:16")

var imageN:array 1..length(text) of int %array for number images
var imageL:array 1..length(text) of int %array for letter images

var imageX:array 1..length(text) of real %array for image's X value

imageX(1):=x
%set X values
for i:2..length(text)
imageX(i):=imageX(i-1) + 15 + i mod 2 * 20
end for

for i:1..length(text)
Font.Draw(text(i),100,100,fontID,black)
imageL(i):= Pic.New(95,95,115,115) %stores each letter
cls
Font.Draw(intstr(Rand.Int(0,9)),100,100,fontID,black)
imageN(i):= Pic.New(95,95,115,115) %stores each number
cls

end for


var lstep:array 1..length(text) of int
var longest:int:=999

for i:1..length(text)
lstep(i):=Rand.Int(-100,0)
if lstep(i)<longest then
longest := lstep(i)
end if
end for


View.Set("offscreenonly")

loop

for i:1..length(text)

draw(imageL(i),imageN(i),round(imageX(i)),y,lstep(i))
lstep(i)+=1


%spreads numbers out
if i mod 2 = 0 and lstep(i) >0 and lstep(i)<40 then %even number
imageX(i) += 1/8
else %odd number
imageX(i) -= 1/8
end if

end for

View.Update
delay(delaytime)
longest+=1
exit when longest>41
cls
end loop


end foolproof


Sorry that it's not commented much. I added some key info, but I donno... if you have questions about how it works, ask. Although you dont really need to know how it works. Not unless you would want to modify hardcoded font (btw, if you're to modify font's size, you'd have to reprogram spacing as well).

Quote:

Effect's method has following format:

foolproof(text:string, x:int, y:int, delay:int

text - a string to be displayed

x/y - location of the left most letter (note, the letter will end up moving a bit to the left during spread out

delay - delay between each step during animation. The amount of calculations required makes it run normaly on my computer with 0 delay


An example of call is
code:

foolproof("foolproof",100,100,0)


Notes
- some flashing numbers before animation are to load up images of letters and numbers.

- View mod is set to "offscreenonly" during animation.

- effect uses cls. If you want to use it with background, you would need to modify that line

- two procedures are involved. draw is for drawing each letter at spesific step. foolproof is the driver that loads values and calls draw
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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 3 of 5  [ 70 Posts ]
Goto page Previous  1, 2, 3, 4, 5  Next
Jump to:   


Style:  
Search: