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 #include void draw_hering (cairo_t *cr, int width, int height); #define WIDTH 300 #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_hering (cr, WIDTH, HEIGHT); cairo_surface_write_to_png (surface, "hering.png"); cairo_destroy (cr); cairo_surface_destroy (surface); return 0; } void draw_hering (cairo_t *cr, int width, int height) { #define LINES 32 #define MAX_THETA (.80 * M_PI_2) #define THETA_INC (2 * MAX_THETA / (double) (LINES-1)) int i; cairo_set_source_rgb (cr, 0, 0, 0); cairo_set_line_width (cr, 2.0); cairo_save (cr); { cairo_translate (cr, width / 2, height / 2); cairo_rotate (cr, MAX_THETA); for (i=0; i < LINES; i++) { cairo_move_to (cr, -2 * width, 0); cairo_line_to (cr, 2 * width, 0); cairo_stroke (cr); cairo_rotate (cr, - THETA_INC); } } cairo_restore (cr); cairo_set_line_width (cr, 6); cairo_set_source_rgb (cr, 1, 0, 0); cairo_move_to (cr, width / 4, 0); cairo_rel_line_to (cr, 0, height); cairo_stroke (cr); cairo_move_to (cr, 3 * width / 4, 0); cairo_rel_line_to (cr, 0, height); 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 @a30 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 @d40 1 a40 1 char image[STRIDE*HEIGHT]; d45 1 d48 3 a50 4 cr = cairo_create (); 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, "hering.png", WIDTH, HEIGHT, STRIDE); d62 2 d76 1 a76 1 cairo_set_rgb_color (cr, 0, 0, 0); d95 1 a95 1 cairo_set_rgb_color (cr, 1, 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 @d34 1 a34 1 draw_hering (cairo_t *ct, int width, int height); d45 1 a45 1 cairo_t *ct; d47 1 a47 1 ct = cairo_create (); d49 1 a49 1 cairo_set_target_image (ct, image, CAIRO_FORMAT_ARGB32, d52 3 a54 3 cairo_rectangle (ct, 0, 0, WIDTH, HEIGHT); cairo_set_rgb_color (ct, 1, 1, 1); cairo_fill (ct); d56 1 a56 1 draw_hering (ct, WIDTH, HEIGHT); d60 1 a60 1 cairo_destroy (ct); d66 1 a66 1 draw_hering (cairo_t *ct, int width, int height) d74 2 a75 2 cairo_set_rgb_color (ct, 0, 0, 0); cairo_set_line_width (ct, 2.0); d77 1 a77 1 cairo_save (ct); d79 2 a80 2 cairo_translate (ct, width / 2, height / 2); cairo_rotate (ct, MAX_THETA); d83 3 a85 3 cairo_move_to (ct, -2 * width, 0); cairo_line_to (ct, 2 * width, 0); cairo_stroke (ct); d87 1 a87 1 cairo_rotate (ct, - THETA_INC); d90 1 a90 1 cairo_restore (ct); d92 2 a93 2 cairo_set_line_width (ct, 6); cairo_set_rgb_color (ct, 1, 0, 0); d95 7 a101 7 cairo_move_to (ct, width / 4, 0); cairo_rel_line_to (ct, 0, height); cairo_stroke (ct); cairo_move_to (ct, 3 * width / 4, 0); cairo_rel_line_to (ct, 0, height); cairo_stroke (ct); @