home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / gimp / 2.0 / help / en / gimp-using-script-fu-tutorial-result.html < prev    next >
Encoding:
Extensible Markup Language  |  2008-05-03  |  8.3 KB  |  194 lines

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4.   <head>
  5.     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  6.     <title>3.7.¬† Your script and its working</title>
  7.     <link rel="stylesheet" href="gimp-help-plain.css" type="text/css" />
  8.     <link rel="stylesheet" href="gimp-help-screen.css" type="text/css" />
  9.     <link rel="stylesheet" href="gimp-help-custom.css" type="text/css" />
  10.     <link rel="alternate stylesheet" href="gimp22.css" type="text/css" title="gimp22" />
  11.     <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
  12.     <link rel="start" href="index.html" title="GNU Image Manipulation Program" />
  13.     <link rel="up" href="gimp-using-script-fu-tutorial.html" title="3.¬† A Script-Fu Tutorial" />
  14.     <link rel="prev" href="gimp-using-script-fu-tutorial-extending-text-box.html" title="3.6.¬† Extending The Text Box Script" />
  15.     <link rel="next" href="pt03.html" title="Part¬†III.¬† Function Reference" />
  16.   </head>
  17.   <body>
  18.     <div class="navheader">
  19.       <table width="100%" summary="Navigation header">
  20.         <tr>
  21.           <th colspan="3" align="center">3.7.¬†
  22.       <span lang="en" xml:lang="en">Your script and its working</span>
  23.     </th>
  24.         </tr>
  25.         <tr>
  26.           <td width="20%" align="left"><a accesskey="p" href="gimp-using-script-fu-tutorial-extending-text-box.html"><img src="../images/prev.png" alt="Prev" /></a>¬†</td>
  27.           <th width="60%" align="center">3.¬†
  28.     <span lang="en" xml:lang="en">A Script-Fu Tutorial</span>
  29.   </th>
  30.           <td width="20%" align="right">¬†<a accesskey="n" href="pt03.html"><img src="../images/next.png" alt="Next" /></a></td>
  31.         </tr>
  32.       </table>
  33.       <hr />
  34.     </div>
  35.     <div class="sect2" lang="en" xml:lang="en">
  36.       <div class="titlepage">
  37.         <div>
  38.           <div>
  39.             <h3 class="title"><a id="gimp-using-script-fu-tutorial-result"></a>3.7.¬†
  40.       <span lang="en" xml:lang="en">Your script and its working</span>
  41.     </h3>
  42.           </div>
  43.         </div>
  44.       </div>
  45.       <div class="sect3" lang="en" xml:lang="en">
  46.         <div class="titlepage">
  47.           <div>
  48.             <div>
  49.               <h4 class="title"><a id="id2620230"></a>3.7.1.¬†
  50.         <span lang="en" xml:lang="en">What you write</span>
  51.       </h4>
  52.             </div>
  53.           </div>
  54.         </div>
  55.         <p>Below the complete script:</p>
  56.         <pre class="programlisting">
  57.         (script-fu-register
  58.                   "script-fu-text-box"                        ;func name
  59.                   "Text Box"                                  ;menu label
  60.                   "Creates a simple text box, sized to fit\
  61.                     around the user's choice of text,\
  62.                     font, font size, and color."              ;description
  63.                   "Michael Terry"                             ;author
  64.                   "copyright 1997, Michael Terry"             ;copyright notice
  65.                   "October 27, 1997"                          ;date created
  66.                   ""                     ;image type that the script works on
  67.                   SF-STRING      "Text:"         "Text Box"   ;a string variable
  68.                   SF-FONT        "Font:"         "Charter"    ;a font variable
  69.                   SF-ADJUSTMENT  "Font size"     '(50 1 1000 1 10 0 1)
  70.                                                               ;a spin-button
  71.                   SF-COLOR       "Color:"        '(0 0 0)     ;color variable
  72.                   SF-ADJUSTMENT  "Buffer amount" '(35 0 100 1 10 1 0)
  73.                                                               ;a slider
  74.         )
  75.         (script-fu-menu-register "script-fu-text-box" "<Toolbox>/Xtns/Script-Fu/Text")
  76.         (define (script-fu-text-box inText inFont inFontSize inTextColor inBufferAmount)
  77.           (let*
  78.             (
  79.               ; define our local variables
  80.               ; create a new image:
  81.               (theImageWidth  10)
  82.               (theImageHeight 10)
  83.               (theImage)
  84.               (theImage
  85.                         (car
  86.                             (gimp-image-new
  87.                               theImageWidth
  88.                               theImageHeight
  89.                               RGB
  90.                             )
  91.                         )
  92.               )
  93.               (theText)             ;a declaration for the text
  94.               (theBuffer)           ;create a new layer for the image
  95.               (theLayer
  96.                         (car
  97.                             (gimp-layer-new
  98.                               theImage
  99.                               theImageWidth
  100.                               theImageHeight
  101.                               RGB-IMAGE
  102.                               "layer 1"
  103.                               100
  104.                               NORMAL
  105.                             )
  106.                         )
  107.               )
  108.             ) ;end of our local variables
  109.             (gimp-image-add-layer theImage theLayer 0)
  110.             (gimp-context-set-background '(255 255 255) )
  111.             (gimp-context-set-foreground inTextColor)
  112.             (gimp-drawable-fill theLayer BACKGROUND-FILL)
  113.             (set! theText
  114.                           (car
  115.                                 (gimp-text-fontname
  116.                                 theImage theLayer
  117.                                 0 0
  118.                                 inText
  119.                                 0
  120.                                 TRUE
  121.                                 inFontSize PIXELS
  122.                                 "Sans")
  123.                             )
  124.               )
  125.             (set! theImageWidth   (car (gimp-drawable-width  theText) ) )
  126.             (set! theImageHeight  (car (gimp-drawable-height theText) ) )
  127.             (set! theBuffer (* theImageHeight (/ inBufferAmount 100) ) )
  128.             (set! theImageHeight (+ theImageHeight theBuffer theBuffer) )
  129.             (set! theImageWidth  (+ theImageWidth  theBuffer theBuffer) )
  130.             (gimp-image-resize theImage theImageWidth theImageHeight 0 0)
  131.             (gimp-layer-resize theLayer theImageWidth theImageHeight 0 0)
  132.             (gimp-layer-set-offsets theText theBuffer theBuffer)
  133.             (gimp-display-new theImage)
  134.             (list theImage theLayer theText)
  135.           )
  136.         )
  137.       </pre>
  138.       </div>
  139.       <div class="sect3" lang="en" xml:lang="en">
  140.         <div class="titlepage">
  141.           <div>
  142.             <div>
  143.               <h4 class="title"><a id="id2620410"></a>3.7.2.¬†What you obtain</h4>
  144.             </div>
  145.           </div>
  146.         </div>
  147.         <div class="figure">
  148.           <a id="id2620417"></a>
  149.           <p class="title">
  150.             <b>Figure¬†12.5.¬†
  151.           <span lang="en" xml:lang="en">And the result on the screen.</span>
  152.         </b>
  153.           </p>
  154.           <div class="figure-contents">
  155.             <div class="mediaobject">
  156.               <img src="../images/using/script-fu-screen.png" alt="And the result on the screen." />
  157.             </div>
  158.           </div>
  159.         </div>
  160.         <br class="figure-break" />
  161.       </div>
  162.     </div>
  163.     <div class="navfooter">
  164.       <hr />
  165.       <table width="100%" summary="Navigation footer">
  166.         <tr>
  167.           <td width="40%" align="left"><a accesskey="p" href="gimp-using-script-fu-tutorial-extending-text-box.html"><img src="../images/prev.png" alt="Prev" /></a>¬†</td>
  168.           <td width="20%" align="center">
  169.             <a accesskey="u" href="gimp-using-script-fu-tutorial.html">
  170.               <img src="../images/up.png" alt="Up" />
  171.             </a>
  172.           </td>
  173.           <td width="40%" align="right">¬†<a accesskey="n" href="pt03.html"><img src="../images/next.png" alt="Next" /></a></td>
  174.         </tr>
  175.         <tr>
  176.           <td width="40%" align="left" valign="top"><a accesskey="p" href="gimp-using-script-fu-tutorial-extending-text-box.html">3.6.¬†
  177.       <span lang="en" xml:lang="en">Extending The Text Box Script</span>
  178.     </a>¬†</td>
  179.           <td width="20%" align="center">
  180.             <a accesskey="h" href="index.html">
  181.               <img src="../images/home.png" alt="Home" />
  182.             </a>
  183.           </td>
  184.           <td width="40%" align="right" valign="top">¬†<a accesskey="n" href="pt03.html">Part¬†III.¬†
  185.       <span lang="en" xml:lang="en">
  186.         Function Reference
  187.       </span>
  188.     </a></td>
  189.         </tr>
  190.       </table>
  191.     </div>
  192.   </body>
  193. </html>
  194.