<?php header("Content-Type: text/html; charset=utf-8"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <meta name="GENERATOR" content="vim" />
   <meta name="Author" content="sam@zoy.org (Sam Hocevar)" />
   <meta name="Description" content="Libcaca study - Source code" />
   <meta name="Keywords" content="libcaca, ASCII, ASCII ART, console, text mode, ncurses, slang, AAlib, dithering, thresholding" />
   <title>Libcaca study - Source code</title>
   <link rel="icon" type="image/x-icon" href="/favicon.ico" />
   <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
   <link rel="stylesheet" type="text/css" href="/main.css" />
   <style type="text/css">
     .comment { color: #38d; }
     .string { color: #c33; }
     .const { color: #33a; }
     .keyword { color: #3a3; }
     .number { color: #c3c; }
   </style>
</head>

<body>

<?php include($_SERVER["DOCUMENT_ROOT"]."/header.inc"); ?>

<p> <span style="color: #aa0000; font-weight: bold;">Warning</span>: this
document is still work in progress. Feel free to send comments but do not
consider it final material. </p>

<div style="float: left;">
   <a href="biblio.html">Bibliography &lt;&lt;&lt;</a>
</div>
<!--<div style="float: right;">
   <a href=""></a>
</div>-->
<div style="text-align: center;">
   <a href="index.html">^^^ Index</a>
</div>

<h2> Source code </h2>

<p> This is the full Python source code to all examples presented in this
document. It can also be downloaded as a standalone <tt><a
href="study.py">study.py</a></tt> Python program. </p>

<p> Just install the <tt>python-gd</tt> package on your favourite operating
system and run the script. With the exception of the <a
href="http://www.cs.cmu.edu/~chuck/lennapg/">original colour 512×512 Lena
image</a>, all Lena images and gradients were generated from this program. If
you have installed Inkscape, many graphics such as dither matrices will also
be automatically generated. </p>

<p> Many algorithms implemented here will seem rather inefficient to people
used to writing image processing software. This is because clarity was almost
always preferred over performance. We believe this document to be of important
value to many researchers in the field, because it implements methods for which
there is no public implementation. </p>

<pre style="background-color: white; border: solid black 1px;
          padding: 10px; text-indent: 0em;"><?php
  $s = file($_SERVER["DOCUMENT_ROOT"]."/study/study.py");
  foreach ($s as $i => $l) {
    if(ereg('temporary cruft', $l))
      break;
    $l = htmlspecialchars($l);
    $c = 0;
    $l = preg_replace('/#[^0-9a-f].*/', '<span class="comment">\\0</span>',
                      $l, -1, $c);
    if($c <= 0) {
      $l = preg_replace('/(&quot;.*&quot;|\\\\$)/',
                        '<span class="string">\\0</span>', $l);
      $l = ereg_replace('[A-Z][A-Z][A-Z0-9_]*',
                        '<span class="const">\\0</span>', $l);
      $l = preg_replace('/\b(for|def|in|return|while|if|elif|else|class |True|False|None|break|continue|and|or|not|print|global|import|try|catch|yield)\b/',
                        '<span class="keyword">\\0</span>', $l);
      $l = preg_replace('/\b([0-9]+[.][0-9]*|[0-9]*[.][0-9]+|[0-9]+)\b/',
                        '<span class="number">\\0</span>', $l);
    }
    echo $l;
  }
?></pre>

<div style="float: left;">
   <a href="biblio.html">Bibliography &lt;&lt;&lt;</a>
</div>
<!--<div style="float: right;">
   <a href=""></a>
</div>-->
<div style="text-align: center;">
   <a href="index.html">^^^ Index</a>
</div>

<?php $rev = '$Id$';
      include($_SERVER['DOCUMENT_ROOT'].'/footer.inc'); ?>

</body>
</html>
