debian/0000775000000000000000000000000012316332553007173 5ustar debian/source/0000775000000000000000000000000011737331034010472 5ustar debian/source/format0000664000000000000000000000001411737330437011706 0ustar 3.0 (quilt) debian/copyright0000664000000000000000000001061411737330437011135 0ustar Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: pycairo Source: http://cairographics.org/releases/ Files: * Copyright: 2003-2010 James Henstridge, Steven Chaplin License: LGPL-3 Files: examples/gtk/lsystem.py Copyright: 2003 Jesse Andrews License: LGPL-3 Files: waf-uncompressed Copyright: 2005-2010 Thomas Nagy License: BSD-3-clause Files: waflib/* Copyright: 2005-2010 Thomas Nagy License: BSD-3-clause Files: debian/* Copyright: 2012 Koichi Akabe License: GPL-3+ Files: examples/gtk/hangman.py Copyright: 2004 Kevin Worth License: MIT Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of the Kevin Worth not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. Kevin Worth California makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. . KEVIN WORTH DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KEVIN WORTH BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. License: LGPL-3 Pycairo is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 as published by the Free Software Foundation. . Pycairo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. . On Debian systems, the complete text of the GNU Lesser General Public License V3 can be found in /usr/share/common-licenses/LGPL-3 file. License: BSD-3-clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: . 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. . 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. . 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. . THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. License: GPL-3+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. . You should have received a copy of the GNU General Public License along with this program. If not, see . On Debian systems, the complete text of the GNU General Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". debian/python3-cairo-doc.docs0000664000000000000000000000002111737330437013305 0ustar doc/_build/html/ debian/waf-uncompress.sh0000775000000000000000000000137511737330437012516 0ustar #!/bin/sh BASEDIR=$1 OLD_IFS=$IFS IFS=" " script="" tar_bz2="" WAF="$BASEDIR/waf" inputdata=`sed -e "s|\\\\x0|#0000|g" $WAF | sed -e "s|\\\\\\\\|#005c|g"` is_script=1 for line in $inputdata do case $line in \#==\>) is_script=0 ;; \#\<==) is_script=1 ;; *) if test $is_script -eq 1; then script=$script$line"\n" else tar_bz2=$line fi ;; esac done echo "$script" > "$BASEDIR/waf-uncompressed" chmod +x "$BASEDIR/waf-uncompressed" echo -n "$tar_bz2" | sed "s|^#||g" | sed "s|#\\/|\\n|g" | sed "s|#\\*|\\r|g" | sed "s|#0000|\\x0|g" | sed "s|#005c|\\\\|g" | \ tar -xjf - -C $BASEDIR IFS=$OLD_IFS debian/python3-cairo-doc.doc-base0000664000000000000000000000045411737330437014044 0ustar Document: python3-cairo Title: Pycairo documentation Author: Steven Chaplin Abstract: Manual for Pycairo Section: Graphics Format: HTML Index: /usr/share/doc/python3-cairo-doc/html/index.html Files: /usr/share/doc/python3-cairo-doc/html/*.html /usr/share/doc/python3-cairo-doc/html/reference/*.html debian/python3-cairo-dev.install0000664000000000000000000000004011737330437014035 0ustar usr/include/ usr/lib/pkgconfig/ debian/changelog0000664000000000000000000000515112316332553011047 0ustar py3cairo (1.10.0+dfsg-3ubuntu2) trusty; urgency=medium * No change rebuild to drop python3.3 compiled extension. -- Dimitri John Ledkov Mon, 31 Mar 2014 19:35:23 +0100 py3cairo (1.10.0+dfsg-3ubuntu1) trusty; urgency=medium * Don't link the extension with the python library. -- Matthias Klose Thu, 20 Feb 2014 12:50:38 +0100 py3cairo (1.10.0+dfsg-3build2) trusty; urgency=medium * Rebuild for Python 3.4. -- Matthias Klose Wed, 19 Feb 2014 21:01:47 +0100 py3cairo (1.10.0+dfsg-3build1) trusty; urgency=medium * Rebuild for python3.4 as a supported python version. -- Matthias Klose Sat, 04 Jan 2014 18:31:45 +0000 py3cairo (1.10.0+dfsg-3) unstable; urgency=low * Upload to unstable (Closes: #707145) -- Koichi Akabe Wed, 15 May 2013 09:58:53 +0900 py3cairo (1.10.0+dfsg-3~exp4) experimental; urgency=low * rebuild for Python 3.3 (Closes: #703676) * debian/patches/60_python-config-without-interpreter.patch - fix waflib to support python 3.3 * debian/control - update Standards-Version to 3.9.4 - remove obsolete DMUA -- Koichi Akabe Sat, 30 Mar 2013 17:58:39 +0900 py3cairo (1.10.0+dfsg-3~exp3) experimental; urgency=low * debian/rules - fix build for other python3 versions (Closes: #691241) * debian/patches/50_specify-encoding-in-waf.patch - add to fix encoding probrem on python 3.3 -- Koichi Akabe Sun, 28 Oct 2012 20:00:11 +0900 py3cairo (1.10.0+dfsg-3~exp2) experimental; urgency=low * debian/patches/101_pycairo-region.patch - add support for cairo_region_t (Closes: 688079) -- Koichi Akabe Thu, 20 Sep 2012 16:14:24 +0900 py3cairo (1.10.0+dfsg-3~exp1) experimental; urgency=low * debian/rules - support DEB_BUILD_OPTIONS=nocheck (Closes: #681034) - add -v flag to waf to output verbose log * debian/compat - up to 9 to add hardening flags * debian/control - update debhelper version to 9 - enable DM-Upload -- Koichi Akabe Tue, 10 Jul 2012 22:52:04 +0900 py3cairo (1.10.0+dfsg-2) unstable; urgency=low * debian/rules - use pytest to run the test suite * debian/patches/10_test-target-py3.patch - add to change py.test script to use all versions of Python 3 * debian/control - add build-depends: python3-pytest -- Koichi Akabe Mon, 16 Apr 2012 08:21:25 +0900 py3cairo (1.10.0+dfsg-1) unstable; urgency=low * Initial release. (Closes: #662957) -- Koichi Akabe Thu, 05 Apr 2012 23:34:52 +0900 debian/python3-cairo.install0000664000000000000000000000002211737330437013261 0ustar /usr/lib/python*/ debian/control0000664000000000000000000000343212316332553010600 0ustar Source: py3cairo Section: python Priority: optional Maintainer: Ubuntu Developers XSBC-Original-Maintainer: Debian Python Modules Team Uploaders: Koichi Akabe Build-Depends: debhelper (>= 9.0.0), python3-all-dev (>= 3.1), libcairo2-dev (>= 1.10.0), python-sphinx (>= 1.0.7+dfsg) | python3-sphinx, python3-pytest Standards-Version: 3.9.4 Homepage: http://cairographics.org/pycairo/ X-Python3-Version: >= 3.1 Vcs-Svn: svn://svn.debian.org/python-modules/packages/py3cairo/trunk/ Vcs-Browser: http://svn.debian.org/viewsvn/python-modules/packages/py3cairo/trunk/ Package: python3-cairo Architecture: any Depends: ${shlibs:Depends}, ${python3:Depends}, ${misc:Depends} Description: Python 3 bindings for the Cairo vector graphics library Cairo is a multi-platform library providing anti-aliased vector-based rendering for multiple target backends. . This package contains modules that allow you to use the Cairo in Python 3 programs. Package: python3-cairo-dev Architecture: all Depends: python3-cairo (>= ${binary:Version}), ${misc:Depends} Suggests: python3-cairo-doc Description: Python 3 cairo bindings: development files Cairo is a multi-platform library providing anti-aliased vector-based rendering for multiple target backends. . This package contains files that allow you to compile wrappers that interoperate with python3-cairo (py3cairo). Package: python3-cairo-doc Section: doc Architecture: all Depends: ${misc:Depends}, ${sphinxdoc:Depends} Description: Python 3 cairo bindings: documentation files Cairo is a multi-platform library providing anti-aliased vector-based rendering for multiple target backends. . This package contains documentation files of python3-cairo (py3cairo). debian/rules0000775000000000000000000000500512043177710010252 0ustar #!/usr/bin/make -f %: dh "$@" --with sphinxdoc --with python3 upstream_version ?= $(shell dpkg-parsechangelog | sed -rne 's/^Version: ([0-9.]+)(\+dfsg)?.*$$/\1/p') dfsg_version = $(upstream_version)+dfsg upstream_pkg = "pycairo" pkg = $(shell dpkg-parsechangelog | sed -ne 's/^Source: //p') get-orig-source: uscan --rename --download-current-version --destdir=. tar -xjf $(pkg)_$(upstream_version).orig.tar.bz2 rm -f $(pkg)_$(upstream_version).orig.tar.bz2 mv $(upstream_pkg)-$(upstream_version) $(pkg)_$(dfsg_version).orig $(CURDIR)/debian/waf-uncompress.sh $(pkg)_$(dfsg_version).orig rm $(pkg)_$(dfsg_version).orig/waf rm -r $(pkg)_$(dfsg_version).orig/doc/_build tar -cjf $(CURDIR)/../$(pkg)_$(dfsg_version).orig.tar.bz2 $(pkg)_$(dfsg_version).orig rm -r $(pkg)_$(dfsg_version).orig override_dh_auto_configure: : # configure done in the build target to build for multiple python versions override_dh_auto_build: set -x; \ for pyversion in $(shell py3versions -vr); do \ echo "configuring for $$pyversion"; \ PYTHON=python$$pyversion python$$pyversion $(CURDIR)/waf-uncompressed configure -v -o $(CURDIR)/build$$pyversion --prefix /usr --nopyc --nopyo; \ echo "building for $$pyversion"; \ PYTHON=python$$pyversion python$$pyversion $(CURDIR)/waf-uncompressed build -v -o $(CURDIR)/build$$pyversion; \ done mkdir -p $(CURDIR)/doc/_build/html cd $(CURDIR)/doc && $(MAKE) html override_dh_auto_install: for pyversion in $(shell py3versions -vr); do \ cp -p $(CURDIR)/build$$pyversion/.lock-wafbuild .; \ PYTHON=python$$pyversion python$$pyversion $(CURDIR)/waf-uncompressed install -v -o $(CURDIR)/build$$pyversion --destdir $(CURDIR)/debian/tmp; \ done override_dh_clean: dh_clean for pyversion in $(shell py3versions -vr); \ do rm -rf $(CURDIR)/build$$pyversion; \ done rm -rf $(CURDIR)/.waf* $(CURDIR)/.lock* $(CURDIR)/doc/_build $(CURDIR)/test/cairo \ `find $(CURDIR) -name "__pycache__"` \ `find $(CURDIR)/waflib -name "*.pyc"` \ `find $(CURDIR)/examples -name "*.pdf" -o -name "*.png" -o -name "*.ps" -o -name "*.svg"` override_dh_compress: dh_compress -X.js -X.inv override_dh_sphinxdoc: (! test -d $(CURDIR)/debian/python3-cairo-doc || dh_sphinxdoc) ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS))) override_dh_auto_test: mkdir $(CURDIR)/test/cairo ln -s $(CURDIR)/src/__init__.py $(CURDIR)/test/cairo/__init__.py for pyversion in $(shell py3versions -vr); \ do ln -sf $(CURDIR)/build$$pyversion/src/*.so $(CURDIR)/test/cairo; \ cd $(CURDIR)/test && python$$pyversion -m pytest; \ done endif debian/watch0000664000000000000000000000014611737330437010232 0ustar version=3 opts=dversionmangle=s/\+dfsg// \ http://cairographics.org/releases/pycairo-(\d.*)\.tar\.bz2 debian/python3-cairo-dev.examples0000664000000000000000000000001611737330437014210 0ustar examples/*.py debian/patches/0000775000000000000000000000000012301366007010615 5ustar debian/patches/10_test-target-py3.patch0000664000000000000000000000140411742653510015117 0ustar Description: Use all versions for py.test This patch changes py.test script to use all versions of Python 3 command instead of python. Author: Koichi Akabe Last-Update: <2012-04-12> --- py3cairo-1.10.0+dfsg.orig/test/examples_test.py +++ py3cairo-1.10.0+dfsg/test/examples_test.py @@ -14,7 +14,8 @@ def test_snippets(): examples/cairo_snippets/snippets/ ''' def doSnippets(name): - retcode = subprocess.call('python %s -s' % name, shell=True) + import sys + retcode = subprocess.call('PYTHONPATH=../../test python%d.%d %s -s' % (sys.version_info[0], sys.version_info[1], name), shell=True) assert retcode == 0, 'Error: retcode == {0}'.format(retcode) os.chdir(os.path.join(os.path.dirname(__file__), '..', 'examples', debian/patches/50_specify-encoding-in-waf.patch0000664000000000000000000000215412043210051016537 0ustar Description: specify encoding in waf This patch specifies utf-8 as the encoding in waf library, because python 3.3 doesn't fallback to utf-8 on default. Author: Matthias Klose Origin: http://launchpadlibrarian.net/120606963/py3cairo_1.10.0%2Bdfsg-3~exp2_1.10.0%2Bdfsg-3~exp2ubuntu1.diff.gz Bug-Debian: http://bugs.debian.org/691241 Last-Update: 2012-10-28 --- py3cairo-1.10.0+dfsg.orig/waflib/Utils.py +++ py3cairo-1.10.0+dfsg/waflib/Utils.py @@ -77,8 +77,8 @@ except ImportError: return value is_win32=sys.platform=='win32' indicator=is_win32 and'\x1b[A\x1b[K%s%s%s\r'or'\x1b[K%s%s%s\r' -def readf(fname,m='r'): - f=open(fname,m) +def readf(fname,m='r',enc=None): + f=open(fname,m,encoding=enc) try: txt=f.read() finally: --- py3cairo-1.10.0+dfsg.orig/waflib/Tools/c_preproc.py +++ py3cairo-1.10.0+dfsg/waflib/Tools/c_preproc.py @@ -44,7 +44,7 @@ def repl(m): return' ' return m.group(3)or'' def filter_comments(filename): - code=Utils.readf(filename) + code=Utils.readf(filename, enc='utf-8') if use_trigraphs: for(a,b)in trig_def:code=code.split(a).join(b) code=re_nl.sub('',code) debian/patches/dont-link-libpython.diff0000664000000000000000000000136612301366007015362 0ustar Index: b/waflib/Tools/python.py =================================================================== --- a/waflib/Tools/python.py +++ b/waflib/Tools/python.py @@ -155,8 +155,10 @@ if result: break if result: - env['LIBPATH_PYEMBED']=path - env.append_value('LIB_PYEMBED',[name]) + # don't link libpython explicitly + #env['LIBPATH_PYEMBED']=path + #env.append_value('LIB_PYEMBED',[name]) + pass else: conf.to_log("\n\n### LIB NOT FOUND\n") if(sys.platform=='win32'or sys.platform.startswith('os2')or sys.platform=='darwin'or dct['Py_ENABLE_SHARED']): @@ -278,4 +280,4 @@ conf(get_python_variables) conf(check_python_headers) conf(check_python_version) -conf(check_python_module) \ No newline at end of file +conf(check_python_module) debian/patches/60_python-config-without-interpreter.patch0000664000000000000000000000155212125535372021003 0ustar Description: run python-config directly This patch runs /usr/bin/python-config directly for python 3.3 Author: Sebastien Bacher Origin: http://launchpadlibrarian.net/125114732/py3cairo_1.10.0%2Bdfsg-3~exp3_1.10.0%2Bdfsg-3~exp3ubuntu1.diff.gz Last-Update: 2013-03-30 --- py3cairo-1.10.0+dfsg.orig/waflib/Tools/python.py +++ py3cairo-1.10.0+dfsg/waflib/Tools/python.py @@ -169,7 +169,7 @@ def check_python_headers(conf): conf.find_program('python-config-%s'%num,var='PYTHON_CONFIG',mandatory=False) includes=[] if conf.env.PYTHON_CONFIG: - for incstr in conf.cmd_and_log(conf.env.PYTHON+[conf.env.PYTHON_CONFIG,'--includes']).strip().split(): + for incstr in conf.cmd_and_log([conf.env.PYTHON_CONFIG,'--includes']).strip().split(): if(incstr.startswith('-I')or incstr.startswith('/I')): incstr=incstr[2:] if incstr not in includes: debian/patches/series0000664000000000000000000000022712301365706012040 0ustar 10_test-target-py3.patch 50_specify-encoding-in-waf.patch 101_pycairo-region.patch 60_python-config-without-interpreter.patch dont-link-libpython.diff debian/patches/101_pycairo-region.patch0000664000000000000000000006614112026544170015161 0ustar Description: Add support for cairo_region_t This patch fix missing support for cairo_region_t. Author: Bug Fly Origin: https://bugs.freedesktop.org/attachment.cgi?id=61553 Bug-Debian: http://bugs.debian.org/688079 Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/py3cairo/+bug/1028115 Last-Update: 2012-08-20 Applied-Upstream: http://cgit.freedesktop.org/pycairo/commit/?id=75e82a1b3f495a3abbc78e50a5c66356d320fb15 --- py3cairo-1.10.0+dfsg.orig/doc/pycairo_c_api.rst +++ py3cairo-1.10.0+dfsg/doc/pycairo_c_api.rst @@ -51,6 +51,8 @@ Objects:: PycairoGradient PycairoLinearGradient PycairoRadialGradient + PycairoRectangleInt + PycairoRegion PycairoScaledFont PycairoSurface PycairoImageSurface @@ -78,6 +80,8 @@ Types:: PyTypeObject *Gradient_Type; PyTypeObject *LinearGradient_Type; PyTypeObject *RadialGradient_Type; + PyTypeObject *RectangleInt_Type; + PyTypeObject *Region_Type; PyTypeObject *ScaledFont_Type; PyTypeObject *Surface_Type; PyTypeObject *ImageSurface_Type; @@ -115,6 +119,12 @@ Functions .. c:function:: PyObject * PycairoPattern_FromPattern(cairo_pattern_t *pattern, PyObject *base) +.. c:function:: PyObject * PycairoRectangleInt_FromRectangleInt(const cairo_rectangle_int_t *rectangle_int) + + +.. c:function:: PyObject * PycairoRegion_FromRegion(const cairo_region_t *region) + + .. c:function:: PyObject * PycairoScaledFont_FromScaledFont(cairo_scaled_font_t *scaled_font) --- py3cairo-1.10.0+dfsg.orig/doc/reference/index.rst +++ py3cairo-1.10.0+dfsg/doc/reference/index.rst @@ -15,5 +15,6 @@ Reference matrix paths patterns + region surfaces text --- /dev/null +++ py3cairo-1.10.0+dfsg/doc/reference/region.rst @@ -0,0 +1,52 @@ +.. _region: + +****** +Region +****** +Region — Representing a pixel-aligned area + +.. currentmodule:: cairo + + +class Region() +============== +*Region* is a simple graphical data type representing an area of +integer-aligned rectangles. They are often used on raster surfaces to track +areas of interest, such as change or clip areas. + + +.. class:: Region([rectangle_int|rectangle_ints]) + + :param rectangle_int: a rectangle or a list of rectangle + :type rectangle_int: :class:`RectangleInt` or [:class:`RectangleInt`] + + Allocates a new empty region object or a region object with the containing + rectangle(s). + + + .. method:: copy() + + :returns: A newly allocated :class:`Region`. + :raises: :exc:`NoMemory` if memory cannot be allocated. + + Allocates a new *Region* object copying the area from original. + + +class RectangleInt() +==================== +*RectangleInt* is a data structure for holding a rectangle with integer +coordinates. + + +.. class:: RectangleInt(x=0, y=0, width=0, height=0) + + :param x: X coordinate of the left side of the rectangle + :type x: int + :param y: Y coordinate of the the top side of the rectangle + :type y: int + :param width: width of the rectangle + :type width: int + :param height: height of the rectangle + :type height: int + + Allocates a new *RectangleInt* object. --- /dev/null +++ py3cairo-1.10.0+dfsg/src/region.c @@ -0,0 +1,598 @@ +/* -*- mode: C; c-basic-offset: 2 -*- + * + * Copyright © 2005,2010 Steve Chaplin + * + * This file is part of pycairo. + * + * Pycairo is free software: you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License version 3 as published + * by the Free Software Foundation. + * + * Pycairo is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for + * more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with pycairo. If not, see . + */ + +#define PY_SSIZE_T_CLEAN +#include +#include "structmember.h" + +#include "config.h" +#include "private.h" + +/* PycairoRectangleInt_FromRectangleInt + * Create a new PycairoRectangleInt from a cairo_rectangle_int_t + * rectangle_int - a cairo_rectangle_int_t to 'wrap' into a Python object. + * rectangle_int is unreferenced if the PycairoRectangleInt creation + * fails. + * Return value: New reference or NULL on failure + */ +PyObject * +PycairoRectangleInt_FromRectangleInt (cairo_rectangle_int_t *rectangle_int) { + PyObject *o; + + assert (rectangle_int != NULL); + + o = PycairoRectangleInt_Type.tp_alloc (&PycairoRectangleInt_Type, 0); + if (o) + ((PycairoRectangleInt *)o)->rectangle_int = *rectangle_int; + return o; +} + +static void +rectangle_int_dealloc(PycairoRectangleInt *o) { +#ifdef DEBUG + printf("rectangle_int_dealloc start\n"); +#endif + //o->ob_type->tp_free((PyObject *)o); + Py_TYPE(o)->tp_free(o); +#ifdef DEBUG + printf("rectangle_int_dealloc end\n"); +#endif +} + +static PyObject * +rectangle_int_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { + static char *kwlist[] = { "x", "y", "width", "height", NULL }; + int x, y, w, h; + x = y = w = h = 0; + cairo_rectangle_int_t rect; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, + "|iiii:RectangleInt.__new__", kwlist, + &x, &y, &w, &h)) + return NULL; + + rect.x = x; + rect.y = y; + rect.width = w; + rect.height = h; + + return PycairoRectangleInt_FromRectangleInt(&rect); +} + +static PyObject * +rectangle_int_str(PycairoRectangleInt *rect_o) { + PyObject *s; + cairo_rectangle_int_t *rect = &(rect_o->rectangle_int); + char buf[80]; + PyOS_snprintf(buf, sizeof(buf), "cairo.RectangleInt(%d, %d, %d, %d)", + rect->x, rect->y, rect->width, rect->height); + s = PyUnicode_FromString(buf); + return s; +} + +static PyObject * +rectangle_int_richcompare(PycairoRectangleInt *self, + PycairoRectangleInt *other, int op) { + int res = 0; + PyObject *b; + + if (op != Py_EQ && op != Py_NE) { + PyErr_SetString(PyExc_TypeError, "Only support testing for == or !="); + return NULL; + } + if (!PyObject_IsInstance((PyObject*)other, + (PyObject*)&PycairoRectangleInt_Type)) { + res = 0; + } + else if ( + self->rectangle_int.x == other->rectangle_int.x && + self->rectangle_int.y == other->rectangle_int.y && + self->rectangle_int.width == other->rectangle_int.width && + self->rectangle_int.height == other->rectangle_int.height + ) + res = 1; + res = op == Py_NE ? !res : res; + b = res ? Py_True : Py_False; + Py_INCREF(b); + + return b; +} + +static PyMemberDef RectangleInt_members[] = { + {"x", T_INT, sizeof(PyObject), 0, + "X coordinate of the left side of the rectangle"}, + {"y", T_INT, sizeof(PyObject)+sizeof(int), 0, + "Y coordinate of the the top side of the rectangle"}, + {"width", T_INT, sizeof(PyObject)+sizeof(int)*2, 0, + "width of the rectangle"}, + {"height", T_INT, sizeof(PyObject)+sizeof(int)*3, 0, + "height of the rectangle"}, + {NULL} +}; + +PyTypeObject PycairoRectangleInt_Type = { + PyVarObject_HEAD_INIT(&PyType_Type, 0) + "cairo.RectangleInt", /* tp_name */ + sizeof(PycairoRectangleInt), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)rectangle_int_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc)rectangle_int_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + (richcmpfunc)rectangle_int_richcompare, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + RectangleInt_members, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + (newfunc)rectangle_int_new, /* tp_new */ +}; + +/* PycairoRegion_FromRegion + * Create a new PycairoRegion from a cairo_region_t + * region - a cairo_region_t to 'wrap' into a Python object. + * region is unreferenced if the PycairoRegion creation fails, or if + * region is in an error status. + * Return value: New reference or NULL on failure + */ +PyObject * +PycairoRegion_FromRegion (cairo_region_t *region) { + PyObject *o; + + assert (region != NULL); + + if (Pycairo_Check_Status (cairo_region_status(region))) { + cairo_region_destroy (region); + return NULL; + } + + o = PycairoRegion_Type.tp_alloc (&PycairoRegion_Type, 0); + if (o) + ((PycairoRegion *)o)->region = region; + else + cairo_region_destroy (region); + return o; +} + +static void +region_dealloc(PycairoRegion *o) { +#ifdef DEBUG + printf("region_dealloc start\n"); +#endif + if (o->region) { + cairo_region_destroy(o->region); + o->region = NULL; + } + //o->ob_type->tp_free((PyObject *)o); + Py_TYPE(o)->tp_free(o); +#ifdef DEBUG + printf("region_dealloc end\n"); +#endif +} + +static PyObject * +region_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { + PyObject *s = NULL; + PycairoRectangleInt *rect_obj = NULL; + cairo_region_t *region = NULL; + cairo_rectangle_int_t *rect = NULL; + + if (PyArg_ParseTuple(args, "|O!:Region.__new__", + &PycairoRectangleInt_Type, &rect_obj)) { + if (rect_obj != NULL) { + region = cairo_region_create_rectangle(&(rect_obj->rectangle_int)); + } + } else if (!PyArg_ParseTuple(args, "|O:Region.__new__", &s)) { + PyErr_SetString(PyExc_TypeError, + "argument must be a RectangleInt or a sequence of RectangleInt."); + return NULL; + } + PyErr_Clear(); /* Clear possible err in the 1st arg parser. */ + + /* list of rectangle_int or no args */ + if (s != NULL) { + int i; + int rect_size; + PyObject *seq = NULL; + seq = PySequence_Fast (s, + "argument must be a RectangleInt or a sequence of RectangleInt."); + if (seq == NULL) { + return NULL; + } + rect_size = PySequence_Fast_GET_SIZE(seq); + rect = PyMem_Malloc (rect_size * sizeof(cairo_rectangle_int_t)); + if (rect == NULL) { + Py_DECREF(seq); + return PyErr_NoMemory(); + } + + for(i=0; irectangle_int; + } + + region = cairo_region_create_rectangles(rect, rect_size); + + Py_DECREF(seq); + PyMem_Free(rect); + } + + if (region == NULL) { + region = cairo_region_create(); + } + + RETURN_NULL_IF_CAIRO_REGION_ERROR(region); + return PycairoRegion_FromRegion(region); +} + +PyObject * +region_copy (PycairoRegion *o) { + cairo_region_t *res; + Py_BEGIN_ALLOW_THREADS; + res = cairo_region_copy (o->region); + Py_END_ALLOW_THREADS; + RETURN_NULL_IF_CAIRO_REGION_ERROR(res); + return PycairoRegion_FromRegion(res); +} + + +PyObject * +region_get_extents (PycairoRegion *o) { + cairo_rectangle_int_t rect; + Py_BEGIN_ALLOW_THREADS; + cairo_region_get_extents(o->region, &rect); + Py_END_ALLOW_THREADS; + + return PycairoRectangleInt_FromRectangleInt(&rect); +} + + +PyObject * +region_num_rectangles (PycairoRegion *o) { + int res; + Py_BEGIN_ALLOW_THREADS; + res = cairo_region_num_rectangles(o->region); + Py_END_ALLOW_THREADS; + return Py_BuildValue("i", res); +} + + +PyObject * +region_get_rectangle (PycairoRegion *o, PyObject *args) { + cairo_rectangle_int_t rect; + int i; + int total; + if (!PyArg_ParseTuple (args, "i:Region.get_rectangle", &i)) + return NULL; + total = cairo_region_num_rectangles(o->region); + if (i >= total || i < 0) { + if ( i < 0) + PyErr_SetString(PyExc_ValueError, "index must be a positive number"); + else + PyErr_SetString(PyExc_ValueError, "index is to big for the region"); + return NULL; + } + Py_BEGIN_ALLOW_THREADS; + cairo_region_get_rectangle(o->region, i, &rect); + Py_END_ALLOW_THREADS; + return PycairoRectangleInt_FromRectangleInt(&rect); +} + + +PyObject * +region_is_empty (PycairoRegion *o) { + cairo_bool_t res; + PyObject *b; + Py_BEGIN_ALLOW_THREADS; + res = cairo_region_is_empty(o->region); + Py_END_ALLOW_THREADS; + b = res ? Py_True : Py_False; + Py_INCREF(b); + return b; +} + + +PyObject * +region_contains_point (PycairoRegion *o, PyObject *args) { + int x, y; + cairo_bool_t res; + PyObject *b; + if (!PyArg_ParseTuple (args, "ii:Region.contains_point", &x, &y)) + return NULL; + Py_BEGIN_ALLOW_THREADS; + res = cairo_region_contains_point(o->region, x, y); + Py_END_ALLOW_THREADS; + b = res ? Py_True : Py_False; + Py_INCREF(b); + return b; +} + + +PyObject * +region_contains_rectangle (PycairoRegion *o, PyObject *args) { + cairo_region_overlap_t res; + PycairoRectangleInt *rect_int; + if (!PyArg_ParseTuple (args, "O!:Region.contains_rectangle", + &PycairoRectangleInt_Type, &rect_int)) + return NULL; + Py_BEGIN_ALLOW_THREADS; + res = cairo_region_contains_rectangle(o->region, &(rect_int->rectangle_int)); + Py_END_ALLOW_THREADS; + return Py_BuildValue("i", res); +} + + +PyObject * +region_equal (PycairoRegion *o, PyObject *args) { + cairo_bool_t res; + PyObject *b; + PycairoRegion *region_obj; + if (!PyArg_ParseTuple (args, "O!:Region.equal", + &PycairoRegion_Type, ®ion_obj)) + return NULL; + Py_BEGIN_ALLOW_THREADS; + res = cairo_region_equal (o->region, region_obj->region); + Py_END_ALLOW_THREADS; + b = res ? Py_True : Py_False; + Py_INCREF(b); + return b; +} + +static PyObject * +region_richcompare(PycairoRegion *self, PycairoRegion *other, int op) { + int res = 0; + PyObject *b; + + if (op != Py_EQ && op != Py_NE) { + PyErr_SetString(PyExc_TypeError, "Only support testing for == or !="); + return NULL; + } + if (!PyObject_IsInstance((PyObject*)other, (PyObject*)&PycairoRegion_Type)) { + res = 0; + } else { + res = cairo_region_equal (self->region, other->region); + } + + res = op == Py_NE ? !res : res; + b = res ? Py_True : Py_False; + Py_INCREF(b); + + return b; +} + +PyObject * +region_translate (PycairoRegion *o, PyObject *args) { + int x, y; + if (!PyArg_ParseTuple (args, "ii:Region.translate", &x, &y)) + return NULL; + Py_BEGIN_ALLOW_THREADS; + cairo_region_translate (o->region, x, y); + Py_END_ALLOW_THREADS; + Py_RETURN_NONE; +} + + +PyObject * +region_intersect (PycairoRegion *o, PyObject *args) { + cairo_status_t res; + PyObject *other; + if (!PyArg_ParseTuple (args, "O:Region.intersect", &other)) + return NULL; + + if (PyObject_IsInstance(other, (PyObject*)&PycairoRegion_Type) == 1) { + Py_BEGIN_ALLOW_THREADS; + res = cairo_region_intersect(o->region, + ((PycairoRegion *)other)->region); + Py_END_ALLOW_THREADS; + } else if (PyObject_IsInstance(other, + (PyObject*)&PycairoRectangleInt_Type) == 1) { + Py_BEGIN_ALLOW_THREADS; + res = cairo_region_intersect_rectangle(o->region, + &(((PycairoRectangleInt *)other)->rectangle_int)); + Py_END_ALLOW_THREADS; + } else { + PyErr_SetString(PyExc_TypeError, + "argument must be a Region or a RectangleInt."); + return NULL; + } + + RETURN_NULL_IF_CAIRO_ERROR(res); + Py_RETURN_NONE; +} + +PyObject * +region_subtract (PycairoRegion *o, PyObject *args) { + cairo_status_t res; + PyObject *other; + if (!PyArg_ParseTuple (args, "O:Region.subtract", &other)) + return NULL; + + if (PyObject_IsInstance(other, (PyObject*)&PycairoRegion_Type) == 1) { + Py_BEGIN_ALLOW_THREADS; + res = cairo_region_subtract(o->region, + ((PycairoRegion *)other)->region); + Py_END_ALLOW_THREADS; + } else if (PyObject_IsInstance(other, + (PyObject*)&PycairoRectangleInt_Type) == 1) { + Py_BEGIN_ALLOW_THREADS; + res = cairo_region_subtract_rectangle(o->region, + &(((PycairoRectangleInt *)other)->rectangle_int)); + Py_END_ALLOW_THREADS; + } else { + PyErr_SetString(PyExc_TypeError, + "argument must be a Region or a RectangleInt."); + return NULL; + } + RETURN_NULL_IF_CAIRO_ERROR(res); + Py_RETURN_NONE; +} + +PyObject * +region_union (PycairoRegion *o, PyObject *args) { + cairo_status_t res; + PyObject *other; + if (!PyArg_ParseTuple (args, "O:Region.union", &other)) + return NULL; + + if (PyObject_IsInstance(other, (PyObject*)&PycairoRegion_Type) == 1) { + Py_BEGIN_ALLOW_THREADS; + res = cairo_region_union(o->region, + ((PycairoRegion *)other)->region); + Py_END_ALLOW_THREADS; + } else if (PyObject_IsInstance(other, + (PyObject*)&PycairoRectangleInt_Type) == 1) { + Py_BEGIN_ALLOW_THREADS; + res = cairo_region_union_rectangle(o->region, + &(((PycairoRectangleInt *)other)->rectangle_int)); + Py_END_ALLOW_THREADS; + } else { + PyErr_SetString(PyExc_TypeError, + "argument must be a Region or a RectangleInt."); + return NULL; + } + RETURN_NULL_IF_CAIRO_ERROR(res); + Py_RETURN_NONE; +} + +PyObject * +region_xor (PycairoRegion *o, PyObject *args) { + cairo_status_t res; + PyObject *other; + if (!PyArg_ParseTuple (args, "O:Region.xorg", &other)) + return NULL; + + if (PyObject_IsInstance(other, (PyObject*)&PycairoRegion_Type) == 1) { + Py_BEGIN_ALLOW_THREADS; + res = cairo_region_xor(o->region, + ((PycairoRegion *)other)->region); + Py_END_ALLOW_THREADS; + } else if (PyObject_IsInstance(other, + (PyObject*)&PycairoRectangleInt_Type) == 1) { + Py_BEGIN_ALLOW_THREADS; + res = cairo_region_xor_rectangle(o->region, + &(((PycairoRectangleInt *)other)->rectangle_int)); + Py_END_ALLOW_THREADS; + } else { + PyErr_SetString(PyExc_TypeError, + "argument must be a Region or a RectangleInt."); + return NULL; + } + RETURN_NULL_IF_CAIRO_ERROR(res); + Py_RETURN_NONE; +} + +static PyMethodDef region_methods[] = { + /* methods never exposed in a language binding: + * cairo_region_destroy() + * cairo_region_get_type() + * cairo_region_reference() + * + * cairo_region_status() + * - not needed since Pycairo handles status checking + * + * _(intersect/subtract/union/xor)_rectangle are merged with the region + * ones. + */ + {"copy", (PyCFunction)region_copy, METH_NOARGS }, + {"get_extents", (PyCFunction)region_get_extents, METH_NOARGS }, + {"num_rectangles", (PyCFunction)region_num_rectangles, METH_NOARGS }, + {"get_rectangle", (PyCFunction)region_get_rectangle, METH_VARARGS }, + {"is_empty", (PyCFunction)region_is_empty, METH_NOARGS }, + {"contains_point", (PyCFunction)region_contains_point, METH_VARARGS }, + {"contains_rectangle", (PyCFunction)region_contains_rectangle, + METH_VARARGS }, + {"equal", (PyCFunction)region_equal, METH_VARARGS }, + {"translate", (PyCFunction)region_translate, METH_VARARGS }, + {"intersect", (PyCFunction)region_intersect, METH_VARARGS }, + {"subtract", (PyCFunction)region_subtract, METH_VARARGS }, + {"union", (PyCFunction)region_union, METH_VARARGS }, + {"xor", (PyCFunction)region_xor, METH_VARARGS }, + {NULL, NULL, 0, NULL}, +}; + +PyTypeObject PycairoRegion_Type = { + PyVarObject_HEAD_INIT(&PyType_Type, 0) + "cairo.Region", /* tp_name */ + sizeof(PycairoRegion), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)region_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + (richcmpfunc)region_richcompare, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + region_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + (newfunc)region_new, /* tp_new */ +}; --- py3cairo-1.10.0+dfsg.orig/src/py3cairo.h +++ py3cairo-1.10.0+dfsg/src/py3cairo.h @@ -67,6 +67,16 @@ typedef struct { typedef struct { PyObject_HEAD + cairo_rectangle_int_t rectangle_int; +} PycairoRectangleInt; + +typedef struct { + PyObject_HEAD + cairo_region_t *region; +} PycairoRegion; + +typedef struct { + PyObject_HEAD cairo_scaled_font_t *scaled_font; } PycairoScaledFont; @@ -129,6 +139,14 @@ typedef struct { /* misc functions */ int (*Check_Status)(cairo_status_t status); + + PyTypeObject *RectangleInt_Type; + PyObject *(*RectangleInt_FromRectangleInt)( + const cairo_rectangle_int_t *rectangle_int); + + PyTypeObject *Region_Type; + PyObject *(*Region_FromRegion)(const cairo_region_t *region); + } Pycairo_CAPI_t; @@ -156,6 +174,13 @@ typedef struct { #define PycairoRadialGradient_Type *(Pycairo_CAPI->RadialGradient_Type) #define PycairoPattern_FromPattern (Pycairo_CAPI->Pattern_FromPattern) +#define PycairoRectangleInt_Type *(Pycairo_CAPI->RectangleInt_Type) +#define PycairoRectangleInt_FromRectangleInt \ + (Pycairo_CAPI->RectangleInt_FromRectangleInt) + +#define PycairoRegion_Type *(Pycairo_CAPI->Region_Type) +#define PycairoRegion_FromRegion (Pycairo_CAPI->Region_FromRegion) + #define PycairoScaledFont_Type *(Pycairo_CAPI->ScaledFont_Type) #define PycairoScaledFont_FromScaledFont \ (Pycairo_CAPI->ScaledFont_FromScaledFont) --- py3cairo-1.10.0+dfsg.orig/src/cairomodule.c +++ py3cairo-1.10.0+dfsg/src/cairomodule.c @@ -141,6 +141,12 @@ static Pycairo_CAPI_t CAPI = { PycairoSurface_FromSurface, Pycairo_Check_Status, + + &PycairoRectangleInt_Type, + PycairoRectangleInt_FromRectangleInt, + + &PycairoRegion_Type, + PycairoRegion_FromRegion, }; static PyObject * @@ -230,6 +236,12 @@ PyInit__cairo(void) if (PyType_Ready(&PycairoRadialGradient_Type) < 0) return NULL; + if (PyType_Ready(&PycairoRectangleInt_Type) < 0) + return NULL; + + if (PyType_Ready(&PycairoRegion_Type) < 0) + return NULL; + if (PyType_Ready(&PycairoScaledFont_Type) < 0) return NULL; @@ -315,6 +327,12 @@ PyInit__cairo(void) PyModule_AddObject(m, "RadialGradient", (PyObject *)&PycairoRadialGradient_Type); + Py_INCREF(&PycairoRectangleInt_Type); + PyModule_AddObject(m, "RectangleInt", (PyObject *)&PycairoRectangleInt_Type); + + Py_INCREF(&PycairoRegion_Type); + PyModule_AddObject(m, "Region", (PyObject *)&PycairoRegion_Type); + Py_INCREF(&PycairoScaledFont_Type); PyModule_AddObject(m, "ScaledFont", (PyObject *)&PycairoScaledFont_Type); @@ -519,6 +537,10 @@ PyInit__cairo(void) CONSTANT(PS_LEVEL_3); #endif + CONSTANT(REGION_OVERLAP_IN); + CONSTANT(REGION_OVERLAP_OUT); + CONSTANT(REGION_OVERLAP_PART); + CONSTANT(SUBPIXEL_ORDER_DEFAULT); CONSTANT(SUBPIXEL_ORDER_RGB); CONSTANT(SUBPIXEL_ORDER_BGR); --- py3cairo-1.10.0+dfsg.orig/src/wscript +++ py3cairo-1.10.0+dfsg/src/wscript @@ -25,6 +25,7 @@ def build(ctx): 'font.c', 'path.c', 'pattern.c', + 'region.c', 'matrix.c', 'surface.c', ], --- py3cairo-1.10.0+dfsg.orig/src/private.h +++ py3cairo-1.10.0+dfsg/src/private.h @@ -60,6 +60,13 @@ extern PyTypeObject PycairoLinearGradien extern PyTypeObject PycairoRadialGradient_Type; PyObject *PycairoPattern_FromPattern (cairo_pattern_t *pattern, PyObject *base); + +extern PyTypeObject PycairoRectangleInt_Type; +PyObject *PycairoRectangleInt_FromRectangleInt ( + cairo_rectangle_int_t *rectangle_int); + +extern PyTypeObject PycairoRegion_Type; +PyObject *PycairoRegion_FromRegion (cairo_region_t *region); extern PyTypeObject PycairoScaledFont_Type; PyObject *PycairoScaledFont_FromScaledFont (cairo_scaled_font_t *scaled_font); @@ -153,6 +160,15 @@ int Pycairo_Check_Status (cairo_status_t if (status != CAIRO_STATUS_SUCCESS) { \ Pycairo_Check_Status (status); \ return NULL; \ + } \ + } while (0) + +#define RETURN_NULL_IF_CAIRO_REGION_ERROR(region) \ + do { \ + cairo_status_t status = cairo_region_status (region); \ + if (status != CAIRO_STATUS_SUCCESS) { \ + Pycairo_Check_Status (status); \ + return NULL; \ } \ } while (0) --- py3cairo-1.10.0+dfsg.orig/test/api_test.py +++ py3cairo-1.10.0+dfsg/test/api_test.py @@ -84,3 +84,65 @@ def test_surface(): def test_text(): pass + + +def test_region(): + a = cairo.Region() + assert a.is_empty() == True + assert a.num_rectangles() == 0 + + b = cairo.RectangleInt(1, 2, 10, 12) + d = cairo.RectangleInt(1, 1, 10, 12) + e = cairo.RectangleInt(1, 3, 8, 12) + assert (b.x, b.y, b.width, b.height) == (1, 2, 10, 12) + c = cairo.Region((b, e)) + assert not c.is_empty() + assert c.num_rectangles() == 2 + assert c.get_rectangle(1).y == 14 + + ex = c.get_extents() + assert ex == cairo.RectangleInt(1, 2, 10, 13) + assert c.contains_rectangle(d) == cairo.REGION_OVERLAP_PART + + c.translate(10, 20) + assert c.contains_rectangle(d) == cairo.REGION_OVERLAP_OUT + assert c.get_rectangle(1) == cairo.RectangleInt(11, 34, 8, 1) + + cp = c.copy() + assert c.num_rectangles() == cp.num_rectangles() + assert c.get_rectangle(0) == cp.get_rectangle(0) + assert c == cp + assert 3 != c + assert c != "test" + + c = cairo.Region((b, e)) + c.intersect(d) + assert c.num_rectangles() == 1 + assert c.get_rectangle(0) == cairo.RectangleInt(1, 2, 10, 11) + + c = cairo.Region((b, e)) + c.subtract(d) + assert c.num_rectangles() == 2 + assert c == cairo.Region([ + cairo.RectangleInt(1, 13, 10, 1), cairo.RectangleInt(1, 14, 8, 1) ]) + + d = cairo.Region(d) + c = cairo.Region((b, e)) + c.subtract(d) + assert c.num_rectangles() == 2 + assert c.get_rectangle(0) == cairo.RectangleInt(1, 13, 10, 1) + + c = cairo.Region((b, e)) + c.union(d) + assert c.num_rectangles() == 2 + assert c == cairo.Region([ + cairo.RectangleInt(1, 1, 10, 13), cairo.RectangleInt(1, 14, 8, 1) ]) + + c = cairo.Region((b, e)) + c.xor(d) + assert c.num_rectangles() == 3 + assert c == cairo.Region([ + cairo.RectangleInt(1, 1, 10, 1), + cairo.RectangleInt(1, 14, 8, 1), + cairo.RectangleInt(1, 13, 10, 1), + ]) debian/README.source0000664000000000000000000000066211737330437011363 0ustar This is repacked source of the upstream package. - The upstream package contains "waf" binary. It doesn't satisfy Debian Policy. On this package, waf binary is replaced with uncompressed scripts. More details: http://wiki.debian.org/UnpackWaf - The upstream package contains html documents which are compiled with sphinx. It contains a binary "objects.inv", so this package rebuilds documents from source files. debian/compat0000664000000000000000000000000211777031352010374 0ustar 9