Mercurial > repos > rliterman > csp2
comparison CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/share/gtk-doc/html/cairo/bindings-path.html @ 68:5028fdace37b
planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author | jpayne |
---|---|
date | Tue, 18 Mar 2025 16:23:26 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
67:0e9998148a16 | 68:5028fdace37b |
---|---|
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | |
2 <html> | |
3 <head> | |
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
5 <title>cairo_path_t: Cairo: A Vector Graphics Library</title> | |
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> | |
7 <link rel="home" href="index.html" title="Cairo: A Vector Graphics Library"> | |
8 <link rel="up" href="language-bindings.html" title="Appendix A. Creating a language binding for cairo"> | |
9 <link rel="prev" href="bindings-fonts.html" title="Fonts"> | |
10 <meta name="generator" content="GTK-Doc V1.27 (XML mode)"> | |
11 <link rel="stylesheet" href="style.css" type="text/css"> | |
12 </head> | |
13 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> | |
14 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle"> | |
15 <td width="100%" align="left" class="shortcuts"></td> | |
16 <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td> | |
17 <td><a accesskey="u" href="language-bindings.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td> | |
18 <td><a accesskey="p" href="bindings-fonts.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td> | |
19 <td><img src="right-insensitive.png" width="16" height="16" border="0"></td> | |
20 </tr></table> | |
21 <div class="sect1"> | |
22 <div class="titlepage"><div><div><h2 class="title" style="clear: both"> | |
23 <a name="bindings-path"></a>cairo_path_t</h2></div></div></div> | |
24 <p> | |
25 The <a class="link" href="cairo-Paths.html#cairo-path-t" title="cairo_path_t"><span class="type">cairo_path_t</span></a> type is one | |
26 area in which most language bindings will differ significantly | |
27 from the C API. The C API for <span class="type">cairo_path_t</span> is | |
28 designed for efficiency and to avoid auxiliary objects that | |
29 would be have to be manually memory managed by the | |
30 application. However, | |
31 a language binding should not present <span class="type">cairo_path_t</span> as an | |
32 array, but rather as an opaque that can be iterated | |
33 over. Different languages have quite different conventions for | |
34 how iterators work, so it is impossible to give an exact | |
35 specification for how this API should work, but the type names | |
36 and methods should be similar to the language's mapping of the following: | |
37 </p> | |
38 <pre class="programlisting"> | |
39 typedef struct cairo_path_iterator cairo_path_iterator_t; | |
40 typedef struct cairo_path_element cairo_path_element_t; | |
41 | |
42 cairo_path_iterator_t * | |
43 cairo_path_get_iterator (cairo_path_t *path); | |
44 | |
45 cairo_bool_t | |
46 cairo_path_iterator_has_next (cairo_path_iterator_t *iterator); | |
47 | |
48 cairo_path_element_t * | |
49 cairo_path_iterator_next (cairo_path_iterator_t *iterator); | |
50 | |
51 cairo_path_element_type_t | |
52 cairo_path_element_get_type (cairo_path_element_t *element); | |
53 | |
54 void | |
55 cairo_path_element_get_point (cairo_path_element_t *element, | |
56 int index, | |
57 double *x, | |
58 double *y); | |
59 </pre> | |
60 <p> | |
61 The above is written using the Java conventions for | |
62 iterators. To illustrate how the API for PathIterator might | |
63 depend on the native iteration conventions of the API, examine | |
64 three versions of the loop, first written in a hypothetical Java | |
65 binding: | |
66 </p> | |
67 <pre class="programlisting"> | |
68 PathIterator iter = cr.copyPath().iterator(); | |
69 while (cr.hasNext()) { | |
70 PathElement element = iter.next(); | |
71 if (element.getType() == PathElementType.MOVE_TO) { | |
72 Point p = element.getPoint(0); | |
73 doMoveTo (p.x, p.y); | |
74 } | |
75 }</pre> | |
76 <p> | |
77 And then in a hypothetical C++ binding: | |
78 </p> | |
79 <pre class="programlisting"> | |
80 Path path = cr.copyPath(); | |
81 for (PathIterator iter = path.begin(); iter != path.end(); iter++) { | |
82 PathElement element = *iter; | |
83 if (element.getType() == PathElementType.MOVE_TO) { | |
84 Point p = element.getPoint(0); | |
85 doMoveTo (p.x, p.y); | |
86 } | |
87 }</pre> | |
88 <p> | |
89 And then finally in a Python binding: | |
90 </p> | |
91 <pre class="programlisting"> | |
92 for element in cr.copy_path(): | |
93 if element.getType == cairo.PATH_ELEMENT_MOVE_TO: | |
94 (x, y) = element.getPoint(0) | |
95 doMoveTo (x, y);</pre> | |
96 <p> | |
97 While many of the API elements stay the same in the three | |
98 examples, the exact iteration mechanism is quite different, to | |
99 match how users of the language would expect to iterate over | |
100 a container. | |
101 </p> | |
102 <p> | |
103 You should not present an API for mutating or for creating new | |
104 <span class="type">cairo_path_t</span> objects. In the future, these | |
105 guidelines may be extended to present an API for creating a | |
106 <span class="type">cairo_path_t</span> from scratch for use with | |
107 <a class="link" href="cairo-Paths.html#cairo-append-path" title="cairo_append_path ()"><code class="function">cairo_append_path()</code></a> | |
108 but the current expectation is that <code class="function">cairo_append_path()</code> will | |
109 mostly be used with paths from | |
110 <a class="link" href="cairo-Paths.html#cairo-append-path" title="cairo_append_path ()"><code class="function">cairo_copy_path()</code></a>. | |
111 </p> | |
112 </div> | |
113 <div class="footer"> | |
114 <hr>Generated by GTK-Doc V1.27</div> | |
115 </body> | |
116 </html> |