aboutsummaryrefslogtreecommitdiff
path: root/include/cru/platform/painter_util.hpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-04-01 18:08:58 +0800
committercrupest <crupest@outlook.com>2019-04-01 18:08:58 +0800
commitde00126c6aeba189a50296df455dd516e21e4176 (patch)
tree3d89a8a36a3603096d4371230c2d071f91e9e986 /include/cru/platform/painter_util.hpp
parent055a3cde0cd19c896f3e498b774078654555c065 (diff)
downloadcru-de00126c6aeba189a50296df455dd516e21e4176.tar.gz
cru-de00126c6aeba189a50296df455dd516e21e4176.tar.bz2
cru-de00126c6aeba189a50296df455dd516e21e4176.zip
...
Diffstat (limited to 'include/cru/platform/painter_util.hpp')
-rw-r--r--include/cru/platform/painter_util.hpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/cru/platform/painter_util.hpp b/include/cru/platform/painter_util.hpp
new file mode 100644
index 00000000..fed0c487
--- /dev/null
+++ b/include/cru/platform/painter_util.hpp
@@ -0,0 +1,14 @@
+#pragma once
+#include "painter.hpp"
+
+#include <functional>
+
+namespace cru::platform::util {
+inline void WithTransform(Painter* painter, const Matrix& matrix,
+ const std::function<void(Painter*)>& action) {
+ const auto old = painter->GetTransform();
+ painter->SetTransform(old * matrix);
+ action(painter);
+ painter->SetTransform(old);
+}
+}