From 7351020a582d70a1495249fba87d342c8a1fb634 Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 10 Apr 2019 19:42:46 +0800 Subject: Refactor. --- include/cru/platform/graph/painter_util.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 include/cru/platform/graph/painter_util.hpp (limited to 'include/cru/platform/graph/painter_util.hpp') diff --git a/include/cru/platform/graph/painter_util.hpp b/include/cru/platform/graph/painter_util.hpp new file mode 100644 index 00000000..c137e8cb --- /dev/null +++ b/include/cru/platform/graph/painter_util.hpp @@ -0,0 +1,18 @@ +#pragma once +#include "painter.hpp" + +#include +#include + +namespace cru::platform::graph::util { +template +inline void WithTransform(Painter* painter, const Matrix& matrix, + const Fn& action) { + static_assert(std::is_invocable_v, + "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 -- cgit v1.2.3