diff --git a/darwin/draw.m b/darwin/draw.m index a8569737..167d3af4 100644 --- a/darwin/draw.m +++ b/darwin/draw.m @@ -333,9 +333,9 @@ void uiDrawMatrixRotate(uiDrawMatrix *m, double x, double y, double amount) c2m(&c, m); } -void uiDrawMatrixSkew(uiDrawMatrix *m, double x, double y, double amount, double yamount) +void uiDrawMatrixSkew(uiDrawMatrix *m, double x, double y, double xamount, double yamount) { - complain("TODO"); + fallbackSkew(m, x, y, xamount, yamount); } void uiDrawMatrixMultiply(uiDrawMatrix *dest, uiDrawMatrix *src) diff --git a/matrix.c b/matrix.c index eda79ed8..937fc136 100644 --- a/matrix.c +++ b/matrix.c @@ -12,7 +12,23 @@ void setIdentity(uiDrawMatrix *m) m->M32 = 0; } -// TODO skew +// TODO don't default to fallback functions within the fallback functions + +// technique from "Programming with Quartz: 2D and PDF Graphics in Mac OS X" +// TODO if Windows 7 is ever dropped change this so we can pass in D2D1Tan() +void fallbackSkew(uiDrawMatrix *m, double x, double y, double xamount, double yamount) +{ + uiDrawMatrix t, n; + + setIdentity(&t); + fallbackTranslate(&t, x, y); + setIdentity(&n); + n.M12 = tan(xamount); + n.M21 = tan(yamount); + fallbackMultiply(&n, &t); + // TODO undo the translation? + fallbackMultiply(&m, &n); +} // see windows/draw.c for more information // TODO we don't need to do this if we can bypass the multiplication somehow diff --git a/uipriv.h b/uipriv.h index 6c355d2a..247a317f 100644 --- a/uipriv.h +++ b/uipriv.h @@ -62,6 +62,7 @@ extern int fromScancode(uintptr_t, uiAreaKeyEvent *); // matrix.c extern void setIdentity(uiDrawMatrix *); +extern void fallbackSkew(uiDrawMatrix *, double, double, double, double); extern void fallbackTranslate(uiDrawMatrix *, double, double); extern void scaleCenter(double, double, double *, double *); extern void fallbackScale(uiDrawMatrix *, double, double, double, double); diff --git a/unix/draw.c b/unix/draw.c index 24c13dda..565a0edc 100644 --- a/unix/draw.c +++ b/unix/draw.c @@ -362,9 +362,9 @@ void uiDrawMatrixRotate(uiDrawMatrix *m, double x, double y, double amount) c2m(&c, m); } -void uiDrawMatrixSkew(uiDrawMatrix *m, double x, double y, double amount, double yamount) +void uiDrawMatrixSkew(uiDrawMatrix *m, double x, double y, double xamount, double yamount) { - complain("TODO"); + fallbackSkew(m, x, y, xamount, yamount); } void uiDrawMatrixMultiply(uiDrawMatrix *dest, uiDrawMatrix *src)