head 1.12; access; symbols; locks; strict; comment @ * @; 1.12 date 2005.05.13.22.36.19; author pippin; state Exp; branches; next 1.11; commitid 244f42852be14567; 1.11 date 2005.05.12.09.49.20; author stevech1097; state Exp; branches; next 1.10; commitid 5f1f4283269f4567; 1.10 date 2005.05.11.21.15.31; author otaylor; state Exp; branches; next 1.9; commitid 4fe428275f24567; 1.9 date 2005.05.03.02.22.48; author krh; state Exp; branches; next 1.8; commitid 33124276e0734567; 1.8 date 2005.04.02.02.03.59; author cworth; state Exp; branches; next 1.7; 1.7 date 2005.03.04.18.39.36; author otaylor; state Exp; branches; next 1.6; 1.6 date 2005.01.11.22.38.03; author pippin; state Exp; branches; next 1.5; 1.5 date 2004.10.13.18.24.11; author cworth; state Exp; branches; next 1.4; 1.4 date 2004.05.18.21.54.57; author pippin; state Exp; branches; next 1.3; 1.3 date 2004.05.18.15.06.14; author pippin; state Exp; branches; next 1.2; 1.2 date 2004.05.18.12.47.41; author pippin; state Exp; branches; next 1.1; 1.1 date 2004.05.16.19.09.50; author pippin; state Exp; branches; next ; desc @@ 1.12 log @reordered cr and surface destruction calls. @ text @/* png frontend for cairo_snippets * (c) Øyvind Kolås 2004, placed in the public domain */ #include "snippets.h" #define IMAGE_WIDTH 256 #define IMAGE_HEIGHT 256 #define LINE_WIDTH 0.04 /* process a snippet, writing it out to file */ static void snippet_do_png (int no); int main (int argc, char **argv) { int i; if (argc > 1) { for (i = 1; i < argc; i++) { int snippet = snippet_name2no (argv[i]); if (snippet >= 0) snippet_do_png (snippet); } } else { for (i=0;i * cairo_snippets_png.c cairo_snippets_ps.c cairo_snippets_win32.c snippets/*.cairo: Cairo API updates. * snippets.h: Remove a stray png-io.h include. * snippets/pattern_fill.cairo: Remove some unused extern @ text @a5 1 #include @ 1.9 log @2005-05-02 Kristian Høgsberg * png_io.c: * png_io.h: * cairo_snippets_png.c: * Makefile.am: Drop custom PNG IO functions and use cairo's new PNG functions. * prepare_snippets.c: * snippets/clip_image.cairo: * snippets/curve_rectangle.cairo: * snippets/fill_and_stroke.cairo: * snippets/fill_and_stroke2.cairo: * snippets/image.cairo: * snippets/imagepattern.cairo: * snippets/libsvg.cairo: * snippets/text.cairo: Port to cairos new group semantics by using cairo_fill_preserve() instead of cairo_save()/cairo_restore() to keep the current path after filling it. Use cairo_image_surface_create_from_png() to load png files. Fix pointer signedness in a couple of places. @ text @d6 1 d40 1 d45 3 a47 4 cr = cairo_create (); cairo_set_target_image_no_data (cr, CAIRO_FORMAT_ARGB32, IMAGE_WIDTH, IMAGE_HEIGHT); d54 1 a54 1 cairo_surface_write_to_png (cairo_get_target_surface (cr), filename); d58 1 @ 1.8 log @ * cairo_snippets_png.c: (snippet_do_png): Track removal of cairo_set_target_png. @ text @d39 1 a39 2 FILE *file; char pngfile[1024]; a42 4 sprintf (pngfile, "%s.png", snippet_name [no]); file = fopen (pngfile, "wb"); d52 2 a53 1 cairo_surface_write_png (cairo_get_target_surface (cr), file); a57 1 fclose (file); @ 1.7 log @2005-03-04 Owen Taylor * cairo_snippets_png.c (snippet_do_png): Open output file with "wb". @ text @d50 2 a51 1 cairo_set_target_png (cr, file, CAIRO_FORMAT_ARGB32, IMAGE_WIDTH, IMAGE_HEIGHT); d57 1 a57 1 cairo_show_page (cr); @ 1.6 log @added normalization function, and removed then redundant initialization code from snippets @ text @d46 1 a46 1 file = fopen (pngfile, "w"); @ 1.5 log @ * cairo_snippets_html.c (do_index): index() is a C library function, rename to do_index(). * Makefile: Add -g -Wall -O2, to get good warnings. * cairo_snippets_html.c prepare_snippets.c: Fix warnings. * cairo_snippets_png.c: Allow individual snippet names to be specified on the command line. @ text @d53 1 a53 8 cairo_scale (cr, IMAGE_WIDTH/1.0, IMAGE_HEIGHT/1.0); cairo_rectangle (cr, 0,0, 1.0, 1.0); cairo_set_rgb_color (cr, 1,1,1); cairo_fill (cr); cairo_set_rgb_color (cr, 0.0, 0.0, 0.0); cairo_set_line_width (cr, LINE_WIDTH); snippet_do (cr, no); a55 5 cairo_set_line_width (cr, 2); cairo_set_rgb_color (cr, 0.0, 0.0, 0.0); cairo_rectangle (cr, 0,0, IMAGE_WIDTH, IMAGE_HEIGHT); cairo_stroke (cr); @ 1.4 log @seperated the html generation from cairo_snippets_png @ text @d17 1 a17 1 main (void) d21 10 a30 2 for (i=0;icairo: snippets\n" " \n" " \n" "\n" "
\n" "\n" "

cairo samples

" "

This page contains cairo code snippets and the corresponding rendered output.\n" "The user space is the unit square ( (0,0) - (1, 1) ).\n" "The snippets are meant to be short, and easy to understand

\n" "

cairo_snippets is available as part of the cairo-demo module in cairo CVS

\n" "

The snippet enviroment, and the original snippets were originally " "created for a paper submitted to GUADEC 2004.

"; static char *html_footer=" \n" "

\n" "\n" "

\n" "\n" "
\n" "\n"; int write_html(void) { int i=0; FILE *file= fopen ("snippets.html", "w"); fprintf (stdout, "writing snippets.html"); fprintf (file, html_header); fprintf (file, "
    \n"); for (i=0;i%s\n", snippet_name[i], snippet_name[i]); fprintf (file, "
\n"); fprintf (file, "\n"); for (i=0;i\n"); fprintf (file, " \n"); fprintf (file, " \n"); fprintf (file, " \n"); fprintf (file, " \n"); fprintf (file, " \n"); fprintf (file, " \n"); fprintf (file, " \n"); } fprintf (file, html_footer); fclose (file); fprintf (stdout, "\n"); } @ 1.2 log @tidied up the png writing backend @ text @d85 3 a87 3 "

cairo snippets

" "

This page contains cairo code snippets and the corresponding rendered output\n" "the user space used is the unit square ( (0,0) - (1, 1) ).\n" d89 1 a89 1 "

cairo_snippets is available as part of the cairo-demo module in cairo CVS

\n" @ 1.1 log @initial import of cairo_snippets @ text @d10 14 a23 1 #define STRIDE (IMAGE_WIDTH * 4) d25 3 a27 1 #define LINE_WIDTH 0.04 d29 2 a30 1 char image[STRIDE*IMAGE_HEIGHT]; d32 2 a33 1 static write_image (cairo_t *cr, int no) d35 2 d43 6 d65 1 a65 1 write_png_argb32 (image, pngfile, IMAGE_WIDTH, IMAGE_HEIGHT, STRIDE); d68 3 a164 14 int main (void) { cairo_t *cr; int i; cr = cairo_create (); cairo_set_target_image (cr, image, CAIRO_FORMAT_ARGB32, IMAGE_WIDTH, IMAGE_HEIGHT, STRIDE); for (i=0;i
\n"); fprintf (file, "

%s

\n", name,name,name); fprintf (file, "
\n");

            while (*c){
                    switch (*c){
                        case '<':
                            fprintf (file, "<");
                            break;
                        case '>':
                            fprintf (file, ">");
                            break;
                        case '&':
                            fprintf (file, "&");
                            break;
                        default:
                            fprintf (file, "%c", *c);
                    }
                    c++;
            }

            fprintf (file, "       
\n"); fprintf (file, " \n", imgname); fprintf (file, "