diff options
author | crupest <crupest@outlook.com> | 2019-05-24 23:45:58 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-05-24 23:45:58 +0800 |
commit | b6db663269201fa14a6a4aa1b9042645a9e8f859 (patch) | |
tree | 1984e2c2784fb9623d4c20fbdd6fc650792e133c /include/cru/platform/graph/util | |
parent | b9df1bcaea0c19b2e29479cdb1ad5a39e23c4ee7 (diff) | |
download | cru-b6db663269201fa14a6a4aa1b9042645a9e8f859.tar.gz cru-b6db663269201fa14a6a4aa1b9042645a9e8f859.tar.bz2 cru-b6db663269201fa14a6a4aa1b9042645a9e8f859.zip |
...
Diffstat (limited to 'include/cru/platform/graph/util')
-rw-r--r-- | include/cru/platform/graph/util/painter_util.hpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/cru/platform/graph/util/painter_util.hpp b/include/cru/platform/graph/util/painter_util.hpp new file mode 100644 index 00000000..71e125c3 --- /dev/null +++ b/include/cru/platform/graph/util/painter_util.hpp @@ -0,0 +1,18 @@ +#pragma once +#include "../painter.hpp" + +#include <functional> +#include <type_traits> + +namespace cru::platform::graph::util { +template <typename Fn> +inline void WithTransform(IPainter* painter, const Matrix& matrix, + const Fn& action) { + static_assert(std::is_invocable_v<decltype(action), IPainter*>, + "Action must can be be invoked with painter."); + const auto old = painter->GetTransform(); + painter->SetTransform(old * matrix); + action(painter); + painter->SetTransform(old); +} +} // namespace cru::platform::util |