Posted in November 2007

Leopard 10.5 supports 512 pixel icons

by

While playing around with Icon Composer in the newest version of XCode Tools for I noticed that Leopard now supports 512×512 pixel icons – much larger than the older 128×128 pixel icons. I assume this has to do with the Cover Flow view for the Finder which displays icons much larger than the other views. Sure enough, Apple have redesigned all their icons for the new format and they look gorgeous. I took some screen grabs of my favourites. Click the thumbnails to see the details. Notice the small text in the iTunes and Dictionary icons and the textures on the truck and the guitar. Hawt!

Click for full size

Dictionary icon

Dictionary



Garage band icon

Garage Band



iTunes icon

iTunes



TextEdit icon

TextEdit



Transmit icon

Transmit


Tagged

Discussion – Is OOP for OCD?

by

[Repost from Jan 31 2007]

Recently, I’ve been playing around with compiling ActionScript 3.0 with strict mode turned off. This makes everything much more loose. Type checking is thrown out, classes can be dynamically altered – essentially, you sacrifice speed and rigourousness for flexibility and forgiveness. In other words, it’s compiled more like AS1 was compiled.
I’ve also been spending some spare time looking at Objective-C (the language used for Mac programming). Obj-C adds functionality to C which makes it sort of object oriented but in reality, it’s very loose. The book I’m reading seems to glorify the dynamic nature pointing out how nice and flexible it is to try to access something that might not exist within an object. Obj-C programmers tend to break the “is a” rule using inheritance to gain functionality rather than identity. Even though it all curdles my blood, it’s hard to deny that this is a system which allows you to very quickly (and fairly elegantly) create working applications.

So my question to you is this.
Is all of the effort that we as developers put into creating object oriented, well defined, interface driven, decoupled code worth the effort?
Is there a value in keeping things loose and dynamic?
Should we shun languages that make this impossible or difficult?

Napkintop web design for maximum impact

by

This link is an oldie but a goodie. It has helped me remember to KISS countless times and to focus on the needs of users when designing sites. Check it out.

An Introduction to Using Patterns in Web Design [37 Signals]

Runtime Stack Information for Logging and Debugging

by

Or, “Hack Your Stack for Fun and Profit!” Yes, this is really and truly a hack, my friends, but, like many hacks, you might find it very useful. Using the Stack class I provide, you can get all sorts of information about the code being run right now: the package, class name, method, filename, and even the line number. You can also grab an Array version of a stack trace and follow it up. Sweet!

So check out this egregious hack. First, you grab the stack trace by throwing and catching a dummy Error and copping its stack trace as a string. Note, that this technique only works (and is only useful) in the Debug Player.

public static function getRawStackTrace():String
{
	var stackTrace:String;
	try
	{
		throw new Error();
	} catch (error:Error) {
		stackTrace = error.getStackTrace();
	}
	return stackTrace;
}

Then you slice it up into lines, and hack those lines into their constituent parts by some crazy regular expressions. That’s pretty much it.

public static function getPartsFromStackTraceEntry(stackEntry:String):Object
{
	return stackEntry.match(/(?P<package>[\w\d\.]+)::(?P<classname>[\w\d\.\:]*?)(?P<isStatic>\$?)\/((?P<scope>[\w\d\.\:]+)::)?(?P<method>[\w\d]+\(\))(\[(?P<filename>[\w\d\\\/\.]+):(?P<line>\d+)\])?/);
}

Fun, right? The properties in the returned Object are:

  • package
  • classname
  • isStatic
  • scope
  • method
  • filename
  • line

You can clean this up into package.classname::method with getSimplifiedStackTraceEntry().

So that’s it, it’s just some regular expressions, but with this hack you can pull out all kinds of juicy information about the context your code is running in. It can be useful for your own debugging, logging, and error reporting.

filecom.yourmajesty.debug.Stack View Source | Download (.as, 2k)

Cylinder Mapping

by

At Your Majesty, we worked on a site where some images appear on different products. I had my hands full with the image generation backend and the hosting issues to work too much on the Flash, but I was able to contribute one effect. I wrote a cylindrical mapping class which let us put any image on a mug as it rotated in three-space.

The process for building this was actually kind of interesting. I ended up actually using that graphing calculator that comes with OS X to preview different equations. I figured, if I could visualize the cross-section of the cylinder across the axis of distortion, then I would have an appropriate function to generate the distortion for each pixel, so I plotted a bunch of different equations interactively without coding them up. For the vertical displacement, the curve of the top lip (and the entire front) of a mug looks like a semicircle, perhaps squashed, so I quickly ended up the equation for a circle, y² + x² = r or y = ±√(r – x²). However, the sides are a bit more exaggerated.

Word to first-time displacement map users like myself, using the drawing API’s gradient tool as a source for displacement map data is not going to yield very good effects, since it seems that it only interpolates between colors linearly, which won’t do much more than shear your image.

So here’s the effect applied to my banner. Scrub the mouse left to right below to “rotate” the “cylinder.” You can see that while the speed of the effect of course scales with the size of the distortion map, it is very fast.

If you see this message, you need to install Flash Player 9.

The code isn’t all cleaned up but at least the interface is clean. We simply create a new distortion map with a size and a display object to attach, set some parameters, and attach its ‘wet’ output to our display list.

map = new CylinderMap(200, 200, new IMAGE());
map.sideCompression = 100;
map.arc = -0.3;
map.rotation = 100;
addChild(map.wet);

And here’s the code for the displacement map class.

filecom.yourmajesty.effects.distortion.CylinderMap View Source | Download (.as, 5k)
filecom.yourmajesty.effects.distortion.IDistortionMap View Source | Download (.as, 1k)