From 7274636a7e36578dae1a82c03b3e7a05d6f2ffe3 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sun, 24 Jun 2018 14:34:01 +1000 Subject: [PATCH] Added coordinate system links in documentation --- docs/handbook/concepts.rst | 2 ++ src/PIL/Image.py | 17 ++++++++++------- src/PIL/ImageDraw.py | 3 ++- src/PIL/ImageMorph.py | 4 ++-- src/PIL/ImageTk.py | 4 ++-- src/PIL/ImageTransform.py | 2 +- src/PIL/ImageWin.py | 5 +++-- src/PIL/PyAccess.py | 6 ++++-- 8 files changed, 26 insertions(+), 17 deletions(-) diff --git a/docs/handbook/concepts.rst b/docs/handbook/concepts.rst index fd410afe0..b2611c11b 100644 --- a/docs/handbook/concepts.rst +++ b/docs/handbook/concepts.rst @@ -58,6 +58,8 @@ You can read the image size through the :py:attr:`~PIL.Image.Image.size` attribute. This is a 2-tuple, containing the horizontal and vertical size in pixels. +.. _coordinate-system: + Coordinate System ----------------- diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 6cc9ec7ca..31e91c0cf 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -1066,7 +1066,7 @@ class Image(object): """ Returns a rectangular region from this image. The box is a 4-tuple defining the left, upper, right, and lower pixel - coordinate. + coordinate. See :ref:`coordinate-system`. Note: Prior to Pillow 3.4.0, this was a lazy operation. @@ -1173,8 +1173,9 @@ class Image(object): image. :returns: The bounding box is returned as a 4-tuple defining the - left, upper, right, and lower pixel coordinate. If the image - is completely empty, this method returns None. + left, upper, right, and lower pixel coordinate. See + :ref:`coordinate-system`. If the image is completely empty, this + method returns None. """ @@ -1275,7 +1276,8 @@ class Image(object): """ Returns the pixel value at a given position. - :param xy: The coordinate, given as (x, y). + :param xy: The coordinate, given as (x, y). See + :ref:`coordinate-system`. :returns: The pixel value. If the image is a multi-layer image, this method returns a tuple. """ @@ -1335,8 +1337,8 @@ class Image(object): Pastes another image into this image. The box argument is either a 2-tuple giving the upper left corner, a 4-tuple defining the left, upper, right, and lower pixel coordinate, or None (same as - (0, 0)). If a 4-tuple is given, the size of the pasted image - must match the size of the region. + (0, 0)). See :ref:`coordinate-system`. If a 4-tuple is given, the size + of the pasted image must match the size of the region. If the modes don't match, the pasted image is converted to the mode of this image (see the :py:meth:`~PIL.Image.Image.convert` method for @@ -1616,7 +1618,8 @@ class Image(object): * :py:meth:`~PIL.Image.Image.putdata` * :py:mod:`~PIL.ImageDraw` - :param xy: The pixel coordinate, given as (x, y). + :param xy: The pixel coordinate, given as (x, y). See + :ref:`coordinate-system`. :param value: The pixel value. """ diff --git a/src/PIL/ImageDraw.py b/src/PIL/ImageDraw.py index 89df27338..0de6a9e3b 100644 --- a/src/PIL/ImageDraw.py +++ b/src/PIL/ImageDraw.py @@ -327,7 +327,8 @@ def floodfill(image, xy, value, border=None, thresh=0): (experimental) Fills a bounded region with a given color. :param image: Target image. - :param xy: Seed position (a 2-item coordinate tuple). + :param xy: Seed position (a 2-item coordinate tuple). See + :ref:`coordinate-system`. :param value: Fill color. :param border: Optional border value. If given, the region consists of pixels with a color different from the border color. If not given, diff --git a/src/PIL/ImageMorph.py b/src/PIL/ImageMorph.py index d2367737f..579ee4e1a 100644 --- a/src/PIL/ImageMorph.py +++ b/src/PIL/ImageMorph.py @@ -211,7 +211,7 @@ class MorphOp(object): an image. Returns a list of tuples of (x,y) coordinates - of all matching pixels.""" + of all matching pixels. See :ref:`coordinate-system`.""" if self.lut is None: raise Exception('No operator loaded') @@ -223,7 +223,7 @@ class MorphOp(object): """Get a list of all turned on pixels in a binary image Returns a list of tuples of (x,y) coordinates - of all matching pixels.""" + of all matching pixels. See :ref:`coordinate-system`.""" if image.mode != 'L': raise Exception('Image must be binary, meaning it must use mode L') diff --git a/src/PIL/ImageTk.py b/src/PIL/ImageTk.py index faf52d2b9..b5ad53df7 100644 --- a/src/PIL/ImageTk.py +++ b/src/PIL/ImageTk.py @@ -169,8 +169,8 @@ class PhotoImage(object): mode does not match, the image is converted to the mode of the bitmap image. :param box: A 4-tuple defining the left, upper, right, and lower pixel - coordinate. If None is given instead of a tuple, all of - the image is assumed. + coordinate. See :ref:`coordinate-system`. If None is given + instead of a tuple, all of the image is assumed. """ # convert to blittable diff --git a/src/PIL/ImageTransform.py b/src/PIL/ImageTransform.py index 4207ffb83..c3f6af8b5 100644 --- a/src/PIL/ImageTransform.py +++ b/src/PIL/ImageTransform.py @@ -65,7 +65,7 @@ class ExtentTransform(Transform): See :py:meth:`~PIL.Image.Image.transform` :param bbox: A 4-tuple (x0, y0, x1, y1) which specifies two points in the - input image's coordinate system. + input image's coordinate system. See :ref:`coordinate-system`. """ method = Image.EXTENT diff --git a/src/PIL/ImageWin.py b/src/PIL/ImageWin.py index d8398e92b..9b86270bc 100644 --- a/src/PIL/ImageWin.py +++ b/src/PIL/ImageWin.py @@ -154,8 +154,9 @@ class Dib(object): If the mode does not match, the image is converted to the mode of the bitmap image. :param box: A 4-tuple defining the left, upper, right, and - lower pixel coordinate. If None is given instead of a - tuple, all of the image is assumed. + lower pixel coordinate. See :ref:`coordinate-system`. If + None is given instead of a tuple, all of the image is + assumed. """ im.load() if self.mode != im.mode: diff --git a/src/PIL/PyAccess.py b/src/PIL/PyAccess.py index 7eec1b160..cce2de2b8 100644 --- a/src/PIL/PyAccess.py +++ b/src/PIL/PyAccess.py @@ -68,7 +68,8 @@ class PyAccess(object): numerical value for single band images, and a tuple for multi-band images - :param xy: The pixel coordinate, given as (x, y). + :param xy: The pixel coordinate, given as (x, y). See + :ref:`coordinate-system`. :param color: The pixel value. """ if self.readonly: @@ -82,7 +83,8 @@ class PyAccess(object): value for single band images or a tuple for multiple band images - :param xy: The pixel coordinate, given as (x, y). + :param xy: The pixel coordinate, given as (x, y). See + :ref:`coordinate-system`. :returns: a pixel value for single band images, a tuple of pixel values for multiband images. """