head 1.5; access; symbols; locks; strict; comment @ * @; 1.5 date 2005.05.17.15.24.39; author cworth; state Exp; branches; next 1.4; commitid 22b4428a0cb74567; 1.4 date 2005.05.17.14.31.43; author cworth; state Exp; branches; next 1.3; commitid 2e0428a004e4567; 1.3 date 2005.04.02.04.20.39; author cworth; state Exp; branches; next 1.2; 1.2 date 2004.05.11.14.52.19; author pippin; state Exp; branches; next 1.1; 1.1 date 2003.08.18.18.11.38; author cworth; state Exp; branches; next ; desc @@ 1.5 log @ * bevels.c: * caps_joins.c: * hering.c: * outline.c: * snapping.c: * spiral.c: * splines_tolerance.c: * star_and_ring.c: * stars.c: * text-rotate.c: * text.c: Remove stale includes of write_png.h. @ text @/* * Copyright © 2003 USC, Information Sciences Institute * * Permission to use, copy, modify, distribute, and sell this software * and its documentation for any purpose is hereby granted without * fee, provided that the above copyright notice appear in all copies * and that both that copyright notice and this permission notice * appear in supporting documentation, and that the name of the * University of Southern California not be used in advertising or * publicity pertaining to distribution of the software without * specific, written prior permission. The University of Southern * California makes no representations about the suitability of this * software for any purpose. It is provided "as is" without express * or implied warranty. * * THE UNIVERSITY OF SOUTHERN CALIFORNIA DISCLAIMS ALL WARRANTIES WITH * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF * SOUTHERN CALIFORNIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Carl D. Worth */ #include void draw_spiral (cairo_t *cr, int width, int height); #define WIDTH 600 #define HEIGHT 600 #define STRIDE (WIDTH * 4) unsigned char image[STRIDE*HEIGHT]; int main (void) { cairo_surface_t *surface; cairo_t *cr; surface = cairo_image_surface_create_for_data (image, CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT, STRIDE); cr = cairo_create (surface); cairo_rectangle (cr, 0, 0, WIDTH, HEIGHT); cairo_set_source_rgb (cr, 1, 1, 1); cairo_fill (cr); draw_spiral (cr, WIDTH, HEIGHT); cairo_surface_write_to_png (surface, "spiral.png"); cairo_destroy (cr); cairo_surface_destroy (surface); return 0; } void draw_spiral (cairo_t *cr, int width, int height) { int wd = .02 * width; int hd = .02 * height; int i; width -= 2; height -= 2; cairo_move_to (cr, width + 1, 1-hd); for (i=0; i < 9; i++) { cairo_rel_line_to (cr, 0, height - hd * (2 * i - 1)); cairo_rel_line_to (cr, - (width - wd * (2 *i)), 0); cairo_rel_line_to (cr, 0, - (height - hd * (2*i))); cairo_rel_line_to (cr, width - wd * (2 * i + 1), 0); } cairo_set_source_rgb (cr, 0, 0, 1); cairo_stroke (cr); } @ 1.4 log @ * Makefile: * bevels.c: (set_hex_color), (main): * caps_joins.c: (main), (stroke_v_twice), (draw_caps_joins): * hering.c: (main), (draw_hering): * outline.c: (main), (create_gradient), (draw_outlines): * snapping.c: (snap_point_for_fill), (snap_point_for_stroke), (snap_line_width), (snap_path_for_fill), (snap_path_for_stroke), (draw_nested), (main): * spiral.c: (main), (draw_spiral): * splines_tolerance.c: (main), (draw_splines): * star_and_ring.c: (star_path), (fill_ring), (fill_star), (main): * stars.c: (main), (draw_stars): * text-rotate.c: (main): * text.c: (box_text), (box_glyphs), (main): Update all programs to match recent cairo API changes. @ text @a29 2 #include "write_png.h" @ 1.3 log @ * caps_joins.c: * hering.c: * outline.c: * spiral.c: * splines_tolerance.c: * stars.c: * text-rotate.c: * text.c: * write_png.c: * write_png.h: Convert file encodings to utf-8. @ text @d39 1 a39 1 char image[STRIDE*HEIGHT]; d44 1 d47 2 a48 1 cr = cairo_create (); d50 1 a50 2 cairo_set_target_image (cr, image, CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT, STRIDE); d53 1 a53 1 cairo_set_rgb_color (cr, 1, 1, 1); d58 1 a58 1 write_png_argb32 (image, "spiral.png", WIDTH, HEIGHT, STRIDE); d62 2 d85 1 a85 1 cairo_set_rgb_color (cr, 0, 0, 1); @ 1.2 log @global replacing of ct with cr @ text @d2 1 a2 1 * Copyright © 2003 USC, Information Sciences Institute @ 1.1 log @Added demos from OLS paper. @ text @d33 1 a33 1 draw_spiral (cairo_t *ct, int width, int height); d44 1 a44 1 cairo_t *ct; d46 1 a46 1 ct = cairo_create (); d48 1 a48 1 cairo_set_target_image (ct, image, CAIRO_FORMAT_ARGB32, d51 3 a53 3 cairo_rectangle (ct, 0, 0, WIDTH, HEIGHT); cairo_set_rgb_color (ct, 1, 1, 1); cairo_fill (ct); d55 1 a55 1 draw_spiral (ct, WIDTH, HEIGHT); d59 1 a59 1 cairo_destroy (ct); d65 1 a65 1 draw_spiral (cairo_t *ct, int width, int height) d74 1 a74 1 cairo_move_to (ct, width + 1, 1-hd); d76 4 a79 4 cairo_rel_line_to (ct, 0, height - hd * (2 * i - 1)); cairo_rel_line_to (ct, - (width - wd * (2 *i)), 0); cairo_rel_line_to (ct, 0, - (height - hd * (2*i))); cairo_rel_line_to (ct, width - wd * (2 * i + 1), 0); d82 2 a83 2 cairo_set_rgb_color (ct, 0, 0, 1); cairo_stroke (ct); @