Archive - Mar 2007

Date

March 30th

(Simple version)Matrix like animated dropping character effect in PHP

This code is only for monospaced typefaces, else it will look strange. This is a simplified version of the dropping down characters(or Matrix Digital Rain), I will create more complex ones later.
The end result is something like this
Matrix like animated dropping character effect
Like most animated effects I will ever make, it needs GIFEncoder class.

The basic idea:
On a screen, when one pixel is activated, it lights up. Here, instead of a pixel, it is a character, so I just have to construct a character grid and light them when it is activated.

Although I did not use any code from Nazmul Hassan's PHP Matrix, he is the one who inspired me to make a animated version, and he is especially kindly to give the source code to me.

include('GIFEncoder.class.php');
ob_start();
$msg = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~!@#$%^&*()-_=+`[]{};:?/.,<>\\|"';
$length = strlen($msg);
$max_x = 400; //image x size
$max_y = 400; //image y size
$font_file = 'cour.ttf';//font, best monospace
$font_size = 10;//font site
$grid = 10;//gridient of the fonts
$measuer = imagettfbbox(10,0,$font_file,'1');
$space = 5;//space between letters
$char_height = $measuer[1] - $measuer[7] + $space;
$char_width = $measuer[2] - $measuer[0] + $space;
$i = 1;
$colorimage = imagecreatetruecolor(1,1);
$color[1] = imagecolorallocate($colorimage, 255, 255, 255);
while($i<$grid){
 
	$color[] = imagecolorallocate($colorimage, 0, 255-20*$i, 0);
	++$i;
}
imagedestroy($colorimage);
//ENOUGH TEXT TO FILL THE PAGE.
$width = ceil($max_x/$char_width);
$height = ceil($max_y/$char_height);
 
 
$x = 0;
while($x < $width){
	$y = 0;
	while($y < $height){
		$text[$x][$y] = $msg[rand(0,$length)];
		++$y;
	}
	$drop[$x] = rand(0, $width);
	++$x;
}
$i = 0;
while($i<$height+$grid){
	$image = imagecreatetruecolor($max_x, $max_y);
	$x = 0;
	while($x < $width){
		$y = 0;
 
		while($y < $drop[$x]){
			if($drop[$x]-$y<=$grid){
				imagettftext($image, $font_size, 0, $x*$char_width, ($y+1)*$char_height-$space, $color[$drop[$x]-$y], $font_file, $text[$x][$y]);
			}
			++$y;
		}
		if($drop[$x]<$height+$grid){
			++$drop[$x];
		}else{
			$drop[$x] = 0;
		}
		++$x;
	}
	imagegif($image);
	$imagedata[$i] = ob_get_contents();
	imagedestroy($image);
	ob_clean();
	++$i;
}
 
$gif = new GIFEncoder(
                            $imagedata,
                            100,
                            0,
                            2,
                            0, 0, 0,
                            "bin"
        ); 
Header ( 'Content-type:image/gif' );
echo    $gif->GetAnimation ();

Please download your own true type fonts.

If you want to find a property through the banks, be ready for a detailed scrutiny of your insurance deals as well as credit report.

Bubble Guru

Beta version Bubble Guru is still free and converting more and more webcam videos to Bubble Gurus, small floating bubbles communicate with the site's user with a small video.
Good idea, but this could be just like the annoying microsoft Clippy if get abused. :monk:
Bubble Guru

March 29th

Matrix like effect in PHP(Animated)

This is an slow(give it a set_time_limit(10)) and dirty animated matrix ever changing data grid effect:
Matrix Data Grid Effect

You have to have the GIFEncoder class and GD library in order to use make this effect work

include('GIFEncoder.class.php');
$max_x = 468;
$max_y = 60;
$step = 10;
$font_file = 'cour.ttf';
$font_size = 10;
$color = pow(255,2);

March 28th

Performancing Metrics VS Google Analytics

I haven't check out Performancing Metrics for a long time, and when I check it out today I was shocked by the table, Google Analytics looks like crap.

Compare list from Performancing Metrics

The table is for purely marketing purpose, basically Metrics just find all of its unique features and stuff on that table.
So I have to make a comparison between the two myself. check my screencast or the pros and cons list below:

Metrics
Pros

  • Simple graphs
  • Live stat
  • User action in detail
  • Referrals in detail
  • Real time Spy View

Cons

  • No content analysis

Google Analytics
Pros

  • Set gals and observe goal conversion
  • Content analysis, adword analysis
  • Rich presentation
  • Export data into different format
  • Executive, Marketer and Webmaster Overview

Cons

  • Slow learning curve
  • Slow javascript loading speed

Conclusion:
Google Analytics are for serious websites that have a clear marketing goal with few good professionals(Executive, Marketer and Webmaster).But it is just too slow for most people(after using analytics for 6 months, I still need 10 second to find "Referring Source" link, and watch yesterday's stat slowly show up though the flash...you know I don't like flash)
Metrics is a fast and good choice for most websites that only requires to know the most important part of
visitor's info--who(IP), where(referral, Geo location), when(time), what(user actions) and sometimes why(user search in google)

I'm going to check Metrics more often because it have just become my primary analytic system
BTW:
Metrics is the rebranded version of Clicky
Google analytics is the renamed version of Urchin

March 27th

Links for March

simple logo
Click2Map: Ajax Google Map marker

CSSFLY logo
CSSFly: Edit site's CSS and see the result instantly

logotext
SNiPiTRON: Research Socially

POPURI
popuri.us: Check out how popular your site are

Final Render
Javascript raytracer: Raytracing(slow) in Javascript

yfile
yFiles Ajax: Draw diagrams Ajaxly

Font Detector: Javascript detect what font is installed

Screencast

Honey Pot that kill bots