0

Theoretically it should be possible to combine transformation or color matrices, through addition or multiplication (I'm lame when it comes to such math). Is it possible?

jayarjo
  • 16,124
  • 24
  • 94
  • 138

1 Answers1

2

It is! In Flash, the convolution matrices are defined in the flash.geom package. The transformation matrix is a Matrix and the color matrix is a ColorTransform. Both implement a concat function letting you multiply the effects of another matrix.

var a:Matrix = new Matrix();
a.translate(60, 40);

var b:Matrix = new Matrix();
b.rotate(60);

a.concat(b); // Matrix a now translates and rotates whatever it convolutes.
  • But do you know what's an actual logic behind this? I would like to port it to let's say JavaScript? – jayarjo Dec 20 '11 at 08:36
  • 1
    It is purely matrix multiplication, so any article on matrix multiplication will show you how to do it. You could also consider asking a question in http://math.stackexchange.com/. Rolling your own implementation of a matrix in code can be a bit tricky though. Consider using a library, like http://sylvester.jcoglan.com/ –  Dec 20 '11 at 08:45