two new gfxmatrix functions
authorkramm <kramm>
Wed, 17 Jan 2007 13:33:05 +0000 (13:33 +0000)
committerkramm <kramm>
Wed, 17 Jan 2007 13:33:05 +0000 (13:33 +0000)
lib/gfxtools.c
lib/gfxtools.h

index 76525ea..86970a2 100644 (file)
@@ -705,6 +705,21 @@ void gfxmatrix_invert(gfxmatrix_t*m, gfxmatrix_t*dest)
     dest->tx = -(dest->m00 * m->tx + dest->m10 * m->ty);
     dest->ty = -(dest->m01 * m->tx + dest->m11 * m->ty);
 }
+void gfxmatrix_unit(gfxmatrix_t*m)
+{
+    memset(m, 0, sizeof(gfxmatrix_t));
+    m->m00 = 1.0;
+    m->m11 = 1.0;
+}
+void gfxmatrix_multiply(gfxmatrix_t*m1, gfxmatrix_t*m2, gfxmatrix_t*dest)
+{
+    dest->m00 = m1->m00*m2->m00 + m1->m10*m2->m01 + m1->tx;
+    dest->m01 = m1->m01*m2->m00 + m1->m11*m2->m01 + m1->ty;
+    dest->m10 = m1->m00*m2->m10 + m1->m10*m2->m11 + m1->tx;
+    dest->m11 = m1->m01*m2->m10 + m1->m11*m2->m11 + m1->ty;
+    dest->tx = m1->m00*m2->tx + m1->m10*m2->ty + m1->tx;
+    dest->ty = m1->m01*m2->tx + m1->m11*m2->ty + m1->ty;
+}
 
 gfxfontlist_t* gfxfontlist_create()
 {
index aa41eff..f24faee 100644 (file)
@@ -74,6 +74,8 @@ void gfxline_transform(gfxline_t*line, gfxmatrix_t*matrix);
 void gfxmatrix_dump(gfxmatrix_t*l, FILE*fi, char*prefix);
 void gfxmatrix_transform(gfxmatrix_t*m, gfxcoord_t* v1, gfxcoord_t*dest);
 void gfxmatrix_invert(gfxmatrix_t*src, gfxmatrix_t*dest);
+void gfxmatrix_unit(gfxmatrix_t*m);
+void gfxmatrix_multiply(gfxmatrix_t*m1, gfxmatrix_t*m2, gfxmatrix_t*dest);
 
 gfxfontlist_t* gfxfontlist_create();
 gfxfontlist_t*gfxfontlist_addfont(gfxfontlist_t*list, gfxfont_t*font);