uxebu / bonsai

BonsaiJS is a graphics library and renderer
http://bonsaijs.org
Other
1.96k stars 189 forks source link

Better matrix animations Edit #182

Open iamdustan opened 11 years ago

iamdustan commented 11 years ago

Came across this matrix interpolation while reading up on matrices as implemented in Flash 8. Worth checking out to see if it cleans up some of the current transformation issues (e.g. Rects)?

// from http://www.readability.com/read?url=http%3A//www.senocular.com/flash/tutorials/transformmatrix/
function matrixInterpolate(m1, m2, t){
    var mi = new flash.geom.Matrix();
    mi.a = m1.a + (m2.a - m1.a)*t;
    mi.b = m1.b + (m2.b - m1.b)*t;
    mi.c = m1.c + (m2.c - m1.c)*t;
    mi.d = m1.d + (m2.d - m1.d)*t;
    mi.tx = m1.tx + (m2.tx - m1.tx)*t;
    mi.ty = m1.ty + (m2.ty - m1.ty)*t;
    return mi;
}