forked from matplotlib/matplotlib
- Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpy_converters.cpp
22 lines (19 loc) · 677 Bytes
/
py_converters.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include"py_converters.h"
voidconvert_trans_affine(const py::object& transform, agg::trans_affine& affine)
{
// If None assume identity transform so leave affine unchanged
if (transform.is_none()) {
return;
}
auto array = py::array_t<double, py::array::c_style>::ensure(transform);
if (!array || array.ndim() != 2 || array.shape(0) != 3 || array.shape(1) != 3) {
throwstd::invalid_argument("Invalid affine transformation matrix");
}
auto buffer = array.data();
affine.sx = buffer[0];
affine.shx = buffer[1];
affine.tx = buffer[2];
affine.shy = buffer[3];
affine.sy = buffer[4];
affine.ty = buffer[5];
}