diff options
Diffstat (limited to 'include/cru/platform/graphics/util/Painter.hpp')
-rw-r--r-- | include/cru/platform/graphics/util/Painter.hpp | 17 |
1 files changed, 17 insertions, 0 deletions
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 <functional> +#include <type_traits> + +namespace cru::platform::graphics::util { +template <typename Fn> +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::graphics::util |