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
PaddyLong




PostPosted: Sun Oct 05, 2003 1:30 pm   Post subject: (No subject)

very cool Tony
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon Oct 27, 2003 11:04 pm   Post subject: (No subject)

yet again - another text effect from the creative mind of bored Tony Laughing

Falling Binary
code:

%Falling Binary
%Turns text string into Binary and makes bits falls,
%slowly rebuilding letters from them
%Created by: Tony Targonski on October 27, 2003
%for www.compsci.ca

procedure binaryFall (text : string, nRows : int)

    var list : array 1 .. length (text) of string %store binary
    var fontID : int := Font.New ("Arial:14")
    var number : int %here for calculations

    for i : 1 .. length (text)
        list (i) := intstr (ord (text (i)), 8, 2) %convert text to binary

        loop
            if list (i) (1) = " " then
                list (i) := list (i) (2 .. *) %remove any extra " "s
            else
                exit
            end if
        end loop

        list (i) := repeat ("0", 8 - length (list (i))) + list (i) + repeat (" ", nRows) %add any missing leading 0s and ending spaces
    end for


    for s : 1 .. nRows + 8 %for num of rows

        if s > nRows then %time to turn binary back into letters
            for i : 1 .. length (text)
                list (i) := list (i) (2 .. *) %cut leading bit off
            end for
        end if

        for i : 1 .. length (text) %for each column
            for l : 1 .. length (list (i)) %for each digit


                %this number thingy makes sure that letters dont fall below sertain level
                if s > nRows then
                    number := nRows
                else
                    number := s
                end if

                Font.Draw (list (i) (l), i * 20, maxy - number * 14 + l * 14, fontID, black)

            end for

        end for
   %     drawline (0, maxy - 10 * 14, maxx, maxy - 10 * 14, black)
       
        for i:1..length(text)
        Font.Draw(text(i),i*20,maxy-nRows*14,fontID,black)
        end for
        Draw.FillBox(0,maxy-nRows*14+14,length(text)*20+20,maxy-nRows*14+round((s-nRows)/8*13),white)
       
        View.Update
        delay (250)
        cls
    end for

    for i:1..length(text)
    Font.Draw(text(i),i*20,maxy-nRows*14,fontID,black)
    end for
    View.Update %show off text to last
   
end binaryFall


kind of documented... not really... should be straight-farward.

The binary that's falling are real binary values of text passed to the method. Reading from bottom to up.

to run the effect:
code:

View.Set("offscreenonly")
binaryFall ("tony is bored", 20)


where it's
binaryFall(text:string, number_of_rows_to_fall:int)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
thoughtful




PostPosted: Tue Oct 28, 2003 6:05 pm   Post subject: My lame effect

This is a lame strike out effect i made. Still has some length issues.
code:

var font : int

var strike : string
procedure strikeout (word : string, x : int, y : int, fontsize : int ,delaytime:int)

    font := Font.New ("Ariel:" + intstr (fontsize))
    Font.Draw (word, x, y, font, black)
    strike := repeat ("_", length (word)- length (word) div 10 )
    if length(strike)=1 then
    Font.Draw (strike, x, y + (fontsize div 2), font, black)
    else
    for i: 1..length(strike)
    Font.Draw (strike(1..i), x, y + (fontsize div 2), font, white)
    Font.Draw (strike(1..i-1), x, y + (fontsize div 2), font, black)
    delay(delaytime)
    end for
    Font.Draw (strike, x, y + (fontsize div 2), font, black)
    end if
end strikeout


At the end try this to call the procedure
code:

strikeout ("Thoughtful", 100, 100, 20,100)
Tony




PostPosted: Tue Oct 28, 2003 6:51 pm   Post subject: (No subject)

I'm not sure if this would help, but
code:

Font.Width(text:string, fontID:int)

might come in handy. It tells you the width of a textstring using sertain font in pixels.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
thoughtful




PostPosted: Tue Oct 28, 2003 7:53 pm   Post subject: Thnx

Hey thnx, now the length problem is fixed using the command u gave me.
I also added custom color. But still the effect is petty lame will do a better one if got more time. Embarassed

code:

var strike : string
procedure strikeout (word : string, x : int, y : int, fontsize : int ,delaytime:int,clr:int)

    var font := Font.New ("Ariel:" + intstr (fontsize))
    Font.Draw (word, x, y, font, clr)
    strike :="_"
    loop
    exit when Font.Width(word, font)<Font.Width(strike, font)
    strike := strike+"_"
    end loop
    if length(strike)=1 then
    Font.Draw (strike, x, y + (fontsize div 2), font, clr)
    else
    for i: 1..length(strike)
    Font.Draw (strike(1..i), x-3, y + (fontsize div 2), font, white)
    Font.Draw (strike(1..i-1), x-3, y + (fontsize div 2), font, clr)
    delay(delaytime)
    end for
    Font.Draw (strike, x-3, y + (fontsize div 2), font, clr)
    end if
end strikeout
strikeout ("Thoughtful", 100, 100, 20,100,7)
strikeout ("ROCKS", 300, 300, 40,150,blue)
thoughtful




PostPosted: Wed Oct 29, 2003 11:27 pm   Post subject: Some other lame effects

Well i made some other lame effects, please do not draw n e thing above 300 y pixels as i m using that area as the scratch pad.
PS:= Can n e one tell me how to use the whatdotcolor functions offscreen, as in how to draw something which has a position greater than maxx or maxy and use this function, because i first tried to use that but it didnt work.

Here are the 3 effects:
code:


procedure ThoughtEffect1 (word : string, x_pos : int, y_pos : int, fontsize : int, colur : int, delay_time : int)
    var font : int := Font.New ("Batang:" + intstr (fontsize))
    var xwidth : int := Font.Width (word, font)
    var height, ascent, descent, internalLeading : int
    Font.Sizes (font, height, ascent, descent, internalLeading)
    var yheight : int := height
    var clr : array 1 .. xwidth, 1 .. yheight of int
    Font.Draw (word, 10, 300, font, colur)
    for x : 1 .. xwidth
        for y : 1 .. yheight
            clr (x, y) := whatdotcolor (x + 10, 300 + y - descent)
        end for
    end for
    drawfillbox (10, 298, 10 + xwidth, 300 + yheight, white)
    for x : 1 .. xwidth
        for y : 1 .. yheight
            drawdot (x + x_pos, y + y_pos, clr (x, y))
        end for
        delay (20)
    end for
end ThoughtEffect1
procedure ThoughtEffect2 (word : string, x_pos : int, y_pos : int, fontsize : int, colur : int, delay_time : int)
    var font : int := Font.New ("Times New Roman:" + intstr (fontsize))
    var xwidth : int := Font.Width (word, font)
    var height, ascent, descent, internalLeading : int
    Font.Sizes (font, height, ascent, descent, internalLeading)
    var yheight : int := height
    var clr : array 1 .. xwidth, 1 .. yheight of int
    Font.Draw (word, 10, 300, font, colur)
    for x : 1 .. xwidth
        for y : 1 .. yheight
            clr (x, y) := whatdotcolor (x + 10, 300 + y - descent)
        end for
    end for
    drawfillbox (10, 298, 10 + xwidth, 300 + yheight, white)

    for y : 1 .. yheight
        for x : 1 .. xwidth
            drawdot (x + x_pos, y + y_pos, clr (x, y))
        end for
        delay (20)
    end for
end ThoughtEffect2
procedure ThoughtFadeIn (word : string, x_pos : int, y_pos : int, fontsize : int, colur : int, delay_time : int)
    var font : int := Font.New ("Comic Sans MS:" + intstr (fontsize))
    var xwidth : int := Font.Width (word, font)
    var height, ascent, descent, internalLeading : int
    var xrand, yrand : int
    Font.Sizes (font, height, ascent, descent, internalLeading)
    var yheight : int := height
    var clr : array 1 .. xwidth, 1 .. yheight of int
    Font.Draw (word, 10, 300, font, colur)
    for x : 1 .. xwidth
        for y : 1 .. yheight
            clr (x, y) := whatdotcolor (x + 10, 300 + y - descent)
        end for
    end for
    drawfillbox (10, 300 - descent, 10 + xwidth, 300 + yheight, white)
    for duration : 1 .. 2
        for l : 1 .. yheight
            for k : 1 .. xwidth
                randint (xrand, 1, xwidth)
                randint (yrand, 1, yheight)
                drawdot (xrand + x_pos, yrand + y_pos, clr (xrand, yrand))
            end for
            delay (delay_time)
        end for
    end for

    for y : 1 .. yheight div 2 + 1
        for x : 1 .. xwidth
            drawdot (x + x_pos, y + y_pos, clr (x, y))
            drawdot (x + x_pos, (yheight - y) + y_pos, clr (x, yheight - y))
        end for
        delay (20)
    end for
end ThoughtFadeIn
ThoughtEffect1 ("THOUGHTFUL's", 20, 30, 30, black, 10)
ThoughtEffect2 ("Effects", 400, 30, 40, blue, 10)
ThoughtFadeIn ("RULE!", maxx div 2 - 50, 100, 40, green, 20)
%effect(word : string, x_pos : int, y_pos : int, fontsize : int, colur : int, delay_time : int)
Tony




PostPosted: Thu Oct 30, 2003 5:35 pm   Post subject: (No subject)

well I'm sure that dodge can tell you all about whatdotcolor Laughing

though you shouldn't be using it really.Got to be better ways out there.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
thoughtful




PostPosted: Thu Oct 30, 2003 7:02 pm   Post subject: Rainbow Effect

Well, i made another effect using the same method , now i use window.open for the scratch pad. N E ways this actually look pretty okay.
PS:= Can any one tell me the command to get the RGB values of pixels.
code:

procedure ThoughtRainbow (word : string, x_pos : int, y_pos : int, fontsize : int, delay_time : int)
    var backgroundcolor : int := white
    var font : int := Font.New ("Ariel:" + intstr (fontsize))
    var xwidth : int := Font.Width (word, font)
    var height, ascent, descent, internalLeading : int
    Font.Sizes (font, height, ascent, descent, internalLeading)
    var yheight : int := height
    var clr : array 1 .. xwidth, 1 .. yheight of int
    var win : int := Window.Open ("graphics:" + intstr (xwidth) + ";" + intstr (yheight))
    Font.Draw (word, 0, -3 + descent, font, black)
    for x : 1 .. xwidth
        for y : 1 .. yheight
            clr (x, y) := whatdotcolor (x, y - descent)
        end for
    end for
    drawfillbox (10, 298, xwidth, yheight, backgroundcolor)
    Window.Close (win)
    for i : 1 .. 1
        for x : 1 .. (xwidth div 7) * i
            for y : 1 .. yheight
                if clr (x, y) not= backgroundcolor then
                    case i of
                        label 1 :
                            clr (x, y) := red
                        label 2 :
                            clr (x, y) := 42
                        label 3 :
                            clr (x, y) := yellow
                        label 4 :
                            clr (x, y) := green
                        label 5 :
                            clr (x, y) := 11
                        label 6 :
                            clr (x, y) := blue
                        label 7 :
                            clr (x, y) := 13
                    end case
                end if
            end for
        end for
    end for
    for i : 2 .. 7
        for x : round ((xwidth / 7) * (i - 1) - 1) .. round ((xwidth / 7) * i)
            for y : 1 .. yheight
                if clr (x, y) not= backgroundcolor then
                    case i of
                        label 1 :
                            clr (x, y) := red
                        label 2 :
                            clr (x, y) := 42
                        label 3 :
                            clr (x, y) := yellow
                        label 4 :
                            clr (x, y) := green
                        label 5 :
                            clr (x, y) := 11
                        label 6 :
                            clr (x, y) := blue
                        label 7 :
                            clr (x, y) := 13
                    end case
                end if
            end for
        end for
    end for

    for x : 1 .. xwidth
        for y : 1 .. yheight
            drawdot (x + x_pos, y + y_pos, clr (x, y))
        end for
        delay (20)
    end for
end ThoughtRainbow

ThoughtRainbow ("THOUGHTFUL", 50, 30, 40, 10)
ThoughtRainbow ("RockS!", 150, 200, 70, 10)

note:- If using a backround color other than white change the line
code:

var backgroundcolor : int := white
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Oct 30, 2003 7:54 pm   Post subject: (No subject)

I think the rainbow effect would look better it was vertical instead of horizontal Confused
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Catalyst




PostPosted: Fri Oct 31, 2003 8:09 am   Post subject: (No subject)

another effect...

code:
setscreen ("graphics:480;150,nobuttonbar,position:300;300,offscreenonly")
type Bin :
    record
        c : char
        v ,g: int
    end record
var pixels : array 0 .. maxx, 0 .. maxy of int

proc GetPixels
    for i : 0 .. maxx
        for k : 0 .. maxy
            pixels (i, k) := whatdotcolor (i, k)
        end for
    end for
end GetPixels

var font : int := Font.New ("verdana:48:bold")
var fontS : int := Font.New ("verdana:6:bold")
cls
Font.Draw ("Catalyst", 10, 40, font, 1)

GetPixels

var cols : array 1 .. (maxx div 4), 1 .. (maxy div 6) of Bin
var cols2 : array 1 .. (maxx div 4), 1 .. (maxy div 6) of char
var hold : int
for i : 1 .. (maxx div 4)
    hold := Rand.Int (-3, -1)
    for k : 1 .. (maxy div 6)
        cols (i, k).c := chr (Rand.Int (48, 49))
        cols (i, k).v := hold
        cols (i, k).g := Rand.Int (28,30)
    end for
end for
loop

    for i : 1 .. (maxx div 4)
        for k : 1 .. (maxy div 6) - 1
            if pixels (i * 4, k * 6) = 1 then
                Font.Draw (cols (i, k).c, i * 6, k * 8, fontS, 42)
            else
                Font.Draw (cols (i, k).c, i * 6, k * 8, fontS,cols(i,k).g)
            end if
        end for
    end for

    for i : 1 .. (maxx div 4)
        for k : 1 .. (maxy div 6) - 1
            cols2 (i, k) := cols (i, k + 1).c
        end for
    end for

    for i : 1 .. (maxx div 4)
        for decreasing k : (maxy div 6) - 1 .. 1
            cols2 (i, maxy div 6 - 1) := chr (Rand.Int (48, 49))
            cols (i, k).c := cols2 (i, k)
        end for
    end for
    delay(10)
    View.Update
    drawfillbox (0, 0, maxx, maxy, 7)
end loop
AsianSensation




PostPosted: Fri Oct 31, 2003 7:55 pm   Post subject: (No subject)

nice......

that is some cool stuff.....

Claping

though it looked cooler when you use 27 as the color to draw the word, then the word blends into the background, but you can still see it, because it's a bit darker than the background.

kudos
thoughtful




PostPosted: Sat Nov 01, 2003 11:28 am   Post subject: Another effect

Here is the vertical effect which infact does look better and another one i made.

PS:- Catalyst you are something man! ditch the school goto a uni!!! Razz
code:

procedure ThoughtRainbowVertical (word : string, x_pos : int, y_pos : int, fontsize : int, delay_time : int)
    var backgroundcolor : int := white
    var font : int := Font.New ("Ariel:" + intstr (fontsize))
    var xwidth : int := Font.Width (word, font)
    var height, ascent, descent, internalLeading : int
    Font.Sizes (font, height, ascent, descent, internalLeading)
    var yheight : int := height
    var clr : array 1 .. xwidth, 1 .. yheight of int
    var win : int := Window.Open ("graphics:" + intstr (xwidth) + ";" + intstr (yheight))
    Font.Draw (word, 0, -3 + descent, font, black)
    for x : 1 .. xwidth
        for y : 1 .. yheight
            clr (x, y) := whatdotcolor (x, y - descent)
        end for
    end for
    drawfillbox (10, 298, xwidth, yheight, backgroundcolor)
    Window.Close (win)
    for i : 1 .. 1

        for y : 1 .. (yheight div 7) * i
            for x : 1 .. xwidth
                if clr (x, y) not= backgroundcolor then
                    case i of
                        label 1 :
                            clr (x, y) := red
                        label 2 :
                            clr (x, y) := 42
                        label 3 :
                            clr (x, y) := yellow
                        label 4 :
                            clr (x, y) := green
                        label 5 :
                            clr (x, y) := 11
                        label 6 :
                            clr (x, y) := blue
                        label 7 :
                            clr (x, y) := 13
                    end case
                end if
            end for
        end for
    end for
    for i : 2 .. 7

        for y : round ((yheight / 7) * (i - 1) - 1) .. round ((yheight / 7) * i)
            for x : 1 .. xwidth
                if clr (x, y) not= backgroundcolor then
                    case i of
                        label 1 :
                            clr (x, y) := red
                        label 2 :
                            clr (x, y) := 42
                        label 3 :
                            clr (x, y) := yellow
                        label 4 :
                            clr (x, y) := green
                        label 5 :
                            clr (x, y) := 11
                        label 6 :
                            clr (x, y) := blue
                        label 7 :
                            clr (x, y) := 13
                    end case
                end if
            end for
        end for
    end for

    for x : 1 .. xwidth
        for y : 1 .. yheight
            drawdot (x + x_pos, y + y_pos, clr (x, y))
        end for
        delay (delay_time)
    end for
end ThoughtRainbowVertical
procedure ThoughtMosaic (word : string, x_pos : int, y_pos : int, fontsize : int, delay_time : int)
    var backgroundcolor : int := white
    var font : int := Font.New ("Ariel:" + intstr (fontsize))
    var xwidth : int := Font.Width (word, font)
    var height, ascent, descent, internalLeading : int
    Font.Sizes (font, height, ascent, descent, internalLeading)
    var yheight : int := height
    var clr : array 1 .. xwidth, 1 .. yheight of int
    var win : int := Window.Open ("graphics:" + intstr (xwidth) + ";" + intstr (yheight))
    Font.Draw (word, 0, -3 + descent, font, black)
    for x : 1 .. xwidth
        for y : 1 .. yheight
            clr (x, y) := whatdotcolor (x, y - descent)
        end for
    end for
    drawfillbox (10, 298, xwidth, yheight, backgroundcolor)
    Window.Close (win)
    for i : 1 .. 1
        for x : 1 .. (xwidth div 7) * i
            for y : 1 .. yheight
                if clr (x, y) not= backgroundcolor then
                    randint (clr (x, y), 32, 56)
                end if
            end for
        end for
    end for
    for i : 2 .. 7
        for x : round ((xwidth / 7) * (i - 1) - 1) .. round ((xwidth / 7) * i)
            for y : 1 .. yheight
                if clr (x, y) not= backgroundcolor then
                    randint (clr (x, y), 32, 56)
                end if
            end for
        end for
    end for

    for x : 1 .. xwidth
        for y : 1 .. yheight
            drawdot (x + x_pos, y + y_pos, clr (x, y))
        end for
        delay (delay_time)
    end for
end ThoughtMosaic


ThoughtMosaic ("THOUGHTFUL's", 50, 30, 40, 10)
ThoughtRainbowVertical("Effects",50,200,30,10)
Andy




PostPosted: Sun Nov 02, 2003 3:16 pm   Post subject: (No subject)

tony wrote:
well I'm sure that dodge can tell you all about whatdotcolor Laughing


damn straight.... use what dot color or be Shoting
thoughtful




PostPosted: Sun Nov 02, 2003 7:37 pm   Post subject: (No subject)

LOL, I think ill stick with what dot color Smile) Razz Razz Razz
By the way do you know a way to get RGB values of dots.
AsianSensation




PostPosted: Sun Nov 02, 2003 8:23 pm   Post subject: (No subject)

first, use whatdotcolor (I am being total serious here, you actually have to use whatdotcolor)

then use RGB.GetColor
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 4 of 5  [ 70 Posts ]
Goto page Previous  1, 2, 3, 4, 5  Next
Jump to:   


Style:  
Search: