From a99a81f58479d06b51adcadd4dd962792bbd303a Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 22 May 2016 22:52:29 -0400 Subject: [PATCH] Answered matrix scaling stuff. https://www.willamette.edu/~gorr/classes/GeneralGraphics/Transforms/transforms2d.htm#Combining --- README.md | 1 + darwin/draw.m | 3 +-- unix/drawmatrix.c | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3ba91ad6..68ff8f4b 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ This README is being written.
* uiDateTimePicker on GTK+ works properly on RTL layouts and no longer disappears off the bottom of the screen if not enough room is available. It will also no longer be marked for localization of the time format (what the separator should be and whether to use 24-hour time), as that information is not provided by the locale system. :( * Added `uiUserBugCannotSetParentOnToplevel()`, which should be used by implementations of toplevel controls in their `SetParent()` implementations. This will also be the beginning of consolidating common user bug messages into a single place, though this will be one of the only few exported user bug functions. * uiSpinbox and uiSlider now merely swap their min and max if min ≥ max. They will no longer panic and do nothing, respectively. + * Matrix scaling will no longer leave the matrix in an invalid state on OS X and GTK+. ## Runtime Requirements diff --git a/darwin/draw.m b/darwin/draw.m index 0552c07d..68d02bc0 100644 --- a/darwin/draw.m +++ b/darwin/draw.m @@ -332,13 +332,12 @@ void uiDrawMatrixScale(uiDrawMatrix *m, double xCenter, double yCenter, double x double xt, yt; m2c(m, &c); - // TODO explain why the translation must come first xt = x; yt = y; scaleCenter(xCenter, yCenter, &xt, &yt); c = CGAffineTransformTranslate(c, xt, yt); c = CGAffineTransformScale(c, x, y); - // TODO undo the translation? + c = CGAffineTransformTranslate(c, -xt, -yt); c2m(&c, m); } diff --git a/unix/drawmatrix.c b/unix/drawmatrix.c index 807b60d9..ac7ac579 100644 --- a/unix/drawmatrix.c +++ b/unix/drawmatrix.c @@ -37,13 +37,12 @@ void uiDrawMatrixScale(uiDrawMatrix *m, double xCenter, double yCenter, double x double xt, yt; m2c(m, &c); - // TODO explain why the translation must come first xt = x; yt = y; scaleCenter(xCenter, yCenter, &xt, &yt); cairo_matrix_translate(&c, xt, yt); cairo_matrix_scale(&c, x, y); - // TODO undo the translation? + cairo_matrix_translate(&c, -xt, -yt); c2m(&c, m); } @@ -54,7 +53,6 @@ void uiDrawMatrixRotate(uiDrawMatrix *m, double x, double y, double amount) m2c(m, &c); cairo_matrix_translate(&c, x, y); cairo_matrix_rotate(&c, amount); - // TODO undo the translation? also cocoa backend cairo_matrix_translate(&c, -x, -y); c2m(&c, m); }