From 6aa2201797a9ed64ce0178215ae941d0c5f09579 Mon Sep 17 00:00:00 2001 From: crupest Date: Fri, 30 Oct 2020 00:07:57 +0800 Subject: ... --- include/cru/platform/graphics/util/Painter.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 include/cru/platform/graphics/util/Painter.hpp (limited to 'include/cru/platform/graphics/util') diff --git a/include/cru/platform/graphics/util/Painter.hpp b/include/cru/platform/graphics/util/Painter.hpp new file mode 100644 index 00000000..af3a1997 --- /dev/null +++ b/include/cru/platform/graphics/util/Painter.hpp @@ -0,0 +1,17 @@ +#pragma once +#include "../Painter.hpp" + +#include +#include + +namespace cru::platform::graphics::util { +template +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::graphics::util -- cgit v1.2.3