blob: f9aec027a46f77a6439604c0a3ca0603cc83e6cd (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 | #pragma once
#include "../Painter.hpp"
#include <functional>
#include <type_traits>
namespace cru::platform::graph::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::graph::util
 |