<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre, #msg p { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[18] trunk/src: Added documentation.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>18</dd>
<dt>Author</dt> <dd>dpruessner</dd>
<dt>Date</dt> <dd>2007-10-28 15:31:43 -0400 (Sun, 28 Oct 2007)</dd>
</dl>

<h3>Log Message</h3>
<pre>Added documentation.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcagg4rrb">trunk/src/agg4r.rb</a></li>
<li><a href="#trunksrccolorcc">trunk/src/color.cc</a></li>
<li><a href="#trunksrcrasterizercc">trunk/src/rasterizer.cc</a></li>
<li><a href="#trunksrcrendererbasecc">trunk/src/rendererbase.cc</a></li>
<li><a href="#trunksrcstrokecc">trunk/src/stroke.cc</a></li>
<li><a href="#trunksrctextcc">trunk/src/text.cc</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcagg4rrb"></a>
<div class="modfile"><h4>Modified: trunk/src/agg4r.rb (17 => 18)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/agg4r.rb        2007-10-28 17:51:36 UTC (rev 17)
+++ trunk/src/agg4r.rb        2007-10-28 19:31:43 UTC (rev 18)
</span><span class="lines">@@ -19,6 +19,11 @@
</span><span class="cx"> 
</span><span class="cx">   
</span><span class="cx">   class Rasterizer
</span><ins>+    # Does a little bit of linking work to private method add_path_int(Path).
+    # Different objects can provide path-like objects (ie, strokes, or 
+    # AGG conv_XXX objects).  This calls the get_path on the object to ensure
+    # that add_path_int parameter is *really* a Path object.
+    #
</ins><span class="cx">     def add_path(path)
</span><span class="cx">       add_path_int(path.get_path)       # Allows calls to be made on a path_like 
</span><span class="cx">                                         # that supports copying itself to a path
</span></span></pre></div>
<a id="trunksrccolorcc"></a>
<div class="modfile"><h4>Modified: trunk/src/color.cc (17 => 18)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/color.cc        2007-10-28 17:51:36 UTC (rev 17)
+++ trunk/src/color.cc        2007-10-28 19:31:43 UTC (rev 18)
</span><span class="lines">@@ -43,7 +43,11 @@
</span><span class="cx">   return rvalue;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-/* Initialize the structure */
</del><ins>+/* call-seq:
+ *   new(r, g, b, a) -&gt; Color
+ *
+ *   Allocates and initializes a new #Color object
+*/
</ins><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> Color_initialize(VALUE vSelf, VALUE r, VALUE g, VALUE b, VALUE a) 
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunksrcrasterizercc"></a>
<div class="modfile"><h4>Modified: trunk/src/rasterizer.cc (17 => 18)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/rasterizer.cc        2007-10-28 17:51:36 UTC (rev 17)
+++ trunk/src/rasterizer.cc        2007-10-28 19:31:43 UTC (rev 18)
</span><span class="lines">@@ -6,10 +6,27 @@
</span><span class="cx"> extern VALUE rb_cAgg4r_Path;
</span><span class="cx"> extern VALUE rb_cAgg4r_Rasterizer;
</span><span class="cx"> 
</span><del>-//////////////////////////////////////////////////
-// class Rasterizer
-//
</del><span class="cx"> 
</span><ins>+/* Rasterizer.cc
+ *
+ * Document-class: Agg4r::Rasterizer
+ *
+ * This object holds a reference to an AGG rasterizer.  It is
+ * a place-holder with little functionality.
+ *
+ * AGG uses the rasterizer to determine the manner in which the
+ * rasterization should take place (Anti-Aliased, Aliased,
+ * etc).  Since this is initially only for AA graphics, the AA 
+ * rasterizer is the only one provided.  This may change in the
+ * future.
+ *
+ * == Usage
+ *   rasterizer = Agg4r::Rasterizer.new();
+ *   rasterizer.add_path(path);
+ *   renderer_base.render(rasterizer, color);
+ *
+*/
+
</ins><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> Rasterizer_free(sRasterizer *rasterizer)
</span><span class="cx"> {
</span><span class="lines">@@ -33,6 +50,7 @@
</span><span class="cx">   return rvalue;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/* Allocate an AGG rasterizer object and initialize */
</ins><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> Rasterizer_initialize (VALUE vSelf)
</span><span class="cx"> {
</span><span class="lines">@@ -49,6 +67,13 @@
</span><span class="cx"> 
</span><span class="cx"> //TODO: Track which paths are stored in this rasterizer.  Does add_path store a ptr to the path thtat was added?
</span><span class="cx"> //       or is data copied on the spot w/o retaining a dependence?
</span><ins>+/* call-seq:
+ *   add_path_int(path)
+ *
+ * Does the C++ side of adding the path. Calls the AGG
+ * +rasterizser.add_path(...)+.
+ *
+*/
</ins><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> Rasterizer_add_path_int (VALUE vSelf, VALUE vPath)
</span><span class="cx"> {
</span><span class="lines">@@ -73,3 +98,8 @@
</span><span class="cx">   return;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// For the documentation engine:
+#if false
+  rb_mAgg4r = rb_define_module(&quot;Agg4r&quot;);
+#endif
+
</ins></span></pre></div>
<a id="trunksrcrendererbasecc"></a>
<div class="modfile"><h4>Modified: trunk/src/rendererbase.cc (17 => 18)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/rendererbase.cc        2007-10-28 17:51:36 UTC (rev 17)
+++ trunk/src/rendererbase.cc        2007-10-28 19:31:43 UTC (rev 18)
</span><span class="lines">@@ -6,8 +6,23 @@
</span><span class="cx"> extern VALUE rb_cAgg4r_Path;
</span><span class="cx"> extern VALUE rb_cAgg4r_Rasterizer;
</span><span class="cx"> 
</span><del>-//////////////////////////////////////////////////
-// Class RendererBase
</del><ins>+/* rendererbase.cc
+ *
+ * Document-class: Agg4r::RendererBase
+ *
+ * Holds a reference to the AGG renderer_base templated object.
+ * This is responsible for scanning in scanlines into the image.
+ *
+ * This object also allocates memory for the underlying pixel information.
+ *
+ * The flow looks like:
+ *   ScanlineSource =&gt; RendererBase =&gt; char[] buffer
+ * 
+ * == Usage
+ *   rb = Agg4r::RendererBase.new(size_x, size_y);
+ *   rb.render(rasterizer, color);
+*/
+
</ins><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> RendererBase_free (sRendererBase* rendererbase)
</span><span class="cx"> {
</span><span class="lines">@@ -31,6 +46,14 @@
</span><span class="cx">   return rvalue;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/* call-seq:
+ *   new(size_x, size_y) -&gt; RendererBase
+ *
+ * Allocates and initializes an AGG +renderer_base+ and creates a
+ * +char[size_x * size_y * 3]+ memory segment to hold the 24-bit
+ * RGB data.
+ *
+*/
</ins><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> RendererBase_initialize (VALUE vSelf, VALUE vsize_x, VALUE vsize_y)
</span><span class="cx"> {
</span><span class="lines">@@ -51,7 +74,13 @@
</span><span class="cx">   rendererbase-&gt;initialized=1;
</span><span class="cx">   return vSelf;
</span><span class="cx"> }
</span><del>-
</del><ins>+/* call-seq:
+ *    get_pixbuf() -&gt; Array
+ *
+ * Returns a +size_x * size_y+ array of pixels.  The RGB components
+ * are multiplied together:
+ *   + Pixel = 256^0 * R + 256^1 * G + 256^2 * B +
+*/
</ins><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> RendererBase_get_pixbuf(VALUE vSelf)
</span><span class="cx"> {
</span><span class="lines">@@ -67,7 +96,7 @@
</span><span class="cx">   unsigned int arr_idx = 0;
</span><span class="cx">   unsigned int end_of_line ;
</span><span class="cx"> 
</span><del>-  // Copy in spans; flipping y.
</del><ins>+  /* Copy in spans; flipping y. */
</ins><span class="cx">   for (int rowoffset=rendererbase-&gt;size_y - 1; rowoffset &gt;= 0; rowoffset--)
</span><span class="cx">   {
</span><span class="cx">     p = rendererbase-&gt;size_x * 3 * rowoffset;
</span><span class="lines">@@ -85,6 +114,13 @@
</span><span class="cx">   return arr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/* call-seq:
+ *   render(rasterizer, color) -&gt; nil
+ *
+ * Renders the information in the rasterizer into the buffer.
+ * This operation clears the #Rasterizer of all path information.
+ * All the data will be of color _color_.
+*/
</ins><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> RendererBase_render(VALUE vSelf, VALUE vRasterizer, VALUE vColor)
</span><span class="cx"> {
</span><span class="lines">@@ -108,6 +144,7 @@
</span><span class="cx">   return Qnil;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/* Returns the x-size of the buffer */
</ins><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> RendererBase_size_x (VALUE vSelf)
</span><span class="cx"> {
</span><span class="lines">@@ -116,6 +153,7 @@
</span><span class="cx">   return INT2FIX(rendererbase-&gt;size_x);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/* Returns the y-size of the buffer */
</ins><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> RendererBase_size_y (VALUE vSelf)
</span><span class="cx"> {
</span><span class="lines">@@ -124,6 +162,12 @@
</span><span class="cx">   return INT2FIX(rendererbase-&gt;size_y);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/* call-seq:
+ *   clear(value)
+ *
+ * Clears all pixel components with this value.  This means that
+ * the image can only be cleared to a gray value.
+*/
</ins><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> RendererBase_clear (VALUE vSelf, VALUE vVal)
</span><span class="cx"> {
</span><span class="lines">@@ -169,7 +213,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-
</del><ins>+// For the documentation engine:
</ins><span class="cx"> #if false
</span><span class="cx">   rb_mAgg4r = rb_define_module(&quot;Agg4r&quot;);
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunksrcstrokecc"></a>
<div class="modfile"><h4>Modified: trunk/src/stroke.cc (17 => 18)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/stroke.cc        2007-10-28 17:51:36 UTC (rev 17)
+++ trunk/src/stroke.cc        2007-10-28 19:31:43 UTC (rev 18)
</span><span class="lines">@@ -20,9 +20,27 @@
</span><span class="cx"> const unsigned int JOIN_BEVEL = 3;
</span><span class="cx"> const unsigned int JOIN_MITER_ROUND = 4;
</span><span class="cx"> 
</span><ins>+/* Document-class: Agg4r::Stroke
+ *
+ * This object takes a path input and creates a stroke path around the input
+ * path. 
+ *
+ * == Usage
+ *   path = Agg4r::Path.new();
+ *   path.move_to(10,10);
+ *   path.line_to(30,30);
+ *   stroke = Agg4r::Stroke.new(path);
+ *   stroke.width = 3.2;                          # Pixels
+ *   stroke.endcap = Agg4r::Stroke::CAP_ROUND;
+ *   rasterizer.add_path(stroke.get_path);
+ *   renderer.render(rasterizer, color);
+ *
+ * Stroking can be done ad infinitum-- you can make a line, then outline the line, then outline
+ * the outline of the line........
+ *
+ * 
+*/
</ins><span class="cx"> 
</span><del>-//////////////////////////////////////////////////
-// Stroke Stuff
</del><span class="cx"> //
</span><span class="cx"> 
</span><span class="cx"> EXTERNAL VALUE
</span><span class="lines">@@ -46,6 +64,15 @@
</span><span class="cx">   return rvalue;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/* call-seq:
+ *   new(path) -&gt; Stroke
+ *
+ * Creates a new stroke and initializes its input to _path_.
+ *
+ * *Note:* This does not pull the data immediately.  If _path_ is updated
+ * after this stroke is created, all changes up until +stroke.#get_path+ are
+ * reflected.
+*/
</ins><span class="cx"> EXTERNAL VALUE 
</span><span class="cx"> Stroke_initialize (VALUE vSelf, VALUE vPath) // vPath = {Path, Stroke, etc}
</span><span class="cx"> {
</span><span class="lines">@@ -62,6 +89,11 @@
</span><span class="cx">   return vSelf;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/* call-seq:
+ *   width= width  -&gt; nil
+ *
+ * Sets the width of the stroke in pixels.
+*/
</ins><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> Stroke_widthEQ (VALUE vSelf, VALUE vWidth)
</span><span class="cx"> {
</span><span class="lines">@@ -72,6 +104,11 @@
</span><span class="cx">   return Qnil;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/* call-seq:
+ *   miter_limit = miter  -&gt; nil
+ *
+ * Sets the miter limit in pixels.
+*/
</ins><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> Stroke_miter_limitEQ (VALUE vSelf, VALUE vMiter)
</span><span class="cx"> {
</span><span class="lines">@@ -82,6 +119,7 @@
</span><span class="cx">   return Qnil;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/* Returns a path object representing the stroke */
</ins><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> Stroke_get_path (VALUE vSelf)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunksrctextcc"></a>
<div class="modfile"><h4>Modified: trunk/src/text.cc (17 => 18)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/text.cc        2007-10-28 17:51:36 UTC (rev 17)
+++ trunk/src/text.cc        2007-10-28 19:31:43 UTC (rev 18)
</span><span class="lines">@@ -11,9 +11,23 @@
</span><span class="cx"> extern VALUE rb_cAgg4r_Text;
</span><span class="cx"> extern VALUE Path_allocate_internal(path_storage_type*);
</span><span class="cx"> 
</span><del>-//////////////////////////////////////////////////
-// Text 
-//
</del><ins>+/* Document-class: Agg4r::Text
+ *
+ * Creates an AGG text object for rendering.
+ *
+ * == Usage
+ *   text = Agg4r::Text.new()
+ *   text.text = &quot;Hello World!&quot;
+ *   text.set_size(20, 0);
+ *   text.start_point(center + text.width.to_f / 2, y);  # use text.width to center.
+ *
+ *   text_stroke = Agg4r::Stroke.new(text.get_path);
+ *   text_stroke.width=1.3;
+ *
+ *   rasterizer.add_path(text_stroke.get_path);
+ *   renderer.render(rasterizer, text_color);
+ *
+*/
</ins><span class="cx"> 
</span><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> Text_free (sText *text)
</span><span class="lines">@@ -37,6 +51,7 @@
</span><span class="cx">   return rvalue;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/* Create and initialize the text */
</ins><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> Text_initialize (VALUE vSelf)
</span><span class="cx"> {
</span><span class="lines">@@ -49,6 +64,11 @@
</span><span class="cx">   return vSelf;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/* call-seq:
+ *   text = text   -&gt; self
+ *
+ * Sets the text.
+*/
</ins><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> Text_textEQ (VALUE vSelf, VALUE vText)
</span><span class="cx"> {
</span><span class="lines">@@ -60,6 +80,14 @@
</span><span class="cx">   return vSelf;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/* call-seq:
+ *   start_point(x, y)  -&gt; self
+ *
+ * Sets the start point of the text.  This is WRT
+ * the lower-left corner of the text box.
+ *
+ * See #text_width for placing arithmitic.
+*/
</ins><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> Text_start_point (VALUE vSelf, VALUE vX, VALUE vY)
</span><span class="cx"> {
</span><span class="lines">@@ -71,6 +99,7 @@
</span><span class="cx">   return vSelf;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/* Flip the rendering in the Y direction? */
</ins><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> Text_flipEQ (VALUE vSelf, VALUE vFlip)
</span><span class="cx"> {
</span><span class="lines">@@ -80,6 +109,13 @@
</span><span class="cx">   return vSelf;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+
+/* call-seq:
+ *   set_size(height, width)
+ *
+ * Sets the height and/or width of the text.  +width=0+ =&gt; default width.
+ *
+*/
</ins><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> Text_set_size(VALUE vSelf, VALUE vHeight, VALUE vWidth)
</span><span class="cx"> {
</span><span class="lines">@@ -88,6 +124,9 @@
</span><span class="cx">   text-&gt;text-&gt;size(NUM2DBL(vHeight), NUM2DBL(vWidth));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/* Returns the width of the text in pixels.
+ * Useful for placing or centering text.
+*/
</ins><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> Text_width (VALUE vSelf)
</span><span class="cx"> {
</span><span class="lines">@@ -95,7 +134,7 @@
</span><span class="cx">   Data_Get_Struct(vSelf, sText, text);
</span><span class="cx">   return (rb_float_new(text-&gt;text-&gt;text_width()));
</span><span class="cx"> }
</span><del>-
</del><ins>+/* Returns the path of the text for rendering */
</ins><span class="cx"> EXTERNAL VALUE
</span><span class="cx"> Text_get_path (VALUE vSelf)
</span><span class="cx"> {
</span><span class="lines">@@ -134,7 +173,7 @@
</span><span class="cx">   return;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-
</del><ins>+// For the documentation engine:
</ins><span class="cx"> #if false
</span><span class="cx">   rb_mAgg4r = rb_define_module(&quot;Agg4r&quot;);
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>

</body>
</html>