diff --git a/doc/api/next_api_changes/deprecations/25728-OG.rst b/doc/api/next_api_changes/deprecations/25728-OG.rst new file mode 100644 index 000000000000..09af74845c4a --- /dev/null +++ b/doc/api/next_api_changes/deprecations/25728-OG.rst @@ -0,0 +1,4 @@ +``ft2font.FT2Image.draw_rect`` and ``ft2font.FT2Font.get_xys`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +... are deprecated as they are unused. If you rely on these, please let us know. diff --git a/src/_path.h b/src/_path.h index bfbb7b49d254..b04e49bb8ffb 100644 --- a/src/_path.h +++ b/src/_path.h @@ -282,35 +282,15 @@ inline bool point_in_path( return result[0] != 0; } -template -void points_on_path(PointArray &points, - const double r, - PathIterator &path, - agg::trans_affine &trans, - ResultArray result) +template +inline bool point_on_path( + double x, double y, const double r, PathIterator &path, agg::trans_affine &trans) { typedef agg::conv_transform transformed_path_t; typedef PathNanRemover no_nans_t; typedef agg::conv_curve curve_t; typedef agg::conv_stroke stroke_t; - size_t i; - for (i = 0; i < points.size(); ++i) { - result[i] = false; - } - - transformed_path_t trans_path(path, trans); - no_nans_t nan_removed_path(trans_path, true, path.has_codes()); - curve_t curved_path(nan_removed_path); - stroke_t stroked_path(curved_path); - stroked_path.width(r * 2.0); - point_in_path_impl(points, stroked_path, result); -} - -template -inline bool point_on_path( - double x, double y, const double r, PathIterator &path, agg::trans_affine &trans) -{ npy_intp shape[] = {1, 2}; numpy::array_view points(shape); points(0, 0) = x; @@ -319,8 +299,12 @@ inline bool point_on_path( int result[1]; result[0] = 0; - points_on_path(points, r, path, trans, result); - + transformed_path_t trans_path(path, trans); + no_nans_t nan_removed_path(trans_path, true, path.has_codes()); + curve_t curved_path(nan_removed_path); + stroke_t stroked_path(curved_path); + stroked_path.width(r * 2.0); + point_in_path_impl(points, stroked_path, result); return result[0] != 0; } diff --git a/src/_path_wrapper.cpp b/src/_path_wrapper.cpp index e1cb0a4f89af..6b19c0f8ac1e 100644 --- a/src/_path_wrapper.cpp +++ b/src/_path_wrapper.cpp @@ -91,98 +91,6 @@ static PyObject *Py_points_in_path(PyObject *self, PyObject *args) return results.pyobj(); } -const char *Py_point_on_path__doc__ = - "point_on_path(x, y, radius, path, trans)\n" - "--\n\n"; - -static PyObject *Py_point_on_path(PyObject *self, PyObject *args) -{ - double x, y, r; - py::PathIterator path; - agg::trans_affine trans; - bool result; - - if (!PyArg_ParseTuple(args, - "dddO&O&:point_on_path", - &x, - &y, - &r, - &convert_path, - &path, - &convert_trans_affine, - &trans)) { - return NULL; - } - - CALL_CPP("point_on_path", (result = point_on_path(x, y, r, path, trans))); - - if (result) { - Py_RETURN_TRUE; - } else { - Py_RETURN_FALSE; - } -} - -const char *Py_points_on_path__doc__ = - "points_on_path(points, radius, path, trans)\n" - "--\n\n"; - -static PyObject *Py_points_on_path(PyObject *self, PyObject *args) -{ - numpy::array_view points; - double r; - py::PathIterator path; - agg::trans_affine trans; - - if (!PyArg_ParseTuple(args, - "O&dO&O&:points_on_path", - &convert_points, - &points, - &r, - &convert_path, - &path, - &convert_trans_affine, - &trans)) { - return NULL; - } - - npy_intp dims[] = { (npy_intp)points.size() }; - numpy::array_view results(dims); - - CALL_CPP("points_on_path", (points_on_path(points, r, path, trans, results))); - - return results.pyobj(); -} - -const char *Py_get_path_extents__doc__ = - "get_path_extents(path, trans)\n" - "--\n\n"; - -static PyObject *Py_get_path_extents(PyObject *self, PyObject *args) -{ - py::PathIterator path; - agg::trans_affine trans; - - if (!PyArg_ParseTuple( - args, "O&O&:get_path_extents", &convert_path, &path, &convert_trans_affine, &trans)) { - return NULL; - } - - extent_limits e; - - CALL_CPP("get_path_extents", (reset_limits(e))); - CALL_CPP("get_path_extents", (update_path_extents(path, trans, e))); - - npy_intp dims[] = { 2, 2 }; - numpy::array_view extents(dims); - extents(0, 0) = e.x0; - extents(0, 1) = e.y0; - extents(1, 0) = e.x1; - extents(1, 1) = e.y1; - - return extents.pyobj(); -} - const char *Py_update_path_extents__doc__ = "update_path_extents(path, trans, rect, minpos, ignore)\n" "--\n\n"; @@ -845,9 +753,6 @@ static PyObject *Py_is_sorted(PyObject *self, PyObject *obj) static PyMethodDef module_functions[] = { {"point_in_path", (PyCFunction)Py_point_in_path, METH_VARARGS, Py_point_in_path__doc__}, {"points_in_path", (PyCFunction)Py_points_in_path, METH_VARARGS, Py_points_in_path__doc__}, - {"point_on_path", (PyCFunction)Py_point_on_path, METH_VARARGS, Py_point_on_path__doc__}, - {"points_on_path", (PyCFunction)Py_points_on_path, METH_VARARGS, Py_points_on_path__doc__}, - {"get_path_extents", (PyCFunction)Py_get_path_extents, METH_VARARGS, Py_get_path_extents__doc__}, {"update_path_extents", (PyCFunction)Py_update_path_extents, METH_VARARGS, Py_update_path_extents__doc__}, {"get_path_collection_extents", (PyCFunction)Py_get_path_collection_extents, METH_VARARGS, Py_get_path_collection_extents__doc__}, {"point_in_path_collection", (PyCFunction)Py_point_in_path_collection, METH_VARARGS, Py_point_in_path_collection__doc__}, diff --git a/src/ft2font.cpp b/src/ft2font.cpp index 2e5d6e63b87d..975041374133 100644 --- a/src/ft2font.cpp +++ b/src/ft2font.cpp @@ -725,11 +725,6 @@ FT_UInt FT2Font::get_char_index(FT_ULong charcode, bool fallback = false) return ft_get_char_index_or_warn(ft_object->get_face(), charcode, false); } -void FT2Font::get_cbox(FT_BBox &bbox) -{ - FT_Glyph_Get_CBox(glyphs.back(), ft_glyph_bbox_subpixels, &bbox); -} - void FT2Font::get_width_height(long *width, long *height) { *width = advance; diff --git a/src/ft2font.h b/src/ft2font.h index dc157f0e2887..d566c3f9bd9d 100644 --- a/src/ft2font.h +++ b/src/ft2font.h @@ -37,7 +37,6 @@ class FT2Image void resize(long width, long height); void draw_bitmap(FT_Bitmap *bitmap, FT_Int x, FT_Int y); - void write_bitmap(FILE *fp) const; void draw_rect(unsigned long x0, unsigned long y0, unsigned long x1, unsigned long y1); void draw_rect_filled(unsigned long x0, unsigned long y0, unsigned long x1, unsigned long y1); @@ -106,7 +105,6 @@ class FT2Font void get_glyph_name(unsigned int glyph_number, char *buffer, bool fallback); long get_name_index(char *name); FT_UInt get_char_index(FT_ULong charcode, bool fallback); - void get_cbox(FT_BBox &bbox); PyObject* get_path(); bool get_char_fallback_index(FT_ULong charcode, int& index) const; diff --git a/src/ft2font_wrapper.cpp b/src/ft2font_wrapper.cpp index 41109bf13860..8f37b5c7d9ad 100644 --- a/src/ft2font_wrapper.cpp +++ b/src/ft2font_wrapper.cpp @@ -69,10 +69,21 @@ static void PyFT2Image_dealloc(PyFT2Image *self) const char *PyFT2Image_draw_rect__doc__ = "draw_rect(self, x0, y0, x1, y1)\n" "--\n\n" - "Draw an empty rectangle to the image.\n"; + "Draw an empty rectangle to the image.\n" + "\n" + ".. deprecated:: 3.8\n"; +; static PyObject *PyFT2Image_draw_rect(PyFT2Image *self, PyObject *args) { + char const* msg = + "FT2Image.draw_rect is deprecated since Matplotlib 3.8 and will be removed " + "two minor releases later as it is not used in the library. If you rely on " + "it, please let us know."; + if (PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1)) { + return NULL; + } + double x0, y0, x1, y1; if (!PyArg_ParseTuple(args, "dddd:draw_rect", &x0, &y0, &x1, &y1)) { @@ -820,10 +831,20 @@ static PyObject *PyFT2Font_draw_glyphs_to_bitmap(PyFT2Font *self, PyObject *args const char *PyFT2Font_get_xys__doc__ = "get_xys(self, antialiased=True)\n" "--\n\n" - "Get the xy locations of the current glyphs.\n"; + "Get the xy locations of the current glyphs.\n" + "\n" + ".. deprecated:: 3.8\n"; static PyObject *PyFT2Font_get_xys(PyFT2Font *self, PyObject *args, PyObject *kwds) { + char const* msg = + "FT2Font.get_xys is deprecated since Matplotlib 3.8 and will be removed two " + "minor releases later as it is not used in the library. If you rely on it, " + "please let us know."; + if (PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1)) { + return NULL; + } + bool antialiased = true; std::vector xys; const char *names[] = { "antialiased", NULL }; diff --git a/src/tri/_tri.cpp b/src/tri/_tri.cpp index 548e65b3e52d..b54eb3e07fb8 100644 --- a/src/tri/_tri.cpp +++ b/src/tri/_tri.cpp @@ -133,11 +133,6 @@ double XYZ::dot(const XYZ& other) const return x*other.x + y*other.y + z*other.z; } -double XYZ::length_squared() const -{ - return x*x + y*y + z*z; -} - XYZ XYZ::operator-(const XYZ& other) const { return XYZ(x - other.x, y - other.y, z - other.z); @@ -182,12 +177,6 @@ ContourLine::ContourLine() : std::vector() {} -void ContourLine::insert_unique(iterator pos, const XY& point) -{ - if (empty() || pos == end() || point != *pos) - std::vector::insert(pos, point); -} - void ContourLine::push_back(const XY& point) { if (empty() || point != back()) diff --git a/src/tri/_tri.h b/src/tri/_tri.h index 6c6c66a01120..c176b4c0e8f5 100644 --- a/src/tri/_tri.h +++ b/src/tri/_tri.h @@ -116,7 +116,6 @@ struct XYZ XYZ(const double& x_, const double& y_, const double& z_); XYZ cross(const XYZ& other) const; double dot(const XYZ& other) const; - double length_squared() const; XYZ operator-(const XYZ& other) const; friend std::ostream& operator<<(std::ostream& os, const XYZ& xyz); @@ -137,14 +136,12 @@ class BoundingBox }; /* A single line of a contour, which may be a closed line loop or an open line - * strip. Identical adjacent points are avoided using insert_unique() and - * push_back(), and a closed line loop should also not have identical first and - * last points. */ + * strip. Identical adjacent points are avoided using push_back(), and a closed + * line loop should also not have identical first and last points. */ class ContourLine : public std::vector { public: ContourLine(); - void insert_unique(iterator pos, const XY& point); void push_back(const XY& point); void write() const; };