« New GalaxyGoo Blog? | Main | Alton Brown Blog »

beginGradientFill with a-i, instead of box?

If you're not one of the coders who reads this blog, please just ignor this post.

Now, if you're a Flash coder and you're nice and comfy with gradient fills, I have a question for you. What does the a-i stand for in this matrix option for beginGradientFill:

matrix = {a:500, b:0, c:0, d:0, e:200, f:0, g:350, h:200, i:1}

Iv'e seen explanations of how to use the "box" type matrix, but not the a-i type.

Comments

a and b are the horizontal offsets (a is x, b is y).

d and e are the vertical offsets (d is x, e is y).

g and h are the center point offsets (g is x, h is y).

I have no idea what c, f, and i do. They may just be space fillers so that the 3*3 matrix transforms can still take place. affine matrix transforms are also used for 3d transformations - so another guess is that c, f, and i are for z axis stuff (which flash, naturally, can't use anyway... so they're blank).

That is just a Matrix in its raw form. Basically the used pairs are a-b, d-e, and g-h. The other letters are just there to balance it. a-b is the x coordinate, c-d is y, and g-h is the amount (x,y) it is moved once it is transformed (called translation).

The only weird part is the two letters affecting one coordinate in the first two sets. It comes down to 'a' is the x coordiante scale, and 'b' is the amount the y coordinate affects it. Similarily 'e' is the y coordinate scale, and d the amount x affects it (backwards from the first set).

So you can use this extra number to rotate or skew. Without gory details, if you think of skewing a box, as the side of the box (x) goes up and down it moves to the left or right, depending on how high up it is (y). So there is that kind of relation going on with the two numbers.

Matrices are useful when you need a single way to store a series of operations like this, but really I don't think they are so practical until at least code is generating them. Personally I sometimes think it is just a way of making a few fairly simple calculations look more complicated, or a hangover from pre-calculator days. Or maybe a drunk from pre-abacus days.

Well I'm sure some total ass will come along and point out how half assed that answer is (which it is). There is lots more to know about a Matrix of course, but having struggled through that stuff myself for many a painful day, I don't find it all that useful. I would personally recommend just opt for the red pill in this case.

Well he had to slip a painful Matrix reference in there after all didn't he. after all didn't he. Cripes. My super cool sunglasses keep falling off.

OK, I'm completely confused now...I'll be back once I do some experimenting :-)