Important alert: (current site time 7/15/2013 9:03:16 PM EDT)
 

VB icon

Thrown Text

Email
Submitted on: 9/16/2003 8:29:07 PM
By: IdoT 
Level: Beginner
User Rating: Unrated
Compatibility: 5.0 (all versions)
Views: 8588
(About the author)
 
     Can you tell what's written there? Try running the code.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
=**************************************
= Name: Thrown Text
= Description:Can you tell what's written there? Try running the code.
= By: IdoT
=
= Inputs:An argument would change the default thrown string...
=
= Assumes:Must have Tk installed.
=
= Side Effects:Time waste looking at it;)
=
=This code is copyrighted and has= limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=539&lngWId=6=for details.=**************************************

use Tk;
my $mw=new MainWindow;
my $canvas=$mw->Canvas(-width=>400,-height=>600,-bg=>'white')->pack;
$g=0.4;
sub create{
	my $self=shift;
	my $t=0;
	my $alpha=atan2($self->{m}-$self->{y0}-$g*$self->{t}**2/2,$self->{n}-$self->{x0});
	my $v0=($self->{n}-$self->{x0})/($self->{t}*cos($alpha));
	my $sub;
	my $i=$canvas->create('text',$self->{x0},$self->{y0},-text=>$self->{letter});
	$sub=sub{
		$canvas->coords($i,$self->{x0}+cos($alpha)*$v0*$t,$self->{y0}+sin($alpha)*$v0*$t+$g*$t**2/2);
		$t++;
		$mw->after(30,$sub) unless $t>$self->{t};
	};
	$mw->after(rand(2000),$sub);
}
$canvas->repeat(6000,my $subr=sub{$canvas->delete('all');
$x=100;
$n=50;
$string=$ARGV[0]||'www.planet-source-code.com';
my @pos;
for(split //,$string){
	create({letter=>$_,x0=>$n+do{my $a;do{$a=int rand(length $string)} while $pos[$a];$pos[$a]=1;$a*10},y0=>590,m=>300,n=>$x+($string=~s/\Q$_/^/,$-[0])[1]*8,t=>55+int rand(40)});
}});
$subr->();
MainLoop;


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

9/17/2003 12:57:02 AMFunnyPic Huh

This is cool
(If this comment was disrespectful, please report it.)

 
11/12/2003 1:23:55 PMICode

Man, perl is so hard to read... Thanks though, I'll figure it out one day.
(If this comment was disrespectful, please report it.)

 
11/12/2003 1:27:52 PMICode

One thing, every now and then one or more random letters disappear and may return on the next iteration. Wonder why that is?
(If this comment was disrespectful, please report it.)

 
9/15/2004 10:35:01 PM

kool code, however it skips or leaves out a letter every once and a while.
ex: i typed have a good night
it said have a good night, or have a goo night, or have a good nig t.
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.