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_caps_joins (cairo_t *cr, int width, int height); void stroke_v_twice (cairo_t *cr, int dx, int dy); void draw_three_vs (cairo_t *cr, int width, int height, int line_width); #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_caps_joins (cr, WIDTH, HEIGHT); cairo_surface_write_to_png (surface, "caps_joins.png"); cairo_destroy (cr); cairo_surface_destroy (surface); return 0; } void stroke_v_twice (cairo_t *cr, int width, int height) { cairo_move_to (cr, 0, 0); cairo_rel_line_to (cr, width / 2, height / 2); cairo_rel_line_to (cr, width / 2, - height / 2); cairo_save (cr); cairo_stroke (cr); cairo_restore (cr); cairo_save (cr); { cairo_set_line_width (cr, 2.0); cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT); cairo_set_source_rgb (cr, 1, 1, 1); cairo_stroke (cr); } cairo_restore (cr); cairo_new_path (cr); } void draw_caps_joins (cairo_t *cr, int width, int height) { int line_width = height / 12 & (~1); cairo_set_line_width (cr, line_width); cairo_set_source_rgb (cr, 0, 0, 0); cairo_translate (cr, line_width, line_width); width -= 2 *line_width; cairo_set_line_join (cr, CAIRO_LINE_JOIN_BEVEL); cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT); stroke_v_twice (cr, width, height); cairo_translate (cr, 0, height / 4 - line_width); cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER); cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); stroke_v_twice (cr, width, height); cairo_translate (cr, 0, height / 4 - line_width); cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND); cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); stroke_v_twice (cr, width, height); } @ 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 @d45 1 a45 1 char image[STRIDE*HEIGHT]; d50 1 d53 2 a54 1 cr = cairo_create (); d56 1 a56 2 cairo_set_target_image (cr, image, CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT, STRIDE); d59 1 a59 1 cairo_set_rgb_color (cr, 1, 1, 1); d64 1 a64 1 write_png_argb32 (image, "caps_joins.png", WIDTH, HEIGHT, STRIDE); d68 2 d88 1 a88 1 cairo_set_rgb_color (cr, 1, 1, 1); d102 1 a102 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_caps_joins (cairo_t *ct, int width, int height); d36 1 a36 1 stroke_v_twice (cairo_t *ct, int dx, int dy); d39 1 a39 1 draw_three_vs (cairo_t *ct, int width, int height, int line_width); d50 1 a50 1 cairo_t *ct; d52 1 a52 1 ct = cairo_create (); d54 1 a54 1 cairo_set_target_image (ct, image, CAIRO_FORMAT_ARGB32, d57 3 a59 3 cairo_rectangle (ct, 0, 0, WIDTH, HEIGHT); cairo_set_rgb_color (ct, 1, 1, 1); cairo_fill (ct); d61 1 a61 1 draw_caps_joins (ct, WIDTH, HEIGHT); d65 1 a65 1 cairo_destroy (ct); d71 1 a71 1 stroke_v_twice (cairo_t *ct, int width, int height) d73 7 a79 7 cairo_move_to (ct, 0, 0); cairo_rel_line_to (ct, width / 2, height / 2); cairo_rel_line_to (ct, width / 2, - height / 2); cairo_save (ct); cairo_stroke (ct); cairo_restore (ct); d81 1 a81 1 cairo_save (ct); d83 4 a86 4 cairo_set_line_width (ct, 2.0); cairo_set_line_cap (ct, CAIRO_LINE_CAP_BUTT); cairo_set_rgb_color (ct, 1, 1, 1); cairo_stroke (ct); d88 1 a88 1 cairo_restore (ct); d90 1 a90 1 cairo_new_path (ct); d94 1 a94 1 draw_caps_joins (cairo_t *ct, int width, int height) d98 2 a99 2 cairo_set_line_width (ct, line_width); cairo_set_rgb_color (ct, 0, 0, 0); d101 1 a101 1 cairo_translate (ct, line_width, line_width); d104 13 a116 13 cairo_set_line_join (ct, CAIRO_LINE_JOIN_BEVEL); cairo_set_line_cap (ct, CAIRO_LINE_CAP_BUTT); stroke_v_twice (ct, width, height); cairo_translate (ct, 0, height / 4 - line_width); cairo_set_line_join (ct, CAIRO_LINE_JOIN_MITER); cairo_set_line_cap (ct, CAIRO_LINE_CAP_SQUARE); stroke_v_twice (ct, width, height); cairo_translate (ct, 0, height / 4 - line_width); cairo_set_line_join (ct, CAIRO_LINE_JOIN_ROUND); cairo_set_line_cap (ct, CAIRO_LINE_CAP_ROUND); stroke_v_twice (ct, width, height); @