Tag Archive for 'avatar'

Some Assembly Required

So, I’ve decided to learn assembly. Why? Well, nerdiness for one thing. But more importantly, I’m interested in learning it because I’d like to examine the importance of efficiency. Obviously, in modern computers, the need for efficient code is beginning to disappear. But, there are still plenty of small, embedded devices that are limited by the efficiency of the code. Take calculators, for example. A while ago, one of my friends mused that on a programmable calculator, loops actually need to be optimized. But TI-Basic (which he was referring to) can only be optimized so far. Z80 assembly is used for the most efficiency simply because assembly code has no overhead. It allows the developer to play with all aspects of the system. I’m interested in learning assembly because I’d like to start developing advanced applications in Z80 assembly and in HP’s ARM assembly for their calculators (they also have an emulation layer which runs old Saturn assembly programs, too).

One of my little side projects is to understand how I’m learning the language. I learned Python by reading a few manuals and experimenting with the interpreter. I learned PHP by applying my knowledge of Python, with a new syntax. But learning assembly will be a very different process, since it is so foreign to me. I intend to place emphasis more on the actual learning of the language rather than experimentation (until I know what I’m doing).

I am still looking for good guides to follow. I have already found quite a few (I’ll post them later) that have been helpful.

In other news, I’ve been playing around with transparency in GD/PHP (more avatar rotating scripts coming). That has not been fun. I’m just about to give up on it. Usually when I’m at that point, though, it probably means that something is wrong with the server configuration or something. I’ll have to install PHP to a test box to see if that could be the problem.

By the way:
http://xkcd.com/353/
That pretty much sums up my feelings, too.

Random Avatar (Take 2)

Rotating avatars are kind of fun to have.  I find that they are especially nice when they change in some subtle way (such as a background or foreground change) because forum members sometimes express surprise.  The script for a random avatar is fairly simple: it should read in a list of files, choose one at random, and then redirect the output.  This last step can be accomplished in two ways: with the header(“Location: image.png“) function in PHP, or by using GD to read the image in and then output it.  Then, there is the subject of masking.  By using a custom .htaccess file and Apache’s RewriteEngine, you can circumvent the prevention of dynamic PHP scripts as images.  The .htaccess file consists of two lines:

RewriteEngine On
RewriteRule image.png image.php

Most forums don’t want users using dynamic PHP scripts because it is possible to be malicious with them (one of the more harmless things I can think of is getting the viewer’s IP address).  So, use this trick with caution.  I only post it here because it is fairly easy to learn about anyways.

Instead of using the traditional “image rotator”, I decided to get a bit fancier.  I created a couple of foreground images and a couple of background images.  I wrote a quick PHP script to merge the two.  The result is this:

http://jwcxz.com/pic/avatar/square/index.png

The sourcecode is available here.  Fundamentally, the design is extremely simple.  Foreground images are named fgX.png, where X is an increasing integer, starting at 0 and background images are named bgX.png in a similar fashion.  The variables $fmax and $bmax must be modified each time a new image is uploaded.  This is a minor inefficiency, but I didn’t want to have the script use scandir() every time someone looks at an image.  The system then just overlays the foreground image over the background image and prints out the input.

Anyways, my goal is to actually put some decent background and foreground images in there now.