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

📄 z132.html

📁 GTK+_ Gnome Application Development
💻 HTML
📖 第 1 页 / 共 3 页
字号:
          or a portion of one. (<a href=          "z132.html#FL-GDKARC">Figure 20</a>). The arc can be          filled or unfilled; the third argument to the function          toggles fill. The fourth through seventh arguments          describe a rectangle; the ellipse is inscribed in this          rectangle. <span class="STRUCTNAME">angle1</span> is the          angle at which to start drawing; it is relative to the 3          o'clock position (that is, 0 radians). <span class=           "STRUCTNAME">angle2</span> is the distance to travel          around the arc; if positive, travel is counterclockwise,          otherwise travel is clockwise. Both <span class=           "STRUCTNAME">angle1</span> and <span class="STRUCTNAME">          angle2</span> are specified in sixty-fourths of a degree;          so, 360 degrees is given as <span class="STRUCTNAME">          360*64</span>. This allows more precise specification of          the arc's size and shape, without using floating point          numbers. <span class="STRUCTNAME">angle2</span> should          not exceed 360 degrees, since it is nonsensical to move          more than 360 degrees around the ellipse.        </p>        <p>          To draw a circle, draw from 0 to 360*64 inside a square:        </p>        <table border="0" bgcolor="#E0E0E0" width="100%">          <tr>            <td><pre class="PROGRAMLISTING">&#13;  gdk_draw_arc(drawable, gc, TRUE,               0, 0,                50, 50,               0, 360*64);&#13;</pre>            </td>          </tr>        </table>        <p>          To draw half an ellipse, change the aspect ratio and          halve the span of the arc:        </p>        <table border="0" bgcolor="#E0E0E0" width="100%">          <tr>            <td><pre class="PROGRAMLISTING">&#13;  gdk_draw_arc(drawable, gc, TRUE,               0, 0,                100, 50,                0, 180*64);&#13;</pre>            </td>          </tr>        </table>        <p>          Many X servers draw the edges of filled arcs in an          aesthetically unpleasing way; in particular, very small          circles may not look very circular. You can work around          this by also drawing the circle's outline.        </p>        <div class="FIGURE">          <a name="FL-GDKARC"></a>          <div class="FUNCSYNOPSIS">            <a name="FL-GDKARC.SYNOPSIS"></a>            <table border="0" bgcolor="#E0E0E0" width="100%">              <tr>                <td><pre class="FUNCSYNOPSISINFO">#include &lt;gdk/gdk.h&gt;</pre>                </td>              </tr>            </table>            <p>              <code><code class="FUNCDEF">void <tt class=              "FUNCTION">gdk_draw_arc</tt></code>(GdkDrawable* <tt              class="PARAMETER"><i>drawable</i></tt>, GdkGC* <tt              class="PARAMETER"><i>gc</i></tt>, gint <tt class=               "PARAMETER"><i>filled</i></tt>, gint <tt class=               "PARAMETER"><i>x</i></tt>, gint <tt class=              "PARAMETER"><i>y</i></tt>, gint <tt class=              "PARAMETER"><i>width</i></tt>, gint <tt class=               "PARAMETER"><i>height</i></tt>, gint <tt class=               "PARAMETER"><i>angle1</i></tt>, gint <tt class=               "PARAMETER"><i>angle2</i></tt>);</code>            </p>          </div>          <p>            <b>Figure 20. Drawing Arcs</b>          </p>        </div>      </div>      <div class="SECT2">        <h2 class="SECT2">          <a name="Z137">Polygons</a>        </h2>        <p>          <tt class="FUNCTION">gdk_draw_polygon()</tt> draws a          filled or unfilled polygon (<a href=          "z132.html#FL-GDKPOLY">Figure 21</a>). Notice that <tt          class="FUNCTION">gdk_draw_lines()</tt> can also be used          to draw an unfilled polygon (there is no reason to prefer          one or the other). The arguments to <tt class="FUNCTION">          gdk_draw_polygon()</tt> are the same as those to <tt          class="FUNCTION">gdk_draw_lines()</tt>. The polygon does          not have to be convex. It may also be self-intersecting.          Self-intersecting polygons are filled with an "Even-Odd          Rule," which means regions with an odd number of polygon          areas overlapping them are not filled. That is, if the          polygon does not overlap itself, it is entirely filled;          if a region is overlapped once, it is not filled; if it's          overlapped twice, it is filled; and so on.        </p>        <div class="FIGURE">          <a name="FL-GDKPOLY"></a>          <div class="FUNCSYNOPSIS">            <a name="FL-GDKPOLY.SYNOPSIS"></a>            <table border="0" bgcolor="#E0E0E0" width="100%">              <tr>                <td><pre class="FUNCSYNOPSISINFO">#include &lt;gdk/gdk.h&gt;</pre>                </td>              </tr>            </table>            <p>              <code><code class="FUNCDEF">void <tt class=              "FUNCTION">gdk_draw_polygon</tt></code>(GdkDrawable*              <tt class="PARAMETER"><i>drawable</i></tt>, GdkGC*              <tt class="PARAMETER"><i>gc</i></tt>, gint <tt class=               "PARAMETER"><i>filled</i></tt>, GdkPoint* <tt class=               "PARAMETER"><i>points</i></tt>, gint <tt class=               "PARAMETER"><i>npoints</i></tt>);</code>            </p>          </div>          <p>            <b>Figure 21. Drawing Polygons</b>          </p>        </div>      </div>      <div class="SECT2">        <h2 class="SECT2">          <a name="Z138">Text</a>        </h2>        <p>          There are two functions to draw strings; as an          optimization, <tt class="FUNCTION">gdk_draw_text()</tt>          takes the length of the string to draw as an argument.          <tt class="FUNCTION">gdk_draw_string()</tt> uses <tt          class="FUNCTION">strlen()</tt> to compute the string          length for you. Otherwise the two are identical. The          <span class="STRUCTNAME">x</span> and <span class=           "STRUCTNAME">y</span> coordinates specify the location of          the left side of the text's baseline. See <a href=           "sec-gdkfont.html">the section called <i>Fonts</i></a>          for more information on fonts and font metrics. Text is          drawn in the foreground color.        </p>        <p>          There is no way to draw scaled or rotated text with GDK.          <span class="STRUCTNAME">GnomeCanvasText</span> offers a          slow and low-quality way to render scaled and rotated          text (see <a href=           "sec-itemreference.html#SEC-GNOMECANVASTEXT">the section          called <i>Text Item</i> in the chapter called <i><tt          class="CLASSNAME">GnomeCanvas</tt></i></a>). If you need          high-quality scaling and rotating, you will need to use          additional libraries, such as <tt class="APPLICATION">          t1lib</tt> for Type 1 fonts or FreeType for True Type          fonts. Another possibility is the Display Postscript          extension to X (XDPS); the GNU Project is working on a          free implementation of XDPS. The Gnome project also has a          text solution in development, as part of the <tt class=           "APPLICATION">gnome-print</tt> library.        </p>        <div class="FIGURE">          <a name="FL-GDKTEXT"></a>          <div class="FUNCSYNOPSIS">            <a name="FL-GDKTEXT.SYNOPSIS"></a>            <table border="0" bgcolor="#E0E0E0" width="100%">              <tr>                <td><pre class="FUNCSYNOPSISINFO">#include &lt;gdk/gdk.h&gt;</pre>                </td>              </tr>            </table>            <p>              <code><code class="FUNCDEF">void <tt class=              "FUNCTION">gdk_draw_string</tt></code>(GdkDrawable*              <tt class="PARAMETER"><i>drawable</i></tt>, GdkFont*              <tt class="PARAMETER"><i>font</i></tt>, GdkGC* <tt              class="PARAMETER"><i>gc</i></tt>, gint <tt class=               "PARAMETER"><i>x</i></tt>, gint <tt class=              "PARAMETER"><i>y</i></tt>, const gchar* <tt class=               "PARAMETER"><i>text</i></tt>);</code>            </p>            <p>              <code><code class="FUNCDEF">void <tt class=              "FUNCTION">gdk_draw_text</tt></code>(GdkDrawable* <tt              class="PARAMETER"><i>drawable</i></tt>, GdkFont* <tt              class="PARAMETER"><i>font</i></tt>, GdkGC* <tt class=               "PARAMETER"><i>gc</i></tt>, gint <tt class=              "PARAMETER"><i>x</i></tt>, gint <tt class=              "PARAMETER"><i>y</i></tt>, const gchar* <tt class=               "PARAMETER"><i>text</i></tt>, gint <tt class=               "PARAMETER"><i>text_length</i></tt>);</code>            </p>          </div>          <p>            <b>Figure 22. Drawing Text</b>          </p>        </div>      </div>      <div class="SECT2">        <h2 class="SECT2">          <a name="Z139">Pixmaps</a>        </h2>        <p>          <tt class="FUNCTION">gdk_draw_pixmap()</tt> copies a          region from a pixmap to another drawable (pixmap or          window). The source and destination drawables must have          the same depth and visual. If you pass <span class=           "STRUCTNAME">-1</span> for the width or height, the full          size of the source pixmap is substituted. The source can          actually be any drawable, including a window, but <tt          class="FUNCTION">gdk_window_copy_area()</tt> will make          your code clearer if the source is a window. <a href=           "z132.html#FL-GDKDRAWPIXMAP">Figure 23</a> shows <tt          class="FUNCTION">gdk_draw_pixmap()</tt>.        </p>        <div class="FIGURE">          <a name="FL-GDKDRAWPIXMAP"></a>          <div class="FUNCSYNOPSIS">            <a name="FL-GDKDRAWPIXMAP.SYNOPSIS"></a>            <table border="0" bgcolor="#E0E0E0" width="100%">              <tr>                <td><pre class="FUNCSYNOPSISINFO">#include &lt;gdk/gdk.h&gt;</pre>                </td>              </tr>            </table>            <p>              <code><code class="FUNCDEF">void <tt class=              "FUNCTION">gdk_draw_pixmap</tt></code>(GdkDrawable*              <tt class="PARAMETER"><i>drawable</i></tt>, GdkGC*              <tt class="PARAMETER"><i>gc</i></tt>, GdkDrawable*              <tt class="PARAMETER"><i>src</i></tt>, gint <tt              class="PARAMETER"><i>xsrc</i></tt>, gint <tt class=               "PARAMETER"><i>ysrc</i></tt>, gint <tt class=               "PARAMETER"><i>xdest</i></tt>, gint <tt class=               "PARAMETER"><i>ydest</i></tt>, gint <tt class=               "PARAMETER"><i>width</i></tt>, gint <tt class=               "PARAMETER"><i>height</i></tt>);</code>            </p>          </div>          <p>            <b>Figure 23. Drawing Pixmaps</b>

⌨️ 快捷键说明

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