3D in Flash (Plus source code)

Friday, May 02, 2008   —   Vienna 0 Comments

I came across an old peice of Flash work I did about 2 years ago amongst some of my old files on the computer. I did this when I was developing a Flash website as part of the Dark Gloriole video game project. I eventually abandoned the website idea this because building the game demanded too much time.

But what I have left is a neat little peice of a 3D engine implemented in Flash — complete with backface-culling an all! Some time in the future, when I have time I'll revisit this whole 3D thing, it was a lot of nerdy fun.

Loading...

  more »

Function to list directories

Friday, February 08, 2008   —   Vienna 0 Comments

I've seen lots of people asking for this, so I'm posting a recursive function that iterates through a directory and subdirectories, and lists all the files contained within.

This function takes one parameter, the directory you want to list. The function then continues looping through itself until it runs out of subdirectories and files within this directory. The function returns a string containing the files and folders contained in the directory displayed in a tree.   more »

Generate title and caption images on the fly

Monday, January 14, 2008   —   Vienna 0 Comments

This article demonstrates how to use PHP to generated title and caption images on the fly...

When a web designer wanted to display text as an image, the procedure would commonly begin with something in the vain of "open Photoshop..." But in the new web of dynamic content and massive scale, this approach won't work.

In most cases, an image text is used to display titles and headings. The example below is of the Apple's iPhone Developer Center.

Screenshot of iPhone Dev Center

  more »

Thumbnails on the fly

Thursday, January 03, 2008   —   Vienna 0 Comments

This article will show you how to create thumbnails dynamically. For example, these three images have been dynamically generated from the same source.

The above images are generated with a URL like this one: www.petrosalema.com/blog/articles/burger_thumb_100.jpg; where 100 is changeable.

The benefits of being able to dynamically generate images of varying size from a single source file are too obvious to get into. But I will mention that I'v done some research and websites like Amazon, Wikipedia, IMDb, iStockPhoto, and Flickr, where there are large numbers of images to manage, all use this approach.

Below are images of varying size dynamically generated image from Wikipedia using this URL pattern: upload.wikimedia.org/wikipedia/commons/thumb/e/e8/Hamburger_sandwich.jpg/100px- Again, to generate each image 100 is simply changes to the desired width which in this case was 200 and 300.

  more »

Converting hexadecimal color values to RGB

Sunday, October 07, 2007   —   Vienna 0 Comments

A useful function to convert a hexadecimal color value to an array of RGB values.

function Hex2RGB($c)
{
	if(!$c) { return false; }

	$c = trim($c);
	$rgb = false;

	if(eregi("^[0-9ABCDEFabcdef\#]+$", $c))
	{
		$c = str_replace('#','', $c);
		$l = strlen($c);
		if($l == 3)
		{
			for($i=0; $i<3; $i++) { $c6 .= substr($c, $i,1) . substr($c, $i,1); }
			$c = $c6;
		}
		unset($rgb);
		$rgb[0] = $rgb['r'] = $rgb['red']   = hexdec(substr($c, 0,2));
		$rgb[1] = $rgb['g'] = $rgb['green'] = hexdec(substr($c, 2,2));
		$rgb[2] = $rgb['b'] = $rgb['blue']  = hexdec(substr($c, 4,2));
	}
	else { $rgb = false; }
 
	return $rgb;
}
  more »

Overlay text on an image

Friday, July 20, 2007   —   Vienna 0 Comments

This tutorial is going to show you how to overlay a textbox on an image, like this. It's pretty straight forward, so I'm simply going to post the CSS and some exmaple HTML to give you an idea.
  more »

Ajax message queuing

Tuesday, June 05, 2007   —   Vienna 1 Comments

When building Wimbomedia, I encountered the problem of managing multiple HTTPRequests. In order that a new HTTPRequest does not interrupt or kill the previous one, I needed some sort of queuing abstraction that will wait until the previous request was completed (or aborted) before moving on to the next one. FIFO is a computer acronym for a concept called "First In First Out". It is a common principle in managing messages on operating systems because, lest we forget, even offline platforms have to deal with lag!


Imagine a hungry customer arrives at a counter in McDonalds to find a family of five in the throes of indecision. The person serving at the counter would wait until the family has received their order or decided they fancy Berger King instead, before asking the hungery guy to place his order. Well that's FIFO right ther — "First come, first served"! And that's how I'll propose to solve the multiple Ajax request problem.   more »

Human-readable file size

Tuesday, May 01, 2007   —   Vienna 0 Comments

Logarithm to change file size string like this 1234567 one to human-readable format like 123 MB.

function formatSize($s)
{
	$units = array("Bytes", "KB", "MB", "GB", "TB");

	$count = count($units);
	for($i = 0; $i < $count && $s >= 1024; $i++) { $s /= 1024; }

	return (round($s, 2) . " " . $units[$i]);
}
  more »