⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bindings-return-values.html

📁 按照官方的说法:Cairo is a vector graphics library with cross-device output support. 翻译过来
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"><title>Multiple return values</title><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="index.html" title="Cairo: A Vector Graphics Library"><link rel="up" href="language-bindings.html" title="Appendix&#160;A.&#160;Creating a language binding for cairo"><link rel="prev" href="bindings-memory.html" title="Memory Management"><link rel="next" href="bindings-overloading.html" title="Overloading and optional arguments"><meta name="generator" content="GTK-Doc V1.6 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"><link rel="part" href="pt01.html" title="Part&#160;I.&#160;Tutorial"><link rel="part" href="pt02.html" title="Part&#160;II.&#160;Reference"><link rel="chapter" href="Drawing.html" title="Drawing"><link rel="chapter" href="Fonts.html" title="Fonts"><link rel="chapter" href="Surfaces.html" title="Surfaces"><link rel="chapter" href="Support.html" title="Utilities"><link rel="index" href="ix01.html" title="Index"><link rel="appendix" href="language-bindings.html" title="Appendix&#160;A.&#160;Creating a language binding for cairo"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="bindings-memory.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="language-bindings.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">Cairo: A Vector Graphics Library</th><td><a accesskey="n" href="bindings-overloading.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr></table><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="bindings-return-values"></a>Multiple return values</h2></div></div></div><p>      There are a number of functions in the cairo API that have      multiple <em class="firstterm">out parameters</em> or      <em class="firstterm">in-out parameters</em>. In some languages      these can be translated into multiple return values. In Python,      what is:    </p><pre class="programlisting">cairo_user_to_device (cr, &amp;x, &amp;y);</pre><p>      can by mapped to:    </p><pre class="programlisting">(x, y) = cr.user_to_device (cr, x, y);</pre><p>      but many languages don't have provisions for multiple return      values, so it is necessary to introduce auxiliary types.      Most of the functions that require the auxiliary types      require a type that would, in C, look like    </p><pre class="programlisting">typedef struct _cairo_point cairo_point_t;struct _cairo_point {    double x;    double y;}</pre><p>      The same type should be used both for functions that use a pair      of coordinates as an absolute position, and functions that use      a pair of coordinates as a displacement. While an argument could      be made that having a separate &#8220;distance&#8221; type is more correct,      it is more likely just to confuse users.    </p><pre class="programlisting">voidcairo_user_to_device (cairo_t *cr, double *x, double *y);voidcairo_user_to_device_distance (cairo_t *cr, double *dx, double *dy);voidcairo_device_to_user (cairo_t *cr, double *x, double *y);voidcairo_device_to_user_distance (cairo_t *cr, double *dx, double *dy);voidcairo_matrix_transform_distance (cairo_matrix_t *matrix, double *dx, double *dy);voidcairo_matrix_transform_point (cairo_matrix_t *matrix, double *x, double *y);voidcairo_get_current_point (cairo_t *cr, double *x, double *y);    </pre><p>      There are also a couple of functions that return four values      representing a rectangle. These should be mapped to a      &#8220;rectangle&#8221; type that looks like:    </p><pre class="programlisting">typedef struct _cairo_rectangle cairo_rectangle_t;struct _cairo_rectangle {    double x;    double y;    double width;    double height;}</pre><p>      The C function returns the rectangle as a set of two points to      facilitate rounding to integral extents, but this isn't worth      adding a &#8220;box&#8221; type to go along with the more obvious      &#8220;rectangle&#8221; representation.    </p><p class="remark"><i><span class="remark">      Q: Would it make sense here to define a standard      <code class="function">cairo_rectangle_round()</code> method      that language bindings should map?    </span></i></p><pre class="programlisting">voidcairo_stroke_extents (cairo_t *cr,		      double *x1, double *y1,		      double *x2, double *y2);voidcairo_fill_extents (cairo_t *cr,		    double *x1, double *y1,		    double *x2, double *y2);    </pre></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -