From b6db663269201fa14a6a4aa1b9042645a9e8f859 Mon Sep 17 00:00:00 2001 From: crupest Date: Fri, 24 May 2019 23:45:58 +0800 Subject: ... --- include/cru/platform/graph/util/painter_util.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 include/cru/platform/graph/util/painter_util.hpp (limited to 'include/cru/platform/graph/util') 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 +#include + +namespace cru::platform::graph::util { +template +inline void WithTransform(IPainter* 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