@@ -60,11 +60,37 @@ PyRendererAgg_draw_path(RendererAgg *self,
6060static void
6161PyRendererAgg_draw_text_image (RendererAgg *self,
6262 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 ,
6565 double angle,
6666 GCAgg &gc)
6767{
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+
6894 // TODO: This really shouldn't be mutable, but Agg's renderer buffers aren't const.
6995 auto image = image_obj.mutable_unchecked <2 >();
7096
0 commit comments