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