blob: e36d5c55e71d61287aeeac38d7583f40fabb5d5d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#pragma once
#include "../Painter.h"
#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->PushState();
painter->ConcatTransform(matrix);
action(painter);
painter->PopState();
}
} // namespace cru::platform::graphics::util
|