head 1.13; access; symbols; locks; strict; comment @# @; 1.13 date 2005.06.07.05.09.35; author keithp; state Exp; branches; next 1.12; commitid 28e542a52c0b4567; 1.12 date 2005.06.07.03.41.36; author keithp; state Exp; branches; next 1.11; commitid 129442a517694567; 1.11 date 2005.05.18.06.21.15; author keithp; state Exp; branches; next 1.10; commitid 431d428aded64567; 1.10 date 2005.05.02.20.24.38; author keithp; state Exp; branches; next 1.9; commitid 416842768c824567; 1.9 date 2005.02.11.21.15.46; author keithp; state Exp; branches; next 1.8; 1.8 date 2004.12.24.09.00.10; author keithp; state Exp; branches; next 1.7; 1.7 date 2004.12.23.22.39.40; author keithp; state Exp; branches; next 1.6; 1.6 date 2004.12.19.00.06.26; author keithp; state Exp; branches; next 1.5; 1.5 date 2004.12.18.08.16.28; author keithp; state Exp; branches; next 1.4; 1.4 date 2004.12.18.01.09.40; author keithp; state Exp; branches; next 1.3; 1.3 date 2004.12.17.09.50.16; author keithp; state Exp; branches; next 1.2; 1.2 date 2004.12.17.09.40.43; author keithp; state Exp; branches; next 1.1; 1.1 date 2004.12.17.02.09.45; author keithp; state Exp; branches; next ; desc @@ 1.13 log @2005-06-06 Keith Packard * cairo.5c: * init.c: (init_types), (nickle_init): Enum order and names changed in API shuffle. * examples/fob.5c: Create .png files by default @ text @/* $Id: cairo.5c,v 1.12 2005/06/07 03:41:36 keithp Exp $ * * Copyright © 2004 Keith Packard * * This library is free software; you can redistribute it and/or * modify it either under the terms of the GNU Lesser General Public * License version 2.1 as published by the Free Software Foundation * (the "LGPL") or, at your option, under the terms of the Mozilla * Public License Version 1.1 (the "MPL"). If you do not alter this * notice, a recipient may use your version of this file under either * the MPL or the LGPL. * * You should have received a copy of the LGPL along with this library * in the file COPYING-LGPL-2.1; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * You should have received a copy of the MPL along with this library * in the file COPYING-MPL-1.1 * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY * OF ANY KIND, either express or implied. See the LGPL or the MPL for * the specific language governing rights and limitations. * * The Original Code is the cairo graphics library. * * The Initial Developer of the Original Code is Keith Packard * * Contributor(s): * Keith Packard */ if (!Command::valid_name ((string[]) { "Cairo" })) Foreign::load ("libcairo-5c.so"); extend namespace Cairo { public typedef void (real x, real y) move_to_func_t; public typedef void (real x, real y) line_to_func_t; public typedef void (real x1, real y1, real x2, real y2, real x3, real y3) curve_to_func_t; public typedef void () close_path_func_t; public typedef struct { real hue, saturation, value; } hsv_color_t; public int width (cairo_t cr) = Surface::width (get_target (cr)); public int height (cairo_t cr) = Surface::height (get_target (cr)); public file open_event (cairo_t cr) = Surface::open_event (get_target (cr)); public cairo_t new (int args...) { int w = dim(args) > 0 ? args[0] : 0; int h = dim(args) > 1 ? args[1] : 0; string name = (dim (argv) > 0) ? argv[0] : "nickle"; cairo_t cr = create (Surface::create_window (name, w, h)); set_source_rgba (cr, 1, 1, 1, 1); paint (cr); set_source_rgba (cr, 0, 0, 0, 1); return cr; } public cairo_t new_window (string name, int args...) { int w = dim(args) > 0 ? args[0] : 0; int h = dim(args) > 1 ? args[1] : 0; surface_t surface = Surface::create_window (name, w, h); cairo_t cr = create (surface); set_source_rgba (cr, 1, 1, 1, 1); paint (cr); set_source_rgba (cr, 0, 0, 0, 1); return cr; } public cairo_t new_image (int width, int height) { surface_t surface = Image::surface_create (0, width, height); cairo_t cr = create (surface); set_source_rgba (cr, 0, 0, 0, 0); set_operator (cr, operator_t.SOURCE); paint (cr); set_operator (cr, operator_t.OVER); set_source_rgba (cr, 0, 0, 0, 1); return cr; } public void write_to_png (cairo_t cr, string filename) { surface_t surface = get_target (cr); Surface::write_to_png (surface, filename); } public cairo_t new_pdf (string filename, real width, real height) { surface_t surface = Pdf::surface_create (filename, width, height); cairo_t cr = create (surface); set_source_rgba (cr, 1, 1, 1, 1); paint (cr); set_source_rgba (cr, 0, 0, 0, 1); return cr; } public cairo_t dup (cairo_t cr) { return create (get_target (cr)); } real[3] to_hsv(real r, real g, real b) { real minimum = min (r, g, b); real maximum = max (r, g, b); real v = maximum; real s = (maximum == 0) ? 0 : (maximum - minimum) / maximum; real h = 0; if (s != 0) { switch (maximum) { case r: h = (g - b) / (maximum - minimum); break; case g: h = 2.0 + (b - r) / (maximum - minimum); break; case b: h = 4.0 + (r - g) / (maximum - minimum); break; } h = h / 6; } return (real[3]) { h, s, v }; } /* convert hsv to rgb */ real[3] from_hsv(real h, real s, real v) { if (v == 0.0) return (real[3]) { 0 ... }; else if (s == 0.0) { return (real[3]) { v ... }; } else { real h6 = (h * 6) % 6; int i = floor (h6); real f = h6 - i; real p = v * (1 - s); real q = v * (1 - (s * f)); real t = v * (1 - (s * (1 - f))); switch(i) { default:return (real[3]) { v, t, p }; case 1: return (real[3]) { q, v, p }; case 2: return (real[3]) { p, v, t }; case 3: return (real[3]) { p, q, v }; case 4: return (real[3]) { t, p, v }; case 5: return (real[3]) { v, p, q }; } } } public void set_source_hsv (cairo_t cr, real h, real s, real v) /* * Set color using HSV specification * H: hue 0 = red, 0.{3} = green, 0.{6} = blue * S: satuation 0..1 * V: value 0..1 */ { set_source_rgb (cr, from_hsv (h, s, v) ...); } public namespace Matrix { matrix_t multiply_scalar (matrix_t a, real scalar) = (matrix_t) { xx = a.xx * scalar, yx = a.yx * scalar, xy = a.xy * scalar, yy = a.yy * scalar, x0 = a.x0 * scalar, y0 = a.y0 * scalar }; public matrix_t identity () = (matrix_t) { xx = 1, yx = 0, xy = 0, yy = 1, x0 = 0, y0 = 0 }; public real determinant (matrix_t m) = m.xx * m.yy - m.yx * m.xy; /* This function isn't a correct adjoint in that the implicit 1 in the homogeneous result should actually be ad-bc instead. But, since this adjoint is only used in the computation of the inverse, which divides by det (A)=ad-bc anyway, everything works out in the end. */ matrix_t adjoint (matrix_t m) = (matrix_t) { xx = m.yy, yx = -m.xy, xy = -m.yx, yy = m.xx, x0 = m.yx * m.y0 - m.yy * m.x0, y0 = m.xy * m.x0 - m.xx * m.y0 }; /* inv (A) = 1/det (A) * adj (A) */ public matrix_t invert (matrix_t a) = multiply_scalar (adjoint (a), 1 / determinant (a)); public matrix_t multiply (matrix_t a, matrix_t b) = (matrix_t) { xx = a.xx * b.xx + a.yx * b.xy, yx = a.xx * b.yx + a.yx * b.yy, xy = a.xy * b.xx + a.yy * b.xy, yy = a.xy * b.yx + a.yy * b.yy, x0 = a.x0 * b.xx + a.y0 * b.xy + b.x0, y0 = a.x0 * b.yx + a.y0 * b.yy + b.y0 }; public matrix_t translate (matrix_t m, real tx, real ty) = multiply ((matrix_t) { xx = 1, yx = 0, xy = 0, yy = 1, x0 = tx, y0 = ty }, m); public matrix_t scale (matrix_t m, real sx, real sy) = multiply ((matrix_t) { xx = sx, yx = 0, xy = 0, yy = sy, x0 = 0, y0 = 0 }, m); public matrix_t rotate (matrix_t m, real a) = multiply ((matrix_t) { xx = (real c = cos(a)), yx = (real s = sin(a)), xy = -s, yy = c, x0 = 0, y0 = 0 }, m); public point_t point (matrix_t m, point_t p) = (point_t) { x = m.xx * p.x + m.yx * p.y + m.x0, y = m.xy * p.x + m.yy * p.y + m.y0 }; public point_t distance (matrix_t m, point_t p) = (point_t) { x = m.xx * p.x + m.yx * p.y, y = m.xy * p.x + m.yy * p.y }; } } @ 1.12 log @2005-06-06 Keith Packard * cairo.5c: * examples/animate.5c: * gtk.c: (gtk_repaint_timeout), (gtk_thread_main), (cairo_5c_tool_dirty): Some locking changes. Still locks up from time to time. @ text @d1 1 a1 1 /* $Id: cairo.5c,v 1.12 2005/06/07 03:27:17 keithp Exp $ d88 1 a88 1 set_operator (cr, operator_t.SRC); @ 1.11 log @2005-05-17 Keith Packard * cairo-5c.h: * cairo.5c: * cairo.c: (cairo_5c_get), (do_Cairo_create), (cairo_5c_dirty), (cairo_5c_enable), (cairo_5c_disable), (do_Cairo_get_target): * draw.c: (do_Cairo_paint), (do_Cairo_paint_with_alpha), (do_Cairo_mask), (do_Cairo_mask_surface), (do_Cairo_fill_preserve), (do_Cairo_stroke_preserve), (path_elt_new), (path_array), (do_Cairo_copy_path), (do_Cairo_copy_path_flat), (do_Cairo_append_path): * event.c: (do_Cairo_Surface_open_event): * examples/animate.5c: * examples/draw.5c: * examples/fob.5c: * examples/metrics.5c: * examples/sin.5c: * examples/spin.5c: * examples/spinman.5c: * examples/test.5c: * gstate.c: (do_Cairo_set_source_surface), (do_Cairo_identity_matrix), (do_Cairo_transform), (do_Cairo_user_to_device), (do_Cairo_user_to_device_distance), (do_Cairo_device_to_user), (do_Cairo_device_to_user_distance), (do_Cairo_reset_clip), (do_Cairo_clip_preserve): * gtk.c: (create_gtk_global): * init.c: (init_types), (nickle_init): * pattern.c: (do_Cairo_Pattern_create_for_surface), (do_Cairo_Pattern_add_color_stop_rgba), (do_Cairo_Pattern_add_color_stop_rgb): * surface.c: (cairo_5c_surface_get), (cairo_5c_surface_mark), (cairo_5c_surface_destroy), (do_Cairo_Surface_write_to_png), (do_Cairo_Surface_write_to_png_file), (do_Cairo_Surface_set_device_offset), (do_Cairo_Surface_create_similar), (do_Cairo_Surface_finish), (do_Cairo_Surface_destroy), (do_Cairo_Surface_width), (do_Cairo_Surface_height), (do_Cairo_Image_surface_create), (do_Cairo_Image_surface_create_from_png), (do_Cairo_Image_surface_create_from_png_file), (do_Cairo_Pdf_surface_create): * text.c: (do_Cairo_select_font_face), (do_Cairo_get_font_matrix): Another round of API changes for cairo 0.5, the putative final API structure. @ text @d1 1 a1 1 /* $Id: cairo.5c,v 1.10 2005/05/02 20:24:38 keithp Exp $ d115 1 a115 1 return cr; @ 1.10 log @2005-05-02 Keith Packard * cairo-5c.h: * cairo.5c: * cairo.c: (cairo_5c_dirty), (cairo_5c_enable), (cairo_5c_disable), (do_Cairo_get_target_surface): * event.c: (do_Cairo_Surface_open_event): * gstate.c: (do_Cairo_set_source_rgb), (do_Cairo_set_source_rgba), (do_Cairo_get_matrix), (do_Cairo_concat_matrix), (do_Cairo_set_matrix), (do_Cairo_get_operator), (do_Cairo_get_tolerance), (do_Cairo_get_current_point), (do_Cairo_get_fill_rule), (do_Cairo_get_line_width), (do_Cairo_get_line_cap), (do_Cairo_get_line_join), (do_Cairo_get_miter_limit): * gtk.c: (delete_drawing_area), (motion_notify_event), (button_press_event), (button_release_event), (gtk_repaint_timeout), (gtk_thread_main), (gtk_global_free), (create_gtk_global), (cairo_5c_tool_dirty), (cairo_5c_tool_enable): * init.c: (init_types), (nickle_init): * matrix.c: (cairo_matrix_part), (new_cairo_matrix): * pattern.c: (do_Cairo_set_source), (do_Cairo_get_source), (do_Cairo_Pattern_set_matrix), (do_Cairo_Pattern_get_matrix): * surface.c: (cairo_5c_surface_get), (cairo_5c_surface_mark), (cairo_5c_surface_destroy), (do_Cairo_Surface_create_image), (do_Cairo_Surface_write_to_png): * text.c: (do_Cairo_set_font), (do_Cairo_set_font_size), (do_Cairo_set_font_matrix), (do_Cairo_font_extents): Match cairo API as of today. * examples/draw.5c: * examples/fob.5c: * examples/graph.5c: * examples/grid.5c: * examples/led.5c: * examples/pie-new.5c: * examples/pie.5c: * examples/rottext.5c: * examples/sin.5c: * examples/spin-cairo.5c: * examples/spin.5c: * examples/spinman.5c: * examples/test.5c: * examples/text45.5c: Update examples to match API changes @ text @d1 1 a1 1 /* $Id: cairo.5c,v 1.9 2005/02/11 21:15:46 keithp Exp $ d50 1 a50 1 Surface::width (get_target_surface (cr)); d53 1 a53 1 Surface::height (get_target_surface (cr)); d56 1 a56 1 Surface::open_event (get_target_surface (cr)); d59 4 a62 12 int w = dim(args) > 0 ? args[0] : 0; int h = dim(args) > 1 ? args[1] : 0; typedef union { void none; surface_t surface; } surface_or_none_t; static surface_or_none_t surface = surface_or_none_t.none; static mutex m = Mutex::new(); cairo_t cr = create (); d64 2 a65 31 /* * A local function to make sure the 'default' surface * exists */ void ensure_surface () { twixt (Mutex::acquire (m); Mutex::release (m)) { union switch (surface) { case none: string name = (dim (argv) > 0) ? argv[0] : "nickle"; surface.surface = Surface::create_window (name, w, h); set_target_surface (cr, surface.surface); set_source_rgba (cr, 1, 1, 1, 1); rectangle (cr, 0, 0, Cairo::width (cr), Cairo::height (cr)); fill (cr); break; case surface: set_target_surface (cr, surface.surface); break; } } } try { ensure_surface (); } catch invalid_argument (string reason, int i, poly arg) { surface = surface_or_none_t.none; ensure_surface (); } d74 1 a74 1 cairo_t cr = create (); a75 1 set_target_surface (cr, surface); d77 1 a77 2 rectangle (cr, 0, 0, Cairo::width (cr), Cairo::height (cr)); fill (cr); d84 3 a86 3 surface_t surface = Surface::create_image (width, height); cairo_t cr = create (); set_target_surface (cr, surface); d89 1 a89 2 rectangle (cr, 0, 0, Cairo::width (cr), Cairo::height (cr)); fill (cr); d97 1 a97 1 surface_t surface = get_target_surface (cr); d101 2 a102 3 public cairo_t new_ps (string filename, real width, real height, real xppi, real yppi) d104 3 a106 4 surface_t surface = Surface::create_ps (filename, width, height, xppi, yppi); cairo_t cr = create (); set_target_surface (cr, surface); d108 1 a108 2 rectangle (cr, 0, 0, Cairo::width (cr), Cairo::height (cr)); fill (cr); d115 1 a115 68 cairo_t n = create (); set_target_surface (n, get_target_surface (cr)); copy (n, cr); return n; } void walk_path (path_t path, move_to_func_t move_to, line_to_func_t line_to, curve_to_func_t curve_to, close_path_func_t close_path) { while (path != path_t.end) { union switch (path) { case move_to m: move_to (m->x, m->y); path = m->next; break; case line_to l: line_to (l->x, l->y); path = l->next; break; case curve_to c: curve_to (c->x1, c->y1, c->x2, c->y2, c->x3, c->y3); path = c->next; break; case close_path c: close_path (); path = c->next; break; case end: break; } } } public void current_path (cairo_t cr, move_to_func_t move_to, line_to_func_t line_to, curve_to_func_t curve_to, close_path_func_t close_path) /* * Walk path calling provided functions for matching * elements sequentially */ { walk_path (current_path_list (cr), move_to, line_to, curve_to, close_path); } public void current_path_flat (cairo_t cr, move_to_func_t move_to, line_to_func_t line_to, close_path_func_t close_path) /* * Walk path calling provided functions for matching * elements sequentially. Curves are replaced by * lines as needed to meet current_tolerance */ { void no_curve_to (real x1, real y1, real x2, real y2, real x2, real y3) { abort ("flat paths have no curves", cr); } walk_path (current_path_flat_list (cr), move_to, line_to, no_curve_to, close_path); @ 1.9 log @2005-01-02 Keith Packard * cairo-5c.h: Add do_Cairo_copy_page and do_Cairo_show_page. Track whether copy_page/show_page have ever been called so that they can be when the surface is destroyed. * cairo.c: (cairo_5c_free), (cairo_5c_dirty): * draw.c: (do_Cairo_arc), (do_Cairo_arc_negative), (do_Cairo_copy_page), (do_Cairo_show_page): Fix arc arguments * event.c: (do_Cairo_Surface_open_event): * gtk.c: (cairo_5c_tool_destroy): * init.c: (nickle_init): * surface.c: (cairo_5c_surface_mark), (cairo_5c_surface_destroy), (cairo_5c_surface_free), (do_Cairo_Surface_create_window), (do_Cairo_Surface_create_png), (do_Cairo_Surface_create_ps), (do_Cairo_Surface_create_similar), (do_Cairo_Surface_destroy): dunno @ text @d1 1 a1 1 /* $Id: cairo.5c,v 1.8 2004/12/24 09:00:10 keithp Exp $ d50 1 a50 1 Surface::width (current_target_surface (cr)); d53 1 a53 1 Surface::height (current_target_surface (cr)); d56 1 a56 1 Surface::open_event (current_target_surface (cr)); d85 1 a85 1 set_rgb_color (cr, 1, 1, 1); d103 1 a103 1 set_rgb_color (cr, 0, 0, 0); d114 1 a114 1 set_rgb_color (cr, 1, 1, 1); d117 1 a117 1 set_rgb_color (cr, 0, 0, 0); d121 1 a121 1 public cairo_t new_png (string filename, int width, int height) d123 1 a123 1 surface_t surface = Surface::create_png (filename, width, height); d126 1 a126 2 set_rgb_color (cr, 0, 0, 0); set_alpha (cr, 0); d131 1 a131 2 set_rgb_color (cr, 0, 0, 0); set_alpha (cr, 1); d135 6 d149 1 a149 1 set_rgb_color (cr, 1, 1, 1); d152 1 a152 1 set_rgb_color (cr, 0, 0, 0); d160 1 a160 1 set_target_surface (n, current_target_surface (cr)); d274 1 a274 1 public void set_hsv_color (cairo_t cr, real h, real s, real v) d282 1 a282 19 set_rgb_color (cr, from_hsv (h, s, v) ...); } public hsv_color_t current_hsv_color (cairo_t cr) /* * Return current color using HSV specification * * H: hue 0 = red, 0.{3} = green, 0.{6} = blue * S: satuation 0..1 * V: value 0..1 */ { rgb_color_t rgb = current_rgb_color (cr); real[3] t = to_hsv (rgb.red, rgb.green, rgb.blue); return (hsv_color_t) { hue = t[0], saturation = t[1], value = t[2] }; d287 5 a291 1 (matrix_t) { [row,col] = a[row,col] * scalar }; d294 4 a297 1 (matrix_t) { [row,col] = row == col ? 1 : 0 }; d300 1 a300 1 m[0,0] * m[1,1] - m[0,1] * m[1,0]; d308 4 a311 4 { m[1,1], -m[0,1] }, { -m[1,0], m[0,0] }, { m[1,0] * m[2,1] - m[1,1] * m[2,0], m[0,1] * m[2,0] - m[0,0] * m[2,1] }}; d318 7 a324 8 (matrix_t) { [row,col] { real t = 0; if (row == 2) t = b[2,col]; for (int n = 0; n < 2; n++) t += a[row,n] * b[n,col]; return t; }}; d327 4 a330 1 multiply ((matrix_t) { { 1, 0 }, { 0, 1 }, { tx, ty } }, m); d333 4 a336 1 multiply ((matrix_t) { { sx, 0 }, { 0, sy }, { 0, 0 } }, m); d340 3 a342 3 { (real c = cos(a)), (real s = sin(a)) }, { -s, c }, { 0, 0 } }, m); d346 2 a347 2 x = m[0,0] * p.x + m[1,0] * p.y + m[2,0], y = m[0,1] * p.x + m[1,1] * p.y + m[2,1] d352 2 a353 2 x = m[0,0] * p.x + m[1,0] * p.y, y = m[0,1] * p.x + m[1,1] * p.y @ 1.8 log @2004-12-24 Keith Packard * cairo-5c.h: * cairo.5c: * cairo.c: (do_Cairo_set_target_surface): * gtk.c: (delete_drawing_area), (gtk_tool_free), (cairo_5c_tool_create), (cairo_5c_tool_destroy): * init.c: (nickle_init): * surface.c: (create_cairo_window), (cairo_5c_surface_get), (do_Cairo_Surface_create_window): Handle window delete more gracefully; report exception on drawing, report 'delete' event to event reader. Have default surface creation code re-create a surface when the old default surface has been destroyed. @ text @d1 1 a1 1 /* $Id: cairo.5c,v 1.7 2004/12/23 22:39:40 keithp Exp $ d70 2 d78 15 a92 8 Mutex::acquire (m); union switch (surface) { case none: string name = (dim (argv) > 0) ? argv[0] : "nickle"; surface.surface = Surface::create_window (name, w, h); break; case surface: break; a93 1 Mutex::release (m); a95 2 cairo_t cr = create (); a98 1 set_target_surface (cr, surface.surface); a101 1 set_target_surface (cr, surface.surface); d103 11 a125 1 set_target_surface (cr, surface); d128 1 d131 1 a144 1 set_target_surface (cr, surface); @ 1.7 log @2004-12-23 Keith Packard * Makefile.am: * cairo-5c.h: * cairo.5c: * cairo.c: (cairo_5c_get), (cairo_5c_mark), (cairo_5c_free), (cairo_foreign_mark), (cairo_foreign_free), (do_Cairo_create), (cairo_5c_dirty), (cairo_5c_enable), (cairo_5c_disable), (do_Cairo_set_target_surface), (do_Cairo_current_target_surface), (do_Cairo_destroy), (do_Cairo_copy), (do_Cairo_status), (do_Cairo_status_string), (do_Cairo_enable), (do_Cairo_disable): * draw.c: (do_Cairo_new_path), (do_Cairo_move_to), (do_Cairo_line_to), (do_Cairo_curve_to), (do_Cairo_arc), (do_Cairo_arc_negative), (do_Cairo_rel_move_to), (do_Cairo_rel_line_to), (do_Cairo_rel_curve_to), (do_Cairo_rectangle), (do_Cairo_close_path), (do_Cairo_fill), (do_Cairo_stroke), (do_Cairo_in_stroke), (do_Cairo_in_fill), (do_Cairo_stroke_extents), (do_Cairo_fill_extents), (do_Cairo_current_path_list), (do_Cairo_current_path_flat_list): * event.c: (do_Cairo_Surface_open_event): * examples/draw.5c: * examples/graph.5c: * examples/grid.5c: * examples/rottext.5c: * gstate.c: (do_Cairo_save), (do_Cairo_restore), (do_Cairo_set_operator), (do_Cairo_set_rgb_color), (do_Cairo_set_alpha), (do_Cairo_set_tolerance), (do_Cairo_set_fill_rule), (do_Cairo_set_line_width), (do_Cairo_set_line_cap), (do_Cairo_set_line_join), (do_Cairo_set_dash), (do_Cairo_set_miter_limit), (do_Cairo_identity_matrix), (do_Cairo_default_matrix), (do_Cairo_translate), (do_Cairo_scale), (do_Cairo_rotate), (do_Cairo_current_matrix), (do_Cairo_concat_matrix), (do_Cairo_set_matrix), (do_Cairo_transform_point), (do_Cairo_transform_distance), (do_Cairo_inverse_transform_point), (do_Cairo_inverse_transform_distance), (do_Cairo_init_clip), (do_Cairo_clip), (do_Cairo_current_operator), (do_Cairo_current_rgb_color), (do_Cairo_current_alpha), (do_Cairo_current_tolerance), (do_Cairo_current_point), (do_Cairo_current_fill_rule), (do_Cairo_current_line_width), (do_Cairo_current_line_cap), (do_Cairo_current_line_join), (do_Cairo_current_miter_limit): * gtk.c: (configure_event), (expose_event), (delete_drawing_area), (delete_event), (motion_notify_event), (button_press_event), (button_release_event), (gtk_repaint), (gtk_repaint_timeout), (gtk_global_mark), (gtk_global_free), (create_gtk_global), (gtk_tool_mark), (gtk_tool_free), (cairo_5c_tool_create), (cairo_5c_tool_destroy), (cairo_5c_tool_mark), (cairo_5c_tool_dirty), (cairo_5c_tool_disable), (cairo_5c_tool_enable), (cairo_5c_tool_display): * init.c: (init_types), (nickle_init): * pattern.c: (mark_cairo_pattern), (make_pattern_value), (do_Cairo_set_pattern), (do_Cairo_current_pattern), (do_Cairo_Pattern_create_for_surface): * surface.c: (create_cairo_window), (cairo_5c_surface_get), (cairo_5c_surface_mark), (cairo_5c_surface_free), (cairo_surface_foreign_mark), (cairo_surface_foreign_free), (do_Cairo_Surface_create_window), (do_Cairo_Surface_create_png), (do_Cairo_Surface_create_ps), (do_Cairo_Surface_create_similar), (do_Cairo_Surface_destroy), (do_Cairo_Surface_width), (do_Cairo_Surface_height): * text.c: (do_Cairo_select_font), (do_Cairo_set_font), (do_Cairo_scale_font), (do_Cairo_transform_font), (do_Cairo_current_font_extents), (do_Cairo_show_text), (do_Cairo_text_path), (do_Cairo_text_extents): Split cairo_t and cairo_surface_t functions apart, permitting more complex programs to be written that use more than a single window. Switch allocations around to mostly use the nickle memory allocator now. Requires updated nickle bits that expose this change in the foreign object API. @ text @d1 1 a1 1 /* $Id: cairo.5c,v 1.6 2004/12/19 00:06:26 keithp Exp $ d62 24 a85 8 static surface_t surface; static bool been_here = false; static mutex m = Mutex::new(); Mutex::acquire (m); if (!been_here) { been_here = true; surface = Surface::create_window (w, h); a86 1 Mutex::release (m); d89 10 a98 1 set_target_surface (cr, surface); @ 1.6 log @2004-12-18 Keith Packard * cairo.5c: Add matrix operations * cairo-5c.h: * text.c: (do_Cairo_set_font), (do_Cairo_transform_font): * init.c: (nickle_init): Add set_font and transform_font interfaces * examples/animate.5c: * examples/pie.5c: use set_font interface * surface.c: (do_Cairo_dup): Duplicate gstate in dup operator @ text @d1 1 a1 1 /* $Id: cairo.5c,v 1.5 2004/12/18 08:16:28 keithp Exp $ d49 73 @ 1.5 log @2004-12-18 Keith Packard * Makefile.am: * cairo.5c: * examples/animate.5c: * examples/draw.5c: * examples/pie.5c: * examples/rottext.5c: Fix examples to match API changes * gstate.c: (do_Cairo_transform_point), (do_Cairo_transform_distance), (do_Cairo_inverse_transform_point), (do_Cairo_inverse_transform_distance): transforms take point_t, return point_t * cairo-5c.h: * init.c: (nickle_init): * pattern.c: (do_Cairo_Pattern_create_for_surface), (premultiply_data), (create_surface_from_png), (do_Cairo_Pattern_create_png): * surface.c: (get_cairo_5c), (free_cairo_5c), (dirty_cairo_5c), (enable_cairo_5c), (disable_cairo_5c), (do_Cairo_new_png), (do_Cairo_new_scratch), (do_Cairo_dup), (do_Cairo_status): Add png loading, scratch surfaces and surface patterns @ text @d1 1 a1 1 /* $Id: cairo.5c,v 1.4 2004/12/18 01:09:40 keithp Exp $ d186 61 @ 1.4 log @2004-12-17 Keith Packard * Makefile.am: * cairo-5c.h: * cairo.5c: * gstate.c: (do_Cairo_set_alpha), (do_Cairo_current_matrix), (do_Cairo_set_matrix): * init.c: (make_typedef), (init_types), (nickle_init): * matrix.c: (cairo_matrix_part), (new_cairo_matrix): * pattern.c: (get_cairo_pattern), (free_cairo_pattern), (make_pattern_value), (do_Cairo_set_pattern), (do_Cairo_current_pattern), (do_Cairo_Pattern_create_linear), (do_Cairo_Pattern_create_radial), (do_Cairo_Pattern_add_color_stop), (do_Cairo_Pattern_set_matrix), (do_Cairo_Pattern_get_matrix), (do_Cairo_Pattern_set_extend), (do_Cairo_Pattern_get_extend), (do_Cairo_Pattern_set_filter), (do_Cairo_Pattern_get_filter): Add gradient pattern support. Split out matrix support to share. @ text @d1 1 a1 1 /* $Id: cairo.5c,v 1.3 2004/12/17 09:50:16 keithp Exp $ d45 3 d159 6 d169 8 a176 1 public real[3] current_hsv_color (cairo_t cr) d178 7 a184 1 return to_hsv (current_rgb_color (cr) ...); @ 1.3 log @2004-12-17 Keith Packard * cairo.5c: Add HSV color space routine to cairo.5c @ text @d1 1 a1 1 /* $Id: cairo.5c,v 1.2 2004/12/17 09:40:43 keithp Exp $ d157 6 a162 1 Cairo::set_rgb_color (cr, from_hsv (h, s, v) ...); @ 1.2 log @2004-12-17 Keith Packard * cairo-5c.h: * cairo.5c: * draw.c: (path_new), (path_box), (cairo_5c_move_to), (cairo_5c_line_to), (cairo_5c_curve_to), (cairo_5c_close_path), (do_Cairo_current_path_list), (do_Cairo_current_path_flat_list): * init.c: (make_typedef), (init_types), (nickle_init): * surface.c: (get_cairo_5c): Add current_path/current_path_flat by creating nickle structure in C code holding the entire path and walking it in nickle code. * examples/.cvsignore: ignore build files @ text @d1 1 a1 1 /* $Id: cairo.5c,v 1.1 2004/12/17 02:09:45 keithp Exp $ d108 51 a159 1 @ 1.1 log @2004-12-16 Keith Packard * Makefile.am: * autogen.sh: * cairo.5c: * configure.in: Add cairo.5c and install it to nickle libary * cairo-5c.h: * draw.c: (do_Cairo_rectangle), (do_Cairo_in_stroke), (do_Cairo_in_fill), (do_Cairo_stroke_extents), (do_Cairo_fill_extents), (cairo_5c_move_to), (do_Cairo_current_path), (do_Cairo_current_path_flat): * gstate.c: (do_Cairo_set_operator), (do_Cairo_set_fill_rule), (do_Cairo_set_line_cap), (do_Cairo_set_line_join), (do_Cairo_set_dash), (do_Cairo_set_miter_limit), (do_Cairo_default_matrix), (do_Cairo_transform_point), (do_Cairo_transform_distance), (do_Cairo_inverse_transform_point), (do_Cairo_inverse_transform_distance), (do_Cairo_init_clip), (do_Cairo_clip), (do_Cairo_current_operator), (do_Cairo_current_rgb_color), (do_Cairo_current_alpha), (do_Cairo_current_tolerance), (do_Cairo_current_point), (do_Cairo_current_fill_rule), (do_Cairo_current_line_width), (do_Cairo_current_line_cap), (do_Cairo_current_line_join), (do_Cairo_current_miter_limit): * init.c: (make_typedef), (init_types), (EnumIntPart), (IntToEnum), (nickle_init): * text.c: (do_Cairo_select_font), (do_Cairo_text_extents), (do_Cairo_select_ft_font): Add a bunch more bindings. Still more to do, especially the path walkers. Switch from int constants to enums for enumerated types. * gtk.c: (motion_notify_event), (button_press_event), (button_release_event), (cairo_5c_window_new): * surface.c: (do_Cairo_new): Add mouse input support. * examples/animate.5c: * examples/cairo.5c: * examples/draw.5c: * examples/graph.5c: * examples/pie.5c: * examples/rottext.5c: * examples/sin.5c: * examples/test.5c: Change examples to use cairo.5c file with autoimport @ text @d1 1 a1 1 /* $Id: $ d40 68 @