Wednesday, May 14, 2008

ufws canvas transition

My last flash version of UFWS (Episode #12) went up on Monday morning. The rest of Monday was spent transitioning all the actionscript code to javascript (and writing some notes down). Tuesday was spent finishing up and recoding some parts which basically meant cleaning up the original code a bit. The rest of the day was spent making the background and updating the three widget graphics used. I was a bit crunched for time to get some decent gameplay in unfortunately. Overall, though the transition was much smoother than I imagined; there are some things I still don't have figured out. Today Episode #13 is released and is now using the Canvas tag.

The rest of my notes:

  • There are some anti-aliasing differences between the Safari on OS X and Firefox on windows - The "game-over Congrats!" image has rendered text in a PNG displays on major blurrage in firefox for some reason, on OS X this text is crisp

  • no text rendering is a problem, will need to get creative when I want to display any signage (like popup menus I had in the previous flash episodes)

  • No native IE 7 canvas (or SVG) support continues to sadden me.

Monday, May 12, 2008

Canvas tag a Flash killer?

I'm mid-port of my Untitled FWS project to make use of the canvas tag. Here are some notes:

  • Since I'm cheap and haven't pirated Flash I use MTASC + swfmill to create my flash stuff which means my source is written in ActionScript version 2. Porting this code to javascript doesn't require a whole lot of changes.

  • Performance of the canvas tag isn't bad, considering the rendering loop is coded in an interpreted language. In my case I am creating an animated scene and the canvas tag is probably (don't know for sure) redrawing the whole thing every frame; Flash would limit redraws automagically based on what parts actually changed.

  • Firefox version 2.0.0.14 on OS X clearly has a very large memory leak dealing with the canvas' drawImage function that causes it to eventually crash after eating all available memory up. (This can be seen by simply setting an interval and continually drawing an image into a canvas element)Update:This appears to be just for OS X, the Windows version of Firefox 2.0.0.14 doesn't explode.

  • Firefox version 3 Beta 5 has plugged the leak and decreased CPU usage overall

  • Limited No text support in canvas elements in common browsers. however the HTML5 draft teases us with talk of rendering HTML and CSS into a canvas... THAT would be nice

  • No real IE support means this is basically not an option -- yes, there is an emulated canvas library from google but from the CAKE demo page it sounds like it doesn't work very well.

  • javascript intervals get called more regularly by Safari than their actionscript interval equivalents in my experience -- I think this is caused by some weird interaction between the flash plug-in and the safari browser

  • Blend modes are available and actually work without a huge performance penalty. this is better than current SVG blend mode support which relies on filters which aren't implemented (meaning there is only source-over fallback)

Saturday, April 19, 2008

visualizing edb's tag structure

This post deals with visualizing the internal storage format used by the elementaldb project.
I'm in the middle of rewriting the radix-tree storage engine in the elementaldb - while speed isn't a huge goal for the project, the newly rewritten proper crit-bit tree is performing inserts slower than the old version. So I thought it'd be interesting to use Graphviz to visualize the tag structure (and also the current radix tree) implementation. The tagm module was originally written for a mail client where messages could be tagged with a specific value. The generic requirements of the tag module were: it had to perform quick appends and it had to support a sort of hierarchical structure. The result is a linked-list implementation with nodes that can have an unlimited number of children. It's nothing really fancy but provides a convenient layer on which to write other data structures (b+tree, radix or anything else really).


This image shows the result of doing ten inserts of x = [0..9]. Each node is a tag value, in the current rtree implementation a tag node can potentially have a maximum of 256 children. These are sequentially searched (I know, I know) during a rtree put operation when a split branch point is reached. This means that storing binary data is very inefficient, hence the need to write a proper crit-bit implementation.


The image above shows the resulting structure when storing in a crit-bit structure. In this case a tag can have a maximum of 3 children: 0, 1, and data.

Wednesday, April 16, 2008

Untitled FWS


Untitled FWS is an episodic flash web strip that will be published every week on Monday, Wednesday and Friday.
My eventual idea is to actually have an entertaining story and goals to accomplish for each episode. So far the first published one on Monday contained only the very basic mechanics. The episode published today contains an actual goal and some objectives. For the next episodes I hope to continue this development trend.
The publishing schedule is very aggressive but it should force me to streamline the whole development process or fail miserably.

Maybe I'll give it a name soon too!

Saturday, April 12, 2008

Loveless


It's not very hard to see that Apple is the best at creating user interfaces. I've started using Amazon's MP3 Store and if you're a fan of DRM free music (and who isn't?) you should start using it too. The only problem is the interface to the store is simply awful. I've gotten so familiar with Apple's iTunes interface it's difficult to swallow a system where I can't see the most popular songs from an album or sort by most downloads or have any sort of interactive auto-complete search feature. When you go to check out for some reason Amazon's "One-Click" (tm) actually takes four clicks from the time I decide I want a song. After clicking four times for "one-click" the downloader pops-up to actually start the download process. The whole system needs to be put in the trash and Amazon's developer's should start over. The whole system feels very hackish and leaves a lot to be desired.
What can Amazon do? First, look at what Apple's done then try to achieve something similar but as a web solution. Retool the "MP3 Downloader" application to be a hidden plugin (similar to the Google gear's interface) where the web app. would communicate with the downloader portion via a javascript interface. This would make the whole interface seem more consistent (even though the plugin would still be required).
Apply lots of ajax magic to the page so that when I start typing "radi" I get "Radiohead" and a list of 5 other similar band and song names. Lists of songs should also be fast to load and NOT require the whole page to be (re)loaded. Make the song pagination system snappier so that browsing through songs feels snappier.
DRM-free music is worth the extra effort to go through the amazon system and as a new system goes it's not too bad but there is definitely quite a bit of room for improvement.

Thursday, April 3, 2008

php is teh funnays

So I'm squashing compiler warnings in my little project when I come across a warning when building in linux. It deals with pread/pwrite being implicitly defined. I check the man page, yes unistd is included but still the warning. So I google and find some PHP silliness:
Bug #32049 Implicit declaration of function pread - It's just a warning (ha!), note the date and files...
php4: files session handler broken on sparc - deals with the same files and almost 1 year earlier.

Warnings actually really do matter and they are normally pretty easy to fix. I know these were from a few years ago but the complete dismissive attitude of the bug response prompted me to post this.

Tuesday, April 1, 2008

2d line intersection

Playing around with line intersections again. There are two sites I found useful:
Intersection Point Of Two Lines
and N Tutorial's great site (I wish they had done more tutorials but they were probably busy doing N+).

To visualize it all I created a little cocoa app which displays two lines, the intersection point, a normal and a reflected ray from the intersection point:




Download Cocoa Project Source (requires Xcode dev tools): 2d_intersect.zip