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_spline (cairo_t *cr, double height); void draw_splines (cairo_t *cr, int width, int height); #define WIDTH 600 #define HEIGHT 300 #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_splines (cr, WIDTH, HEIGHT); cairo_surface_write_to_png (surface, "splines_tolerance.png"); cairo_destroy (cr); cairo_surface_destroy (surface); return 0; } void draw_spline (cairo_t *cr, double height) { cairo_move_to (cr, 0, .1 * height); height = .8 * height; cairo_rel_curve_to (cr, -height/2, height/2, height/2, height/2, 0, height); cairo_stroke (cr); } void draw_splines (cairo_t *cr, int width, int height) { int i; double tolerance[5] = {.1, .5, 1, 5, 10}; double line_width = .08 * width; double gap = width / 6; cairo_set_source_rgb (cr, 0, 0, 0); cairo_set_line_width (cr, line_width); cairo_translate (cr, gap, 0); for (i=0; i < 5; i++) { cairo_set_tolerance (cr, tolerance[i]); draw_spline (cr, height); cairo_translate (cr, gap, 0); } } @ 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 @d42 1 a42 1 char image[STRIDE*HEIGHT]; d47 1 d50 2 a51 1 cr = cairo_create (); d53 1 a53 2 cairo_set_target_image (cr, image, CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT, STRIDE); d56 1 a56 1 cairo_set_rgb_color (cr, 1, 1, 1); d61 1 a61 1 write_png_argb32 (image, "splines_tolerance.png", WIDTH, HEIGHT, STRIDE); d65 2 d90 1 a90 1 cairo_set_rgb_color (cr, 0, 0, 0); @ 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_spline (cairo_t *ct, double height); d36 1 a36 1 draw_splines (cairo_t *ct, int width, int height); d47 1 a47 1 cairo_t *ct; d49 1 a49 1 ct = cairo_create (); d51 1 a51 1 cairo_set_target_image (ct, image, CAIRO_FORMAT_ARGB32, d54 3 a56 3 cairo_rectangle (ct, 0, 0, WIDTH, HEIGHT); cairo_set_rgb_color (ct, 1, 1, 1); cairo_fill (ct); d58 1 a58 1 draw_splines (ct, WIDTH, HEIGHT); d62 1 a62 1 cairo_destroy (ct); d68 1 a68 1 draw_spline (cairo_t *ct, double height) d70 1 a70 1 cairo_move_to (ct, 0, .1 * height); d72 1 a72 1 cairo_rel_curve_to (ct, d76 1 a76 1 cairo_stroke (ct); d80 1 a80 1 draw_splines (cairo_t *ct, int width, int height) d87 2 a88 2 cairo_set_rgb_color (ct, 0, 0, 0); cairo_set_line_width (ct, line_width); d90 1 a90 1 cairo_translate (ct, gap, 0); d92 3 a94 3 cairo_set_tolerance (ct, tolerance[i]); draw_spline (ct, height); cairo_translate (ct, gap, 0); @