[cairo-commit] cairo-demo/cairo_snippets arc_negative.cairo, NONE, 1.1 curve_to.cairo, NONE, 1.1 footer.html_template, NONE, 1.1 header.html_template, NONE, 1.1 .cvsignore, 1.3, 1.4 ChangeLog, 1.12, 1.13 Makefile, 1.7, 1.8 arc.cairo, 1.1, 1.2 cairo_snippets_html.c, 1.1, 1.2 caps.cairo, 1.1, 1.2 joins.cairo, 1.1, 1.2 text.cairo, 1.1, 1.2 text_centering.cairo, 1.1, 1.2 bezier_spline.cairo, 1.1, NONE caps_and_joins.cairo, 1.1, NONE footer.html, 1.1, NONE header.html, 1.2, NONE

OEyvind Kolaas commit at pdx.freedesktop.org
Thu May 20 07:33:26 PDT 2004


Committed by: pippin

Update of /cvs/cairo/cairo-demo/cairo_snippets
In directory pdx:/tmp/cvs-serv17326

Modified Files:
	.cvsignore ChangeLog Makefile arc.cairo cairo_snippets_html.c 
	caps.cairo joins.cairo text.cairo text_centering.cairo 
Added Files:
	arc_negative.cairo curve_to.cairo footer.html_template 
	header.html_template 
Removed Files:
	bezier_spline.cairo caps_and_joins.cairo footer.html 
	header.html 
Log Message:
various helping lines  single html file for each snippet, preliminary browsing support


--- NEW FILE: arc_negative.cairo ---
double xc = 0.5;
double yc = 0.5;
double radius = 0.4;
double angle1 = 45.0  * (M_PI/180.0);  /* angles are specified */
double angle2 = 180.0 * (M_PI/180.0);  /* in radians           */

cairo_arc_negative (cr, xc, yc, radius, angle1, angle2);
cairo_stroke (cr);

/* draw helping lines */
cairo_set_rgb_color (cr, 1,0.2,0.2);
cairo_set_alpha (cr, 0.6);
cairo_arc (cr, xc, yc, 0.05, 0, 2*M_PI);
cairo_fill (cr);
cairo_set_line_width (cr, 0.03);
cairo_arc (cr, xc, yc, radius, angle1, angle1);
cairo_line_to (cr, xc, yc);
cairo_arc (cr, xc, yc, radius, angle2, angle2);
cairo_line_to (cr, xc, yc);
cairo_stroke (cr);

--- NEW FILE: curve_to.cairo ---
double x=0.1,  y=0.5;
double x1=0.4, y1=0.9,
       x2=0.6, y2=0.1,
       x3=0.9, y3=0.5;

cairo_move_to (cr,  x, y);
cairo_curve_to (cr, x1, y1, x2, y2, x3, y3);

cairo_stroke (cr);

cairo_set_rgb_color (cr, 1,0.2,0.2);
cairo_set_alpha (cr, 0.6);
cairo_set_line_width (cr, 0.03);
cairo_move_to (cr,x,y);   cairo_line_to (cr,x1,y1);
cairo_move_to (cr,x2,y2); cairo_line_to (cr,x3,y3);
cairo_stroke (cr);

--- NEW FILE: footer.html_template ---
    </div><p />
    <a name='PageBottom'></a>
    <center>
            <a href='http://cairographics.org/cairo/glider-blue.svg'
                    ><img border='0' src='http://cairographics.org/cairo/glider-blue.png'>
            </a>
    </center>
</html>

--- NEW FILE: header.html_template ---
<html>
        <head><title>cairo: snippets</title>
                <style type='text/css'>
     @import url(http://cairographics.org/styles.css);
  </style>
  <body>
    <a name='PageTop'></a>
    <div id='main'>
      <div id='logo'><a href='http://cairographics.org/'><img border='0' src='http://cairographics.org/cairo/cairo_banner.png' alt='cairographics.org'/></a></div>

      <h1>cairo samples</h1>
    
      <p>This page contains cairo code snippets and the corresponding rendered output.
         The <em>user space</em> is the unit square ( (0,0) - (1, 1) ).
         The snippets are meant to be short, and easy to understand
      </p>
      
      <p>cairo_snippets is available as part of the <a
              href='http://cvs.cairographics.org/cairo-demo/cairo_snippets/'
              >cairo-demo module in cairo CVS</a>
      </p>
      
      <p>The snippet enviroment, and the original snippets were originally 
      created by &Oslash;yvind Kol&aring;s for a paper submitted to <a href='http://2004.guadec.org/'>GUADEC 2004</a>.
      </p>

Index: .cvsignore
===================================================================
RCS file: /cvs/cairo/cairo-demo/cairo_snippets/.cvsignore,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** a/.cvsignore	19 May 2004 18:11:24 -0000	1.3
--- b/.cvsignore	20 May 2004 14:33:23 -0000	1.4
***************
*** 1,4 ****
--- 1,5 ----
  *.eps
  *.png
+ *.html
  snippets.ps
  snippets.pdf
***************
*** 8,11 ****
  cairo_snippets_ps
  prepare_snippets
- snippets.html
  snippets.c
--- 9,11 ----

Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/cairo-demo/cairo_snippets/ChangeLog,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** a/ChangeLog	19 May 2004 18:11:24 -0000	1.12
--- b/ChangeLog	20 May 2004 14:33:23 -0000	1.13
***************
*** 1,2 ****
--- 1,10 ----
+ 2004-05-20  OEyvind Kolaas <pippin at freedesktop.org>
+ 
+ 	* cairo_snippets_html.c : added seperate pages for each snippet
+ 	* renamed header.html->header.html_template
+ 	* renamed footer.html->footer.html_template
+ 	* .cvsignore: added *.html
+ 	* Makefile: added *.html to clean
+ 
  2004-05-19  OEyvind Kolaas <pippin at freedesktop.org>
  	
***************
*** 12,19 ****
--- 20,29 ----
  
  2004-05-18 OEyvind Kolaas <pippin at freedesktop.org>
+ 
  	* curve_rectangle.cairo: added a custom shape snippet, which also
  	tests storking with alpha
  
  2004-05-18 OEyvind Kolaas <pippin at freedesktop.org>
+ 
  	* Makefile: general cleanup, added target html
  	* cairo_snippets_png.c: removed html stuff
***************
*** 24,27 ****
--- 34,38 ----
  
  2004-05-18 OEyvind Kolaas <pippin at freedesktop.org>
+ 
  	* xxx_clipping.cairo xxx_image_clipping.cairo: removed
  	* clipping.cairo image_clipping.cairo: added
***************
*** 30,42 ****
--- 41,57 ----
  
  2004-05-18 OEyvind Kolaas <pippin at freedesktop.org>
+ 
  	* cairo_snippets_ps.c: added postscript with basis in the pdf version
  
  2004-05-18 OEyvind Kolaas <pippin at freedesktop.org>
+ 
  	* cairo_snippets_gtk.c: removed STRIDE define
  
  2004-05-18 OEyvind Kolaas <pippin at freedesktop.org>
+ 
  	* cairo_snippets_pdf.c: code cleanup
  
  2004-05-18 OEyvind Kolaas <pippin at freedesktop.org> 
+ 
  	* cairo_snippets_png.c: code cleanup, change to use the actual png backend
  	instead of using the png writing function in png_io.
***************
*** 44,47 ****
--- 59,63 ----
  
  2004-05-18 OEyvind Kolaas <pippin at freedesktop.org> 
+ 
  	* cairo_snippets_pdf.c, Makefile: added pdf backend, initially commented
  	  out in Makefile
***************
*** 50,51 ****
--- 66,69 ----
  
  	Initial import
+ 
+ /* vim: set ts=4 noet : */

Index: Makefile
===================================================================
RCS file: /cvs/cairo/cairo-demo/cairo_snippets/Makefile,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** a/Makefile	19 May 2004 09:39:00 -0000	1.7
--- b/Makefile	20 May 2004 14:33:23 -0000	1.8
***************
*** 21,25 ****
  	rm -f $(COMPILE_PROGS) \
  	      prepare_snippets \
! 		  snippets.html    \
  		  snippets.ps      \
  		  snippets.pdf     \
--- 21,25 ----
  	rm -f $(COMPILE_PROGS) \
  	      prepare_snippets \
! 		  *.html           \
  		  snippets.ps      \
  		  snippets.pdf     \
***************
*** 57,62 ****
  
  scp: html
! 	scp *.png freedesktop.org:/home/www/cairo/samples/
! 	scp snippets.html freedesktop.org:/home/www/cairo/samples/index.html
  
  pngs: cairo_snippets_png
--- 57,61 ----
  
  scp: html
! 	scp *.png *.html freedesktop.org:/home/www/cairo/samples/
  
  pngs: cairo_snippets_png

Index: arc.cairo
===================================================================
RCS file: /cvs/cairo/cairo-demo/cairo_snippets/arc.cairo,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** a/arc.cairo	20 May 2004 13:17:20 -0000	1.1
--- b/arc.cairo	20 May 2004 14:33:23 -0000	1.2
***************
*** 5,12 ****
  double angle2 = 180.0 * (M_PI/180.0);  /* in radians           */
  
- cairo_arc (cr, xc, yc, 0.1, 0, 2*M_PI);
- cairo_fill (cr);
- 
  cairo_arc (cr, xc, yc, radius, angle1, angle2);
  
  cairo_stroke (cr);
--- 5,20 ----
  double angle2 = 180.0 * (M_PI/180.0);  /* in radians           */
  
  cairo_arc (cr, xc, yc, radius, angle1, angle2);
+ cairo_stroke (cr);
  
+ /* draw helping lines */
+ cairo_set_rgb_color (cr, 1,0.2,0.2);
+ cairo_set_alpha (cr, 0.6);
+ cairo_arc (cr, xc, yc, 0.05, 0, 2*M_PI);
+ cairo_fill (cr);
+ cairo_set_line_width (cr, 0.03);
+ cairo_arc (cr, xc, yc, radius, angle1, angle1);
+ cairo_line_to (cr, xc, yc);
+ cairo_arc (cr, xc, yc, radius, angle2, angle2);
+ cairo_line_to (cr, xc, yc);
  cairo_stroke (cr);

Index: cairo_snippets_html.c
===================================================================
RCS file: /cvs/cairo/cairo-demo/cairo_snippets/cairo_snippets_html.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** a/cairo_snippets_html.c	18 May 2004 21:54:57 -0000	1.1
--- b/cairo_snippets_html.c	20 May 2004 14:33:23 -0000	1.2
***************
*** 5,11 ****
  #include "snippets.h"
  
! /* write an snippets.html file, containing inline images, and source code */
! int
! write_html (void);
  
  static void
--- 5,16 ----
  #include "snippets.h"
  
! void
! write_index (void);
! 
! void
! write_all (void);
! 
! void
! write_html (int snippet_no);
  
  static void
***************
*** 16,30 ****
  main (int argc, char **argv)
  {
!         write_html ();
          return 0;
  }
  
! int
! write_html(void)
  {
      int i=0;
      FILE *file= fopen ("snippets.html", "w");
  
!     embed_file (file, "header.html");
      fprintf (file, "<ul>\n");
  
--- 21,61 ----
  main (int argc, char **argv)
  {
!         int i;
!         for (i=0;i<snippet_count;i++)
!                 write_html (i);
!         write_index ();
!         write_all ();
          return 0;
  }
  
! void
! write_index(void)
! {
!     int i=0;
!     FILE *file= fopen ("index.html", "w");
! 
!     embed_file (file, "header.html_template");
!     fprintf (file, "<ul>\n");
! 
!         fprintf (file, "<li><a href='snippets.html'>all</a></li>\n");
!     for (i=0;i<snippet_count;i++)
!         fprintf (file, "<li><a href='%s.html'>%s</a></li>\n",
!                         snippet_name[i], snippet_name[i]);
! 
!     fprintf (file, "</ul>\n");
! 
!     embed_file (file, "footer.html_template");
!     fclose (file);
! }
! 
! 
! 
! void
! write_all(void)
  {
      int i=0;
      FILE *file= fopen ("snippets.html", "w");
  
!     embed_file (file, "header.html_template");
      fprintf (file, "<ul>\n");
  
***************
*** 38,50 ****
      for (i=0;i<snippet_count;i++) {
              const char *name=snippet_name[i];
-             char imgname[40];
              FILE *srcfile;
              int  size;
              const char *c=&snippet_source[i][0];
-             sprintf (imgname, "%s.png", name);
  
              fprintf (file, "    <tr>\n");
              fprintf (file, "       <td colspan='2'>\n");
!             fprintf (file, "         <h2><a href='#%s'><b>%s</b></a><a name='%s'></a></h2>\n", name,name,name);
              fprintf (file, "       </td>\n");
              fprintf (file, "    <tr>\n");
--- 69,79 ----
      for (i=0;i<snippet_count;i++) {
              const char *name=snippet_name[i];
              FILE *srcfile;
              int  size;
              const char *c=&snippet_source[i][0];
  
              fprintf (file, "    <tr>\n");
              fprintf (file, "       <td colspan='2'>\n");
!             fprintf (file, "         <h3><a href='%s.html'><b>%s</b></a><a name='%s'></a></h3>\n", name,name,name);
              fprintf (file, "       </td>\n");
              fprintf (file, "    <tr>\n");
***************
*** 71,75 ****
              fprintf (file, "       </pre></td>\n");
              fprintf (file, "       <td>\n");
!             fprintf (file, "         <img src='%s'/>\n", imgname);
              fprintf (file, "       </td>\n");
              fprintf (file, "    </tr>\n");
--- 100,104 ----
              fprintf (file, "       </pre></td>\n");
              fprintf (file, "       <td>\n");
!             fprintf (file, "         <img src='%s.png'/>\n", name);
              fprintf (file, "       </td>\n");
              fprintf (file, "    </tr>\n");
***************
*** 77,81 ****
      }
      fprintf (file, "</table>");
!     embed_file (file, "footer.html");
      fclose (file);
  }
--- 106,179 ----
      }
      fprintf (file, "</table>");
!     embed_file (file, "footer.html_template");
!     fclose (file);
! }
! 
! 
! void
! write_html(int snippet_no)
! {
!     FILE *file;
!     const char *name=snippet_name[snippet_no];
!     char htmlfile[1024];
! 
!     sprintf (htmlfile, "%s.html", name);
!     file = fopen (htmlfile, "w");
! 
!     embed_file (file, "header.html_template");
!     fprintf (file, "<p><a href='index.html'>index</a>");
! 
!     if (snippet_no>0)
!         fprintf (file, "&nbsp;<a href='%s.html'>prev(%s)</a>", snippet_name[snippet_no-1], snippet_name[snippet_no-1]);
!     else
!         fprintf (file, "");
! 
!     if (snippet_no<snippet_count-1)
!         fprintf (file, "&nbsp;<a href='%s.html'>next(%s)</a>", snippet_name[snippet_no+1], snippet_name[snippet_no+1]);
!     else
!         fprintf (file, "");
!     fprintf (file, "</p>\n");
! 
!     fprintf (file, "<table>\n");
! 
!     {
!             FILE *srcfile;
!             int  size;
!             const char *c=&snippet_source[snippet_no][0];
! 
!             fprintf (file, "    <tr>\n");
!             fprintf (file, "       <td colspan='2'>\n");
!             fprintf (file, "         <h3><a href='snippets.html#%s'><b>%s</b></h3>\n", name,name);
!             fprintf (file, "       </td>\n");
!             fprintf (file, "    <tr>\n");
!             fprintf (file, "    <tr>\n");
!             fprintf (file, "       <td><pre>\n");
! 
!             while (*c){
!                     switch (*c){
!                         case '<':
!                             fprintf (file, "&lt;");
!                             break;
!                         case '>':
!                             fprintf (file, "&gt;");
!                             break;
!                         case '&':
!                             fprintf (file, "&amp;");
!                             break;
!                         default:
!                             fprintf (file, "%c", *c);
!                     }
!                     c++;
!             }
! 
!             fprintf (file, "       </pre></td>\n");
!             fprintf (file, "       <td>\n");
!             fprintf (file, "         <img src='%s.png'/>\n", name);
!             fprintf (file, "       </td>\n");
!             fprintf (file, "    </tr>\n");
!             fprintf (file, "    <tr><td>&nbsp;</td></tr>\n");
!     }
!     fprintf (file, "</table>");
!     embed_file (file, "footer.html_template");
      fclose (file);
  }

Index: caps.cairo
===================================================================
RCS file: /cvs/cairo/cairo-demo/cairo_snippets/caps.cairo,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** a/caps.cairo	16 May 2004 19:09:50 -0000	1.1
--- b/caps.cairo	20 May 2004 14:33:23 -0000	1.2
***************
*** 9,16 ****
  cairo_move_to (cr, 0.75, 0.2); cairo_line_to (cr, 0.75, 0.8);
  cairo_stroke (cr);
  cairo_move_to (cr, 0.25, 0.2); cairo_line_to (cr, 0.25, 0.8);
  cairo_move_to (cr, 0.5, 0.2);  cairo_line_to (cr, 0.5, 0.8);
  cairo_move_to (cr, 0.75, 0.2); cairo_line_to (cr, 0.75, 0.8);
- cairo_set_rgb_color (cr, 1,1,1);
- cairo_set_line_width (cr, 0.01);
  cairo_stroke (cr);
--- 9,18 ----
  cairo_move_to (cr, 0.75, 0.2); cairo_line_to (cr, 0.75, 0.8);
  cairo_stroke (cr);
+ 
+ /* draw helping lines */
+ cairo_set_rgb_color (cr, 1,0.2,0.2);
+ cairo_set_line_width (cr, 0.01);
  cairo_move_to (cr, 0.25, 0.2); cairo_line_to (cr, 0.25, 0.8);
  cairo_move_to (cr, 0.5, 0.2);  cairo_line_to (cr, 0.5, 0.8);
  cairo_move_to (cr, 0.75, 0.2); cairo_line_to (cr, 0.75, 0.8);
  cairo_stroke (cr);

Index: joins.cairo
===================================================================
RCS file: /cvs/cairo/cairo-demo/cairo_snippets/joins.cairo,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** a/joins.cairo	16 May 2004 19:09:50 -0000	1.1
--- b/joins.cairo	20 May 2004 14:33:23 -0000	1.2
***************
*** 1,4 ****
! cairo_set_line_width (cr, 0.12);
! cairo_move_to (cr, 0.3, 0.3);
  cairo_rel_line_to (cr, 0.2, -0.2);
  cairo_rel_line_to (cr, 0.2, 0.2);
--- 1,4 ----
! cairo_set_line_width (cr, 0.16);
! cairo_move_to (cr, 0.3, 0.33);
  cairo_rel_line_to (cr, 0.2, -0.2);
  cairo_rel_line_to (cr, 0.2, 0.2);
***************
*** 6,10 ****
  cairo_stroke (cr);
  
! cairo_move_to (cr, 0.3, 0.6);
  cairo_rel_line_to (cr, 0.2, -0.2);
  cairo_rel_line_to (cr, 0.2, 0.2);
--- 6,10 ----
  cairo_stroke (cr);
  
! cairo_move_to (cr, 0.3, 0.63);
  cairo_rel_line_to (cr, 0.2, -0.2);
  cairo_rel_line_to (cr, 0.2, 0.2);
***************
*** 12,18 ****
  cairo_stroke (cr);
  
! cairo_move_to (cr, 0.3, 0.9);
  cairo_rel_line_to (cr, 0.2, -0.2);
  cairo_rel_line_to (cr, 0.2, 0.2);
  cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
  cairo_stroke (cr);
--- 12,20 ----
  cairo_stroke (cr);
  
! cairo_move_to (cr, 0.3, 0.93);
  cairo_rel_line_to (cr, 0.2, -0.2);
  cairo_rel_line_to (cr, 0.2, 0.2);
  cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
  cairo_stroke (cr);
+ 
+ 

Index: text.cairo
===================================================================
RCS file: /cvs/cairo/cairo-demo/cairo_snippets/text.cairo,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** a/text.cairo	16 May 2004 19:09:50 -0000	1.1
--- b/text.cairo	20 May 2004 14:33:23 -0000	1.2
***************
*** 14,15 ****
--- 14,23 ----
  cairo_set_line_width (cr, 0.01);
  cairo_stroke (cr);
+ 
+ /* draw helping lines */
+ cairo_set_rgb_color (cr, 1,0.2,0.2);
+ cairo_set_alpha (cr, 0.6);
+ cairo_arc (cr, 0.04, 0.53, 0.02, 0, 2*M_PI);
+ cairo_arc (cr, 0.27, 0.65, 0.02, 0, 2*M_PI);
+ cairo_fill (cr);
+ 

Index: text_centering.cairo
===================================================================
RCS file: /cvs/cairo/cairo-demo/cairo_snippets/text_centering.cairo,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** a/text_centering.cairo	16 May 2004 19:09:50 -0000	1.1
--- b/text_centering.cairo	20 May 2004 14:33:23 -0000	1.2
***************
*** 1,4 ****
- const char *string = "cairo";
  cairo_text_extents_t extents;
  double x,y;
  
--- 1,5 ----
  cairo_text_extents_t extents;
+ 
+ const char *utf8 = "cairo";
  double x,y;
  
***************
*** 6,13 ****
      CAIRO_FONT_SLANT_NORMAL,
      CAIRO_FONT_WEIGHT_NORMAL);
  cairo_scale_font (cr, 0.4);
! cairo_text_extents (cr, string, &extents);
  x = 0.5-(extents.width/2 +extents.x_bearing);
  y = 0.5-(extents.height/2+extents.y_bearing);
  cairo_move_to (cr, x, y);
! cairo_show_text (cr, string);
--- 7,28 ----
      CAIRO_FONT_SLANT_NORMAL,
      CAIRO_FONT_WEIGHT_NORMAL);
+ 
  cairo_scale_font (cr, 0.4);
! cairo_text_extents (cr, utf8, &extents);
  x = 0.5-(extents.width/2 +extents.x_bearing);
  y = 0.5-(extents.height/2+extents.y_bearing);
+ 
  cairo_move_to (cr, x, y);
! cairo_show_text (cr, utf8);
! 
! /* draw helping lines */
! cairo_set_rgb_color (cr, 1,0.2,0.2);
! cairo_set_alpha (cr, 0.6);
! cairo_arc (cr, x, y, 0.05, 0, 2*M_PI);
! cairo_fill (cr);
! cairo_move_to (cr, x,y);
! cairo_rel_line_to (cr, 0, -extents.height);
! cairo_rel_line_to (cr, extents.width, 0);
! cairo_rel_line_to (cr, extents.x_bearing, -extents.y_bearing);
! cairo_stroke (cr);
! 

--- bezier_spline.cairo DELETED ---

--- caps_and_joins.cairo DELETED ---

--- footer.html DELETED ---

--- header.html DELETED ---





More information about the cairo-commit mailing list