diff options
author | Keith Packard <keithp@keithp.com> | 2005-05-18 06:21:15 +0000 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2005-05-18 06:21:15 +0000 |
commit | 8c05c722441014b1bf2cf8b5bbbfa33173d59265 (patch) | |
tree | 29edc336b93916db6f51db20619db96d16f967d7 /examples | |
parent | 25f0ae0c8e3faaa56cfbf630138292e1c9fe47e1 (diff) |
Another round of API changes for cairo 0.5, the putative final API structure.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/animate.5c | 9 | ||||
-rw-r--r-- | examples/draw.5c | 2 | ||||
-rw-r--r-- | examples/fob.5c | 4 | ||||
-rw-r--r-- | examples/metrics.5c | 2 | ||||
-rw-r--r-- | examples/sin.5c | 15 | ||||
-rw-r--r-- | examples/spin.5c | 12 | ||||
-rw-r--r-- | examples/spinman.5c | 14 | ||||
-rw-r--r-- | examples/test.5c | 5 |
8 files changed, 23 insertions, 40 deletions
diff --git a/examples/animate.5c b/examples/animate.5c index e8e4a12..e8cbe71 100644 --- a/examples/animate.5c +++ b/examples/animate.5c @@ -39,7 +39,7 @@ autoimport Cairo; void clear (cairo_t cr) { save (cr); identity_matrix (cr); - set_rgb_color (cr, 1, 1, 1); + set_source_rgb (cr, 1, 1, 1); int w = width (cr); int h = height (cr); move_to (cr, 0, 0); @@ -62,11 +62,10 @@ void rectangle (cairo_t cr, real x, real y, real w, real h) void picture (cairo_t cr) { save (cr); - set_rgb_color (cr, 0.6, .6, 1); + set_source_rgb (cr, 0.6, .6, 1); move_to (cr, -10, 18); show_text (cr, "nickle"); - set_rgb_color (cr, 0, 0, 0); - set_alpha (cr, 0.5); + set_source_rgba (cr, 0, 0, 0, 0.5); rotate (cr, pi/2); move_to (cr, -10, -5); show_text (cr, "cairo"); @@ -88,7 +87,7 @@ void animate (cairo_t cr, int n, int m) disable (cr); save (cr); translate (cr, n * 100, m * 100); - set_rgb_color (cr, 1, 1, 1); + set_source_rgb (cr, 1, 1, 1); rectangle (cr, 0, 0, 100, 100); fill (cr); transform (cr, t); diff --git a/examples/draw.5c b/examples/draw.5c index 5ca8501..e0f6915 100644 --- a/examples/draw.5c +++ b/examples/draw.5c @@ -47,7 +47,7 @@ void draw (cairo_t cr) void transform_inplace (&real x, &real y) { - point_t a = inverse_transform_point (cr, (point_t) { x = x, y = y }); + point_t a = device_to_user (cr, (point_t) { x = x, y = y }); x = a.x; y = a.y; } diff --git a/examples/fob.5c b/examples/fob.5c index 542fe3f..5219f00 100644 --- a/examples/fob.5c +++ b/examples/fob.5c @@ -53,7 +53,7 @@ void fob (cairo_t cr) Pattern::add_color_stop (pat, 0, 1, 1, 1, 1); Pattern::add_color_stop (pat, 1, 1, .8, .6, 1); set_source (cr, pat); - fill (cr); + fill_preserve (cr); restore (cr); scale (cr, 1/3.5, 1/4); stroke (cr); @@ -148,7 +148,7 @@ void fob (cairo_t cr) void letters (cairo_t cr) { save (cr); - select_font (cr, "sans", font_slant_t.NORMAL, font_weight_t.NORMAL); + select_font_face (cr, "sans", font_slant_t.NORMAL, font_weight_t.NORMAL); set_font_size (cr, 40); rotate (cr, 90 * pi / 180); translate (cr, 12, -20); diff --git a/examples/metrics.5c b/examples/metrics.5c index c3a8746..69cbe73 100644 --- a/examples/metrics.5c +++ b/examples/metrics.5c @@ -36,7 +36,7 @@ autoimport Cairo; cairo_t cr = new (); -scale_font (cr, 12); +set_font_size (cr, 12); for (t = 0; t <= 2 * pi; t += .1) #t = -45 * pi / 180; #t = 0; diff --git a/examples/sin.5c b/examples/sin.5c index 88cc97f..9751f31 100644 --- a/examples/sin.5c +++ b/examples/sin.5c @@ -35,22 +35,7 @@ autoimport Cairo; -void clear (foreign cr) { - save (cr); - identity_matrix (cr); - set_source_rgb (cr, 1, 1, 1); - int w = width (cr); - int h = height (cr); - move_to (cr, 0, 0); - line_to (cr, w, 0); - line_to (cr, w, h); - line_to (cr, 0, h); - fill (cr); - restore (cr); -} - void draw_sin (foreign cr) { - clear (cr); set_line_width (cr, sqrt (width(cr)**2 + height(cr)**2) * 0.01); save (cr); translate (cr, width(cr)/2, height(cr)/2); diff --git a/examples/spin.5c b/examples/spin.5c index e7ae346..ad3f4fa 100644 --- a/examples/spin.5c +++ b/examples/spin.5c @@ -78,10 +78,6 @@ void transform (cairo_t cr, real t) void animate (cairo_t cr) { - cairo_t crl = create (); - set_target_surface (crl, get_target_surface (cr)); - set_font (crl, "sans-12"); - set_source_rgb (crl, 0, 0, 0); real t = 0; for (;;) { @@ -90,8 +86,12 @@ void animate (cairo_t cr) translate (cr, 100, 100); set_source_rgb (cr, 1, 1, 1); clear (cr); - move_to (crl, 3, 20); - show_text (crl, sprintf ("%5.2f", t)); + save (cr); + set_font (cr, "sans-12"); + move_to (cr, 3, 20); + set_source_rgb (cr, 0, 0, 0); + show_text (cr, sprintf ("%5.2f", t)); + restore (cr); transform (cr, t); picture (cr); restore (cr); diff --git a/examples/spinman.5c b/examples/spinman.5c index 7b7cbfa..4fc18ee 100644 --- a/examples/spinman.5c +++ b/examples/spinman.5c @@ -95,7 +95,7 @@ read_event (file f, cairo_t cr) void transform_inplace (&real x, &real y) { - point_t a = inverse_transform_point (cr, (point_t) { x = x, y = y }); + point_t a = device_to_user (cr, (point_t) { x = x, y = y }); x = a.x; y = a.y; } @@ -125,10 +125,6 @@ read_event (file f, cairo_t cr) void animate (cairo_t cr) { - cairo_t crl = create (); - set_target_surface (crl, get_target_surface (cr)); - set_font (crl, "sans-12"); - set_source_rgb (crl, 0, 0, 0); translate (cr, 150, 150); real t = 0; bool down = false; @@ -155,8 +151,12 @@ void animate (cairo_t cr) disable (cr); save (cr); clear (cr); - move_to (crl, 3, 20); - show_text (crl, sprintf ("%5.2f", t)); + save (cr); + set_font (cr, "sans-12"); + set_source_rgb (cr, 0, 0, 0); + move_to (cr, 3, 20); + show_text (cr, sprintf ("%5.2f", t)); + restore (cr); rotate (cr, t); picture (cr); restore (cr); diff --git a/examples/test.5c b/examples/test.5c index 9dd4987..adfe34d 100644 --- a/examples/test.5c +++ b/examples/test.5c @@ -41,8 +41,7 @@ move_to (cr, 10, 10); line_to (cr, 100, 100); stroke (cr); move_to (cr, 50, 50); -set_source_rgb (cr, 0.8, 0, 0.5); -set_alpha (cr, 0.5); -scale_font (cr, 12); +set_source_rgba (cr, 0.8, 0, 0.5, 0.5); +set_font_size (cr, 12); show_text (cr, "Hello, cairo"); sleep (100000); |