@@ -60,11 +60,37 @@ PyRendererAgg_draw_path(RendererAgg *self,
60
60
static void
61
61
PyRendererAgg_draw_text_image (RendererAgg *self,
62
62
py::array_t <agg::int8u, py::array::c_style | py::array::forcecast> image_obj,
63
- double x ,
64
- double y ,
63
+ std::variant< double , int > vx ,
64
+ std::variant< double , int > vy ,
65
65
double angle,
66
66
GCAgg &gc)
67
67
{
68
+ int x, y;
69
+
70
+ if (auto value = std::get_if<double >(&vx)) {
71
+ auto api = py::module_::import (" matplotlib._api" );
72
+ auto warn = api.attr (" warn_deprecated" );
73
+ warn (" since" _a=" 3.10" , " name" _a=" x" , " obj_type" _a=" parameter as float" ,
74
+ " alternative" _a=" int(x)" );
75
+ x = static_cast <int >(*value);
76
+ } else if (auto value = std::get_if<int >(&vx)) {
77
+ x = *value;
78
+ } else {
79
+ throw std::runtime_error (" Should not happen" );
80
+ }
81
+
82
+ if (auto value = std::get_if<double >(&vy)) {
83
+ auto api = py::module_::import (" matplotlib._api" );
84
+ auto warn = api.attr (" warn_deprecated" );
85
+ warn (" since" _a=" 3.10" , " name" _a=" y" , " obj_type" _a=" parameter as float" ,
86
+ " alternative" _a=" int(y)" );
87
+ y = static_cast <int >(*value);
88
+ } else if (auto value = std::get_if<int >(&vy)) {
89
+ y = *value;
90
+ } else {
91
+ throw std::runtime_error (" Should not happen" );
92
+ }
93
+
68
94
// TODO: This really shouldn't be mutable, but Agg's renderer buffers aren't const.
69
95
auto image = image_obj.mutable_unchecked <2 >();
70
96
0 commit comments