aboutsummaryrefslogtreecommitdiff
path: root/include/cru/platform/graphics/Painter.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru/platform/graphics/Painter.h')
-rw-r--r--include/cru/platform/graphics/Painter.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/cru/platform/graphics/Painter.h b/include/cru/platform/graphics/Painter.h
index de44c7b4..2e122a08 100644
--- a/include/cru/platform/graphics/Painter.h
+++ b/include/cru/platform/graphics/Painter.h
@@ -1,4 +1,5 @@
#pragma once
+#include <type_traits>
#include "Base.h"
namespace cru::platform::graphics {
@@ -42,5 +43,15 @@ struct CRU_PLATFORM_GRAPHICS_API IPainter : virtual IPlatformResource {
virtual void PopState() = 0;
virtual void EndDraw() = 0;
+
+ template <typename Fn>
+ std::enable_if_t<std::is_invocable_v<Fn, IPainter*>> WithTransform(
+ const Matrix& matrix, const Fn& action) {
+ const auto old = this->GetTransform();
+ this->PushState();
+ this->ConcatTransform(matrix);
+ action(this);
+ this->PopState();
+ }
};
} // namespace cru::platform::graphics