Thursday, December 25, 2008

question: is svg path data definition retarded?

Imagine you were going to write an XML description of a polygon type structure... Wouldn't you do something like:

<pt x="100" y="100"/>
<pt x="300" y="100"/>
<pt x="200" y="300"/>

There are probably a lot of variations, but wouldn't it look something like that?

I mean... it's kinda a no brainer, right? Sort of hard to screw up, though there are probably a lot of ways to get it right.

If you were handing this out as a homework assignment in an XML 101 class, what grade you would give someone who came up with something like this:

<path d="M 100 100 L 300 100 L 200 300 z"/>

What if they went on to tell you, you could also write it in any of the following acceptable forms:

<path d="M 100 100 L 300 100 L 200 300 z"/>
<path d="M 100,100 L 300,100 L 200,300 z"/>
<path d="M 100 100L300 100L200 300 z"/>

Would you think they were being smart by saving space?

What if they told you:

  • the "M" meant "move to the absolute position"

  • the "m" meant "the point which relative to the last point"

  • the "L" meant "draw a line to the absolute position"

  • the "l" meant "draw a line the point which relative to the last point"

Would you think they were really smart? Or would you think they were pretty dumb?

Would you recommend it for inclusion in the W3 SVG standard?

I'm just wondering... cuz to me... it seems pretty stupid.

Way to drop the ball... I really would not have thought someone could screw that up so badly.

Monday, December 15, 2008

a point in haxe: inline ftw!

A while back, I talked about how delineating between structures and objects could have some performance implications.

Since then I have periodically doubted the conclusions I drew from my observations. My results still indicate that for Java with the JVM I used, structuring the code into a point structure and implementing the operations as a collection of static operators does make for a significant performance increase.

What I came to doubt was the universality of this observation.

Specifically, I wanted to see if this design methodology also payed off with haxe or if it was more of a JVM implementation artifact.

To test it, I wrote 3 different implementation of a "point" class:

typedef TypedPoint = {
public var x : Float;
public var y : Float;
public var z : Float;
class TypedPointOps {
public inline static function add( dest:TypedPoint, a:TypedPoint, b:TypedPoint ) : TypedPoint {
dest.x = a.x + b.x;
dest.y = a.y + b.y;
dest.z = a.z + b.z;
return dest;

class Point {
public var x : Float;
public var y : Float;
public var z : Float;

public function new( ?x:Float, ?y:Float, ?z:Float ) {
this.assign( x, y, z );

public function assign( ?x:Float, ?y:Float, ?z:Float ) : Point {
this.x = x;
this.y = y;
this.z = z;
return this;

public function add( a:Point, b:Point ) : Point {
this.x = a.x + b.x;
this.y = a.y + b.y;
this.z = a.z + b.z;
return this;

I wrote another version called "InlinePoint" which is just like "Point", but used the "inline" keyword.

Here is the result:

It basicly "adds" two points together 1 million times.

Here is the breakdown:

point : 0.019s
inline : 0.010s
typed : 1.355s

As you can see, the object version using the "inline" keyword is extremely fast compared to the alternatives.

In testing, I used the neato flashplayer command line tool that came as part of the Adobe Flex Builder Linux Public Alpha

% flashplayer pointsDemo.swf

For some reason it shows the "point" time as "0.149s"... weird... The "typed" time was also pretty different... eh...

So... why did I bother? Now I know I can port my JS 3D library straight to haxe without any major refactoring! :-D

Monday, December 8, 2008

Fallout 3 S.P.E.C.I.A.L Calculator

Fallout 3 is super-hoopy! And you are nuts not to devote tons of free time to it!

Here is some stuff on character creation gathered up with a lame calculator... No warrantees... don't sue me!

SPECIAL is 7 attributes starting with 5 points, with an extra 5 to spread around.. So... 40 points in all:

If that doesn't work, try hitting it directly

Even works under in (lame olde) IE... Use FF.

Here is some random advice I culled from some guys who actually put in the time to really document this stuff.

Since it's a mashup and different builds are different (ya reckon?), a lot of this is contradictory...

The following notes are culled from those links and are pretty much the words of the original authors.


I would suggest never going lower than three, and never going higher than five.

every type of character needs [..] inventory, [..] recommended that Strength be at least a 5


I wouldn't say a high level of Perception is desperately needed, but it will make your life easier. Put at least one point in there, if not two or three.

Perception needs to be brought to 6 eventually as a Perk prerequisite


If you want to use [big guns or unarmed ...] up to seven or eight. Otherwise, [...] drop it down to four or so


it's actually quite important if you want to be able to talk your way out of situations, and definitely worth putting two or three points in.

you can take Charisma down to 1 if you don't mind getting slightly worse prices on buying and selling and having little chance to use Speech skill.


Note that almost all characters in Fallout 3 should have 9-10 Intelligence


Unless it's just not in-line with how you want your character to be, push it up to eight.


If you don't care about any perks related to Luck, you could drain Luck to support other attributes. Unlike previous Fallout games, a low level of Luck won't cause any directly negative effects.

maxing your Agility and Intelligence early, with Luck following afterwards.


Haven't incorporated it yet, but is really interesting. Google search for "fallout 3 attributes build" turns up some good stuff

Sorry I'm too lazy to attribute the quotes to the right source. This is mostly for me to crib from... You should real the full texts, it's worth it.

I know my calculator looks pretty dumb... the real one looks like this

Tuesday, December 2, 2008

svg transform matrix

Oh what fun you can have with svg!

I'm working on a little flash game and I wanted to design the boards in inkscape, save as svg, transform them to my xml format and load 'em up... but...

Have you seen a one of these yet?


According to the spec, the syntax is matrix(a,b,c,d,e,f) which get laid out in matrix form like this:

if you guessed that, my hat is off to you! To me it is just bizarre...

OK, so what... matrix math rules out the xsl, right? Wrong...

Assuming you can pull out the a,b,c,d,e,f from that kooky string... then you can do this to apply the transformation matrix:

<xsl:attribute name="x">
<xsl:value-of select="$x * $a + $y * $c + $e"/>
<xsl:attribute name="y">
<xsl:value-of select="$x * $b + $y * $d + $f"/>

You have to do the same thing for width and height, too...

Happily, I had some old point * matrix implementation to pull from... if you don't have one handy... see above...


If you read the spec, you will see a bunch of other stuff I didn't bother with cuz I don't need it. Sorry...

Uhhmmm.... and I only ever see the case transform="matrix(0,1,-1,0,0,0)" so I hardcode the values for a,b,c,d,e,f,g like so

<xsl:variable name="a" select="'0'"/>
<xsl:variable name="b" select="'1'"/>
<xsl:variable name="c" select="'-1'"/>
<xsl:variable name="d" select="'0'"/>
<xsl:variable name="e" select="'0'"/>
<xsl:variable name="f" select="'0'"/>

Yeah... I know...

In case it helps, here is the board.xsl as it stands right now...

btw: alias xencode="sed 's/</\&lt;/g;s/>/\&gt;/g;s/\"/\"/g'"

why I left wordpress

Oh, what a heavy heart!
I freakin' ❤'d wordpress, but ultimately I had to move to here's why:

  1. adsense: wordpress doesn't allow it, does.
  2. embed: let's me put flash content in my blog. Since I blog about haxe a lot, this was a real bummer

  3. javascript: I also do some crazy stuff with js and I needs to demo stuff

  4. css: I liked being able to make pre tags look like terminals

I bummed, really, bummed. Even adding the vaulted google analytics I don't have a nice charts and graphs...

And I'm going to have to relink all my projects... woe! woe is me!

I hate to do it, but ... sometimes things are just like that...

find jars by sha1sum :

Ever have a mystery jar? Ever taken over an ant project and need to find what version of log4j the chuckle-heads were using so you can port the project to maven?

Check it out... jar-czar can help... Converting from an sha1sum to a url is ez and will provide you with the version info you needs.

Here is some really simple javascript... to pull form an input called 'sha1sum'

javascript:( function() {
document.location = (
document.getElementById( 'sha1sum' ).value
.replace( /(.*)/, '$1 $1' )
.replace( /^(...)/, '$1x' )
.replace( /(x...)/, '$1x' )
.replace( / /, 'x' )
.replace( /x/g, '/' )
.replace( /(.*)/, '$1-jar-czar.xml' )

as seen on

Here is the shell script way:

% sha1sum jcr-1.0.jar
% sha1sum *.jar | sed 's,\([^ \t]*\) *.*,\1 \1,;s,^...,&/,;s,/...,&/,;s, ,/,;s,.*,,'
% alias sha1_to_jar_car="sed 's,\([^ \t]*\) *.*,\1 \1,;s,^...,&/,;s,/...,&/,;s, ,/,;s,.*,,'"
% sha1sum *.jar | sha1_to_jar_car