cairo 1.8.3-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of cairo might be problematic. Click here for more details.
- data/AUTHORS +4 -0
- data/COPYING +59 -0
- data/GPL +340 -0
- data/NEWS +163 -0
- data/Rakefile +190 -0
- data/doc/doc.css +91 -0
- data/doc/en/cairo-antialias.html +38 -0
- data/doc/en/cairo-clip-not-representable-error.html +47 -0
- data/doc/en/cairo-color-base.html +69 -0
- data/doc/en/cairo-color-cmyk.html +157 -0
- data/doc/en/cairo-color-hsv.html +137 -0
- data/doc/en/cairo-color-rgb.html +142 -0
- data/doc/en/cairo-color-x11.html +173 -0
- data/doc/en/cairo-color.html +238 -0
- data/doc/en/cairo-content.html +37 -0
- data/doc/en/cairo-context-blur.html +39 -0
- data/doc/en/cairo-context-circle.html +39 -0
- data/doc/en/cairo-context-color.html +39 -0
- data/doc/en/cairo-context-path.html +44 -0
- data/doc/en/cairo-context-rectangle.html +39 -0
- data/doc/en/cairo-context-triangle.html +39 -0
- data/doc/en/cairo-context.html +643 -0
- data/doc/en/cairo-error.html +44 -0
- data/doc/en/cairo-extend.html +38 -0
- data/doc/en/cairo-file-not-found.html +47 -0
- data/doc/en/cairo-fill-rule.html +36 -0
- data/doc/en/cairo-filter.html +40 -0
- data/doc/en/cairo-font-extents.html +129 -0
- data/doc/en/cairo-font-face.html +38 -0
- data/doc/en/cairo-font-options.html +139 -0
- data/doc/en/cairo-font-slant.html +37 -0
- data/doc/en/cairo-font-type-mismatch.html +47 -0
- data/doc/en/cairo-font-weight.html +36 -0
- data/doc/en/cairo-format.html +46 -0
- data/doc/en/cairo-glyph.html +99 -0
- data/doc/en/cairo-gradient-pattern.html +74 -0
- data/doc/en/cairo-hint-metrics.html +37 -0
- data/doc/en/cairo-hint-style.html +39 -0
- data/doc/en/cairo-image-surface.html +82 -0
- data/doc/en/cairo-invalid-clusters.html +47 -0
- data/doc/en/cairo-invalid-content-error.html +47 -0
- data/doc/en/cairo-invalid-dash-error.html +47 -0
- data/doc/en/cairo-invalid-dsc-comment-error.html +47 -0
- data/doc/en/cairo-invalid-format-error.html +47 -0
- data/doc/en/cairo-invalid-index-error.html +47 -0
- data/doc/en/cairo-invalid-matrix-error.html +47 -0
- data/doc/en/cairo-invalid-path-data-error.html +47 -0
- data/doc/en/cairo-invalid-pop-group-error.html +47 -0
- data/doc/en/cairo-invalid-restore-error.html +47 -0
- data/doc/en/cairo-invalid-slant.html +47 -0
- data/doc/en/cairo-invalid-status-error.html +47 -0
- data/doc/en/cairo-invalid-stride-error.html +47 -0
- data/doc/en/cairo-invalid-string-error.html +47 -0
- data/doc/en/cairo-invalid-visual-error.html +47 -0
- data/doc/en/cairo-invalid-weight.html +47 -0
- data/doc/en/cairo-line-cap.html +37 -0
- data/doc/en/cairo-line-join.html +37 -0
- data/doc/en/cairo-linear-pattern.html +60 -0
- data/doc/en/cairo-matrix.html +259 -0
- data/doc/en/cairo-negative-count.html +47 -0
- data/doc/en/cairo-no-current-point-error.html +47 -0
- data/doc/en/cairo-null-pointer-error.html +47 -0
- data/doc/en/cairo-operator.html +48 -0
- data/doc/en/cairo-paper-parse-error.html +47 -0
- data/doc/en/cairo-paper-unknown-paper-name.html +66 -0
- data/doc/en/cairo-paper-unknown-unit.html +66 -0
- data/doc/en/cairo-paper-unrecognized-paper-description.html +66 -0
- data/doc/en/cairo-paper.html +184 -0
- data/doc/en/cairo-path-close-path.html +49 -0
- data/doc/en/cairo-path-curve-to.html +49 -0
- data/doc/en/cairo-path-data-type.html +38 -0
- data/doc/en/cairo-path-data.html +98 -0
- data/doc/en/cairo-path-line-to.html +49 -0
- data/doc/en/cairo-path-move-to.html +49 -0
- data/doc/en/cairo-path.html +155 -0
- data/doc/en/cairo-pattern-type-mismatch-error.html +47 -0
- data/doc/en/cairo-pattern.html +99 -0
- data/doc/en/cairo-pdf-surface.html +57 -0
- data/doc/en/cairo-point.html +74 -0
- data/doc/en/cairo-ps-level.html +49 -0
- data/doc/en/cairo-ps-surface.html +92 -0
- data/doc/en/cairo-quartz-image-surface.html +57 -0
- data/doc/en/cairo-quartz-surface.html +57 -0
- data/doc/en/cairo-radial-pattern.html +60 -0
- data/doc/en/cairo-read-error.html +47 -0
- data/doc/en/cairo-rectangle.html +89 -0
- data/doc/en/cairo-scaled-font.html +94 -0
- data/doc/en/cairo-solid-pattern.html +62 -0
- data/doc/en/cairo-subpixel-order.html +39 -0
- data/doc/en/cairo-surface-finished-error.html +47 -0
- data/doc/en/cairo-surface-pattern.html +57 -0
- data/doc/en/cairo-surface-type-mismatch-error.html +47 -0
- data/doc/en/cairo-surface.html +121 -0
- data/doc/en/cairo-svg-surface.html +77 -0
- data/doc/en/cairo-svg-version.html +49 -0
- data/doc/en/cairo-temp-file-error.html +47 -0
- data/doc/en/cairo-text-cluster-flag.html +35 -0
- data/doc/en/cairo-text-cluster.html +84 -0
- data/doc/en/cairo-text-extents.html +144 -0
- data/doc/en/cairo-toy-font-face.html +67 -0
- data/doc/en/cairo-user-font-error.html +47 -0
- data/doc/en/cairo-user-font-face-text-to-glyphs-data.html +94 -0
- data/doc/en/cairo-user-font-face.html +72 -0
- data/doc/en/cairo-user-font-immutable.html +47 -0
- data/doc/en/cairo-win32-printing-surface.html +57 -0
- data/doc/en/cairo-win32-surface.html +62 -0
- data/doc/en/cairo-write-error.html +47 -0
- data/doc/en/cairo.html +131 -0
- data/doc/en/index.html +1154 -0
- data/doc/index.html +18 -0
- data/doc/ja/cairo-antialias.html +57 -0
- data/doc/ja/cairo-clip-not-representable-error.html +56 -0
- data/doc/ja/cairo-color-base.html +75 -0
- data/doc/ja/cairo-color-cmyk.html +152 -0
- data/doc/ja/cairo-color-hsv.html +135 -0
- data/doc/ja/cairo-color-rgb.html +145 -0
- data/doc/ja/cairo-color-x11.html +183 -0
- data/doc/ja/cairo-color.html +317 -0
- data/doc/ja/cairo-content.html +51 -0
- data/doc/ja/cairo-context-blur.html +53 -0
- data/doc/ja/cairo-context-circle.html +54 -0
- data/doc/ja/cairo-context-color.html +52 -0
- data/doc/ja/cairo-context-path.html +77 -0
- data/doc/ja/cairo-context-rectangle.html +60 -0
- data/doc/ja/cairo-context-triangle.html +47 -0
- data/doc/ja/cairo-context.html +1542 -0
- data/doc/ja/cairo-error.html +56 -0
- data/doc/ja/cairo-extend.html +56 -0
- data/doc/ja/cairo-file-not-found.html +51 -0
- data/doc/ja/cairo-fill-rule.html +58 -0
- data/doc/ja/cairo-filter.html +43 -0
- data/doc/ja/cairo-font-extents.html +164 -0
- data/doc/ja/cairo-font-face.html +55 -0
- data/doc/ja/cairo-font-options.html +189 -0
- data/doc/ja/cairo-font-slant.html +50 -0
- data/doc/ja/cairo-font-type-mismatch.html +52 -0
- data/doc/ja/cairo-font-weight.html +47 -0
- data/doc/ja/cairo-format.html +81 -0
- data/doc/ja/cairo-glyph.html +115 -0
- data/doc/ja/cairo-gradient-pattern.html +119 -0
- data/doc/ja/cairo-hint-metrics.html +57 -0
- data/doc/ja/cairo-hint-style.html +64 -0
- data/doc/ja/cairo-image-surface.html +131 -0
- data/doc/ja/cairo-invalid-clusters.html +55 -0
- data/doc/ja/cairo-invalid-content-error.html +54 -0
- data/doc/ja/cairo-invalid-dash-error.html +54 -0
- data/doc/ja/cairo-invalid-dsc-comment-error.html +54 -0
- data/doc/ja/cairo-invalid-format-error.html +54 -0
- data/doc/ja/cairo-invalid-index-error.html +54 -0
- data/doc/ja/cairo-invalid-matrix-error.html +54 -0
- data/doc/ja/cairo-invalid-path-data-error.html +54 -0
- data/doc/ja/cairo-invalid-pop-group-error.html +54 -0
- data/doc/ja/cairo-invalid-restore-error.html +55 -0
- data/doc/ja/cairo-invalid-slant.html +57 -0
- data/doc/ja/cairo-invalid-status-error.html +55 -0
- data/doc/ja/cairo-invalid-stride-error.html +55 -0
- data/doc/ja/cairo-invalid-string-error.html +54 -0
- data/doc/ja/cairo-invalid-visual-error.html +57 -0
- data/doc/ja/cairo-invalid-weight.html +57 -0
- data/doc/ja/cairo-line-cap.html +50 -0
- data/doc/ja/cairo-line-join.html +53 -0
- data/doc/ja/cairo-linear-pattern.html +87 -0
- data/doc/ja/cairo-matrix.html +354 -0
- data/doc/ja/cairo-negative-count.html +52 -0
- data/doc/ja/cairo-no-current-point-error.html +54 -0
- data/doc/ja/cairo-null-pointer-error.html +54 -0
- data/doc/ja/cairo-operator.html +51 -0
- data/doc/ja/cairo-paper-parse-error.html +55 -0
- data/doc/ja/cairo-paper-unknown-paper-name.html +76 -0
- data/doc/ja/cairo-paper-unknown-unit.html +75 -0
- data/doc/ja/cairo-paper-unrecognized-paper-description.html +76 -0
- data/doc/ja/cairo-paper.html +357 -0
- data/doc/ja/cairo-path-close-path.html +57 -0
- data/doc/ja/cairo-path-curve-to.html +70 -0
- data/doc/ja/cairo-path-data-type.html +53 -0
- data/doc/ja/cairo-path-data.html +127 -0
- data/doc/ja/cairo-path-line-to.html +62 -0
- data/doc/ja/cairo-path-move-to.html +62 -0
- data/doc/ja/cairo-path.html +144 -0
- data/doc/ja/cairo-pattern-type-mismatch-error.html +56 -0
- data/doc/ja/cairo-pattern.html +128 -0
- data/doc/ja/cairo-pdf-surface.html +86 -0
- data/doc/ja/cairo-point.html +90 -0
- data/doc/ja/cairo-ps-level.html +62 -0
- data/doc/ja/cairo-ps-surface.html +214 -0
- data/doc/ja/cairo-quartz-image-surface.html +75 -0
- data/doc/ja/cairo-quartz-surface.html +93 -0
- data/doc/ja/cairo-radial-pattern.html +93 -0
- data/doc/ja/cairo-read-error.html +55 -0
- data/doc/ja/cairo-rectangle.html +109 -0
- data/doc/ja/cairo-scaled-font.html +180 -0
- data/doc/ja/cairo-solid-pattern.html +87 -0
- data/doc/ja/cairo-subpixel-order.html +57 -0
- data/doc/ja/cairo-surface-finished-error.html +54 -0
- data/doc/ja/cairo-surface-pattern.html +68 -0
- data/doc/ja/cairo-surface-type-mismatch-error.html +56 -0
- data/doc/ja/cairo-surface.html +213 -0
- data/doc/ja/cairo-svg-surface.html +114 -0
- data/doc/ja/cairo-svg-version.html +66 -0
- data/doc/ja/cairo-temp-file-error.html +50 -0
- data/doc/ja/cairo-text-cluster-flag.html +46 -0
- data/doc/ja/cairo-text-cluster.html +102 -0
- data/doc/ja/cairo-text-extents.html +163 -0
- data/doc/ja/cairo-toy-font-face.html +107 -0
- data/doc/ja/cairo-user-font-error.html +55 -0
- data/doc/ja/cairo-user-font-face-text-to-glyphs-data.html +156 -0
- data/doc/ja/cairo-user-font-face.html +268 -0
- data/doc/ja/cairo-user-font-immutable.html +54 -0
- data/doc/ja/cairo-win32-printing-surface.html +80 -0
- data/doc/ja/cairo-win32-surface.html +100 -0
- data/doc/ja/cairo-write-error.html +55 -0
- data/doc/ja/cairo.html +177 -0
- data/doc/ja/index.html +1156 -0
- data/ext/cairo/cairo.def +104 -0
- data/ext/cairo/extconf.rb +80 -0
- data/ext/cairo/rb_cairo.c +104 -0
- data/ext/cairo/rb_cairo.h +275 -0
- data/ext/cairo/rb_cairo_constants.c +478 -0
- data/ext/cairo/rb_cairo_context.c +1693 -0
- data/ext/cairo/rb_cairo_exception.c +354 -0
- data/ext/cairo/rb_cairo_font_extents.c +200 -0
- data/ext/cairo/rb_cairo_font_face.c +713 -0
- data/ext/cairo/rb_cairo_font_options.c +197 -0
- data/ext/cairo/rb_cairo_glyph.c +161 -0
- data/ext/cairo/rb_cairo_matrix.c +366 -0
- data/ext/cairo/rb_cairo_path.c +459 -0
- data/ext/cairo/rb_cairo_pattern.c +540 -0
- data/ext/cairo/rb_cairo_private.c +242 -0
- data/ext/cairo/rb_cairo_private.h +114 -0
- data/ext/cairo/rb_cairo_scaled_font.c +235 -0
- data/ext/cairo/rb_cairo_surface.c +1371 -0
- data/ext/cairo/rb_cairo_text_cluster.c +151 -0
- data/ext/cairo/rb_cairo_text_extents.c +221 -0
- data/extconf.rb +45 -0
- data/lib/1.8/cairo.so +0 -0
- data/lib/1.9/cairo.so +0 -0
- data/lib/cairo.rb +151 -0
- data/lib/cairo/color.rb +267 -0
- data/lib/cairo/colors.rb +656 -0
- data/lib/cairo/constants.rb +24 -0
- data/lib/cairo/context.rb +29 -0
- data/lib/cairo/context/blur.rb +45 -0
- data/lib/cairo/context/circle.rb +9 -0
- data/lib/cairo/context/color.rb +11 -0
- data/lib/cairo/context/path.rb +116 -0
- data/lib/cairo/context/rectangle.rb +33 -0
- data/lib/cairo/context/triangle.rb +12 -0
- data/lib/cairo/paper.rb +183 -0
- data/lib/cairo/papers.rb +41 -0
- data/lib/cairo/path.rb +15 -0
- data/lib/cairo/point.rb +7 -0
- data/misc/update-colors.rb +143 -0
- data/pkg-config.rb +313 -0
- data/samples/agg/README +4 -0
- data/samples/agg/aa_test.rb +304 -0
- data/samples/blur.rb +47 -0
- data/samples/pac.rb +99 -0
- data/samples/pac2.rb +171 -0
- data/samples/png.rb +45 -0
- data/samples/scalable.rb +56 -0
- data/samples/text-on-path.rb +60 -0
- data/samples/text2.rb +131 -0
- data/test-unit/Rakefile +30 -0
- data/test-unit/bin/testrb +5 -0
- data/test-unit/lib/test/unit.rb +280 -0
- data/test-unit/lib/test/unit/assertionfailederror.rb +14 -0
- data/test-unit/lib/test/unit/assertions.rb +722 -0
- data/test-unit/lib/test/unit/attribute.rb +125 -0
- data/test-unit/lib/test/unit/autorunner.rb +254 -0
- data/test-unit/lib/test/unit/collector.rb +43 -0
- data/test-unit/lib/test/unit/collector/descendant.rb +23 -0
- data/test-unit/lib/test/unit/collector/dir.rb +108 -0
- data/test-unit/lib/test/unit/collector/load.rb +135 -0
- data/test-unit/lib/test/unit/collector/objectspace.rb +34 -0
- data/test-unit/lib/test/unit/color.rb +61 -0
- data/test-unit/lib/test/unit/diff.rb +524 -0
- data/test-unit/lib/test/unit/error.rb +124 -0
- data/test-unit/lib/test/unit/exceptionhandler.rb +39 -0
- data/test-unit/lib/test/unit/failure.rb +110 -0
- data/test-unit/lib/test/unit/fixture.rb +185 -0
- data/test-unit/lib/test/unit/notification.rb +125 -0
- data/test-unit/lib/test/unit/omission.rb +143 -0
- data/test-unit/lib/test/unit/pending.rb +146 -0
- data/test-unit/lib/test/unit/priority.rb +146 -0
- data/test-unit/lib/test/unit/runner/console.rb +46 -0
- data/test-unit/lib/test/unit/runner/emacs.rb +8 -0
- data/test-unit/lib/test/unit/testcase.rb +281 -0
- data/test-unit/lib/test/unit/testresult.rb +89 -0
- data/test-unit/lib/test/unit/testsuite.rb +110 -0
- data/test-unit/lib/test/unit/ui/console/outputlevel.rb +14 -0
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +195 -0
- data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +49 -0
- data/test-unit/lib/test/unit/ui/testrunner.rb +20 -0
- data/test-unit/lib/test/unit/ui/testrunnermediator.rb +77 -0
- data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +41 -0
- data/test-unit/lib/test/unit/util/backtracefilter.rb +41 -0
- data/test-unit/lib/test/unit/util/observable.rb +90 -0
- data/test-unit/lib/test/unit/util/procwrapper.rb +48 -0
- data/test-unit/lib/test/unit/version.rb +7 -0
- data/test-unit/sample/adder.rb +13 -0
- data/test-unit/sample/subtracter.rb +12 -0
- data/test-unit/sample/tc_adder.rb +18 -0
- data/test-unit/sample/tc_subtracter.rb +18 -0
- data/test-unit/sample/ts_examples.rb +7 -0
- data/test-unit/test/collector/test_descendant.rb +135 -0
- data/test-unit/test/collector/test_dir.rb +406 -0
- data/test-unit/test/collector/test_load.rb +333 -0
- data/test-unit/test/collector/test_objectspace.rb +98 -0
- data/test-unit/test/run-test.rb +13 -0
- data/test-unit/test/test_assertions.rb +693 -0
- data/test-unit/test/test_attribute.rb +86 -0
- data/test-unit/test/test_color.rb +37 -0
- data/test-unit/test/test_diff.rb +477 -0
- data/test-unit/test/test_emacs_runner.rb +60 -0
- data/test-unit/test/test_error.rb +26 -0
- data/test-unit/test/test_failure.rb +33 -0
- data/test-unit/test/test_fixture.rb +252 -0
- data/test-unit/test/test_notification.rb +33 -0
- data/test-unit/test/test_omission.rb +81 -0
- data/test-unit/test/test_pending.rb +70 -0
- data/test-unit/test/test_priority.rb +89 -0
- data/test-unit/test/test_testcase.rb +430 -0
- data/test-unit/test/test_testresult.rb +113 -0
- data/test-unit/test/test_testsuite.rb +129 -0
- data/test-unit/test/testunit_test_util.rb +14 -0
- data/test-unit/test/ui/test_testrunmediator.rb +20 -0
- data/test-unit/test/util/test_backtracefilter.rb +41 -0
- data/test-unit/test/util/test_observable.rb +102 -0
- data/test-unit/test/util/test_procwrapper.rb +36 -0
- data/test/cairo-test-utils.rb +18 -0
- data/test/run-test.rb +28 -0
- data/test/test_color.rb +17 -0
- data/test/test_constants.rb +16 -0
- data/test/test_context.rb +105 -0
- data/test/test_exception.rb +27 -0
- data/test/test_font_extents.rb +36 -0
- data/test/test_font_face.rb +244 -0
- data/test/test_font_options.rb +13 -0
- data/test/test_paper.rb +81 -0
- data/test/test_pkg_config.rb +123 -0
- data/test/test_scaled_font.rb +34 -0
- data/test/test_surface.rb +41 -0
- data/test/test_text_cluster.rb +32 -0
- data/test/test_text_extents.rb +40 -0
- data/test/test_text_to_glyphs_data.rb +51 -0
- data/tmp/x86-mingw32/cairo/1.8.7/fake.rb +6 -0
- data/tmp/x86-mingw32/cairo/1.8.7/mkmf.rb +1836 -0
- data/tmp/x86-mingw32/cairo/1.8.7/rbconfig.rb +183 -0
- data/tmp/x86-mingw32/cairo/1.9.2/fake.rb +6 -0
- data/tmp/x86-mingw32/cairo/1.9.2/mkmf.rb +2079 -0
- data/tmp/x86-mingw32/cairo/1.9.2/rbconfig.rb +226 -0
- metadata +437 -0
@@ -0,0 +1,1693 @@
|
|
1
|
+
/* -*- c-file-style: "gnu"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Ruby Cairo Binding
|
4
|
+
*
|
5
|
+
* $Author: kou $
|
6
|
+
* $Date: 2008-09-26 13:52:08 $
|
7
|
+
*
|
8
|
+
* Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
|
9
|
+
* Copyright 2004-2005 MenTaLguY <mental@rydia.com>
|
10
|
+
*
|
11
|
+
* This file is made available under the same terms as Ruby
|
12
|
+
*
|
13
|
+
*/
|
14
|
+
|
15
|
+
#include "rb_cairo.h"
|
16
|
+
#include "rb_cairo_private.h"
|
17
|
+
|
18
|
+
#ifdef HAVE_RUBY_ST_H
|
19
|
+
# include <ruby/st.h>
|
20
|
+
#else
|
21
|
+
# include <st.h>
|
22
|
+
#endif
|
23
|
+
|
24
|
+
VALUE rb_cCairo_Context;
|
25
|
+
|
26
|
+
static ID cr_id_surface, cr_id_source;
|
27
|
+
static ID cr_id_plus, cr_id_minus, cr_id_multi, cr_id_div;
|
28
|
+
static cairo_user_data_key_t cr_object_holder_key;
|
29
|
+
|
30
|
+
#define _SELF (RVAL2CRCONTEXT(self))
|
31
|
+
|
32
|
+
static VALUE cr_get_current_point (VALUE self);
|
33
|
+
|
34
|
+
#if CAIRO_CHECK_VERSION(1, 3, 0)
|
35
|
+
static VALUE rb_cCairo_Rectangle;
|
36
|
+
static ID at_x, at_y, at_width, at_height;
|
37
|
+
|
38
|
+
static VALUE
|
39
|
+
cr_rectangle_initialize (VALUE self, VALUE x, VALUE y,
|
40
|
+
VALUE width, VALUE height)
|
41
|
+
{
|
42
|
+
rb_ivar_set (self, at_x, x);
|
43
|
+
rb_ivar_set (self, at_y, y);
|
44
|
+
rb_ivar_set (self, at_width, width);
|
45
|
+
rb_ivar_set (self, at_height, height);
|
46
|
+
|
47
|
+
return Qnil;
|
48
|
+
}
|
49
|
+
#endif
|
50
|
+
|
51
|
+
static inline void
|
52
|
+
cr_check_status (cairo_t *context)
|
53
|
+
{
|
54
|
+
rb_cairo_check_status (cairo_status (context));
|
55
|
+
}
|
56
|
+
|
57
|
+
/* Functions for manipulating state objects */
|
58
|
+
cairo_t *
|
59
|
+
rb_cairo_context_from_ruby_object (VALUE obj)
|
60
|
+
{
|
61
|
+
cairo_t *context;
|
62
|
+
if (!rb_cairo__is_kind_of (obj, rb_cCairo_Context))
|
63
|
+
{
|
64
|
+
rb_raise (rb_eTypeError, "not a cairo graphics context");
|
65
|
+
}
|
66
|
+
Data_Get_Struct (obj, cairo_t, context);
|
67
|
+
if (!context)
|
68
|
+
rb_cairo_check_status (CAIRO_STATUS_NULL_POINTER);
|
69
|
+
return context;
|
70
|
+
}
|
71
|
+
|
72
|
+
static rb_cairo__object_holder_t *
|
73
|
+
cr_object_holder_new (VALUE object)
|
74
|
+
{
|
75
|
+
return rb_cairo__object_holder_new (rb_cCairo_Context, object);
|
76
|
+
}
|
77
|
+
|
78
|
+
static void
|
79
|
+
cr_object_holder_free (void *ptr)
|
80
|
+
{
|
81
|
+
rb_cairo__object_holder_free (rb_cCairo_Context, ptr);
|
82
|
+
}
|
83
|
+
|
84
|
+
static void
|
85
|
+
cr_context_free (void *ptr)
|
86
|
+
{
|
87
|
+
if (ptr)
|
88
|
+
{
|
89
|
+
cairo_destroy ((cairo_t *) ptr);
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
VALUE
|
94
|
+
rb_cairo_context_to_ruby_object (cairo_t *cr)
|
95
|
+
{
|
96
|
+
if (cr)
|
97
|
+
{
|
98
|
+
cairo_reference (cr);
|
99
|
+
return Data_Wrap_Struct (rb_cCairo_Context, NULL, cr_context_free, cr);
|
100
|
+
}
|
101
|
+
else
|
102
|
+
{
|
103
|
+
return Qnil;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
static VALUE
|
108
|
+
cr_allocate (VALUE klass)
|
109
|
+
{
|
110
|
+
return Data_Wrap_Struct (klass, NULL, cr_context_free, NULL);
|
111
|
+
}
|
112
|
+
|
113
|
+
static void
|
114
|
+
cr_set_user_data (cairo_t *cr, const cairo_user_data_key_t *key,
|
115
|
+
void *user_data, cairo_destroy_func_t destroy)
|
116
|
+
{
|
117
|
+
#if CAIRO_CHECK_VERSION(1, 4, 0)
|
118
|
+
cairo_set_user_data (cr, key, user_data, destroy);
|
119
|
+
#else
|
120
|
+
cairo_surface_t *surface;
|
121
|
+
surface = cairo_get_target (cr);
|
122
|
+
cairo_surface_set_user_data (surface, key, user_data, destroy);
|
123
|
+
#endif
|
124
|
+
}
|
125
|
+
|
126
|
+
static VALUE
|
127
|
+
cr_destroy (VALUE self)
|
128
|
+
{
|
129
|
+
cairo_t *cr;
|
130
|
+
|
131
|
+
cr = _SELF;
|
132
|
+
cr_set_user_data (cr, &cr_object_holder_key, NULL, NULL);
|
133
|
+
cairo_destroy (cr);
|
134
|
+
|
135
|
+
DATA_PTR (self) = NULL;
|
136
|
+
return Qnil;
|
137
|
+
}
|
138
|
+
|
139
|
+
static VALUE
|
140
|
+
cr_destroy_with_destroy_check (VALUE self)
|
141
|
+
{
|
142
|
+
if (DATA_PTR (self))
|
143
|
+
cr_destroy (self);
|
144
|
+
return Qnil;
|
145
|
+
}
|
146
|
+
|
147
|
+
static VALUE
|
148
|
+
cr_initialize (VALUE self, VALUE target)
|
149
|
+
{
|
150
|
+
cairo_t *cr;
|
151
|
+
VALUE result = Qnil;
|
152
|
+
|
153
|
+
cr = cairo_create (RVAL2CRSURFACE (target));
|
154
|
+
cr_check_status (cr);
|
155
|
+
rb_ivar_set (self, cr_id_surface, target);
|
156
|
+
cr_set_user_data (cr,
|
157
|
+
&cr_object_holder_key,
|
158
|
+
cr_object_holder_new(self),
|
159
|
+
cr_object_holder_free);
|
160
|
+
DATA_PTR (self) = cr;
|
161
|
+
if (rb_block_given_p ())
|
162
|
+
result = rb_ensure (rb_yield, self, cr_destroy_with_destroy_check, self);
|
163
|
+
return result;
|
164
|
+
}
|
165
|
+
|
166
|
+
static VALUE
|
167
|
+
cr_restore (VALUE self)
|
168
|
+
{
|
169
|
+
cairo_restore (_SELF);
|
170
|
+
cr_check_status (_SELF);
|
171
|
+
return Qnil;
|
172
|
+
}
|
173
|
+
|
174
|
+
static VALUE
|
175
|
+
cr_save (VALUE self)
|
176
|
+
{
|
177
|
+
VALUE result = Qnil;
|
178
|
+
cairo_save (_SELF);
|
179
|
+
cr_check_status (_SELF);
|
180
|
+
if (rb_block_given_p ())
|
181
|
+
{
|
182
|
+
result = rb_ensure (rb_yield, self, cr_restore, self);
|
183
|
+
}
|
184
|
+
return result;
|
185
|
+
}
|
186
|
+
|
187
|
+
static VALUE
|
188
|
+
cr_pop_group (VALUE self)
|
189
|
+
{
|
190
|
+
VALUE rb_pattern;
|
191
|
+
cairo_pattern_t *pattern;
|
192
|
+
|
193
|
+
pattern = cairo_pop_group (_SELF);
|
194
|
+
cr_check_status (_SELF);
|
195
|
+
rb_pattern = CRPATTERN2RVAL (pattern);
|
196
|
+
cairo_pattern_destroy (pattern);
|
197
|
+
return rb_pattern;
|
198
|
+
}
|
199
|
+
|
200
|
+
static VALUE
|
201
|
+
cr_pop_group_to_source (VALUE self)
|
202
|
+
{
|
203
|
+
cairo_pop_group_to_source (_SELF);
|
204
|
+
cr_check_status (_SELF);
|
205
|
+
return Qnil;
|
206
|
+
}
|
207
|
+
|
208
|
+
static VALUE
|
209
|
+
cr_pop_group_generic (int argc, VALUE *argv, VALUE self)
|
210
|
+
{
|
211
|
+
VALUE to_source;
|
212
|
+
rb_scan_args (argc, argv, "01", &to_source);
|
213
|
+
if (RVAL2CBOOL (to_source))
|
214
|
+
return cr_pop_group_to_source (self);
|
215
|
+
else
|
216
|
+
return cr_pop_group (self);
|
217
|
+
}
|
218
|
+
|
219
|
+
static VALUE
|
220
|
+
cr_push_group (int argc, VALUE *argv, VALUE self)
|
221
|
+
{
|
222
|
+
VALUE result = Qnil;
|
223
|
+
VALUE content, pop_to_source;
|
224
|
+
rb_scan_args (argc, argv, "02", &content, &pop_to_source);
|
225
|
+
|
226
|
+
if (NIL_P(content))
|
227
|
+
cairo_push_group (_SELF);
|
228
|
+
else
|
229
|
+
cairo_push_group_with_content (_SELF, RVAL2CRCONTENT(content));
|
230
|
+
cr_check_status (_SELF);
|
231
|
+
|
232
|
+
if (rb_block_given_p ())
|
233
|
+
{
|
234
|
+
int state = 0;
|
235
|
+
|
236
|
+
if (NIL_P (pop_to_source))
|
237
|
+
pop_to_source = Qtrue;
|
238
|
+
|
239
|
+
result = rb_protect (rb_yield, self, &state);
|
240
|
+
if (cairo_status(_SELF) == CAIRO_STATUS_SUCCESS)
|
241
|
+
{
|
242
|
+
if (RVAL2CBOOL (pop_to_source))
|
243
|
+
cr_pop_group_to_source (self);
|
244
|
+
else
|
245
|
+
result = cr_pop_group (self);
|
246
|
+
}
|
247
|
+
|
248
|
+
if (state)
|
249
|
+
rb_jump_tag (state);
|
250
|
+
}
|
251
|
+
|
252
|
+
return result;
|
253
|
+
}
|
254
|
+
|
255
|
+
|
256
|
+
/* Modify state */
|
257
|
+
static VALUE
|
258
|
+
cr_set_operator (VALUE self, VALUE operator)
|
259
|
+
{
|
260
|
+
cairo_set_operator (_SELF, RVAL2CROPERATOR (operator));
|
261
|
+
cr_check_status (_SELF);
|
262
|
+
return self;
|
263
|
+
}
|
264
|
+
|
265
|
+
static VALUE
|
266
|
+
cr_set_source_rgb (int argc, VALUE *argv, VALUE self)
|
267
|
+
{
|
268
|
+
VALUE red, green, blue;
|
269
|
+
int n;
|
270
|
+
|
271
|
+
n = rb_scan_args (argc, argv, "12", &red, &green, &blue);
|
272
|
+
|
273
|
+
if (n == 1 && rb_cairo__is_kind_of (red, rb_cArray))
|
274
|
+
{
|
275
|
+
VALUE ary = red;
|
276
|
+
n = RARRAY_LEN (ary);
|
277
|
+
red = rb_ary_entry (ary, 0);
|
278
|
+
green = rb_ary_entry (ary, 1);
|
279
|
+
blue = rb_ary_entry (ary, 2);
|
280
|
+
}
|
281
|
+
|
282
|
+
if (n == 3)
|
283
|
+
{
|
284
|
+
cairo_set_source_rgb (_SELF,
|
285
|
+
NUM2DBL (red),
|
286
|
+
NUM2DBL (green),
|
287
|
+
NUM2DBL (blue));
|
288
|
+
}
|
289
|
+
else
|
290
|
+
{
|
291
|
+
VALUE inspected_arg = rb_inspect (rb_ary_new4 (argc, argv));
|
292
|
+
rb_raise (rb_eArgError,
|
293
|
+
"invalid RGB: %s (expect "
|
294
|
+
"(red, green, blue) or ([red, green, blue]))",
|
295
|
+
StringValuePtr (inspected_arg));
|
296
|
+
}
|
297
|
+
cr_check_status (_SELF);
|
298
|
+
rb_ivar_set (self, cr_id_source, Qnil);
|
299
|
+
return self;
|
300
|
+
}
|
301
|
+
|
302
|
+
static VALUE
|
303
|
+
cr_set_source_rgba (int argc, VALUE *argv, VALUE self)
|
304
|
+
{
|
305
|
+
VALUE red, green, blue, alpha;
|
306
|
+
int n;
|
307
|
+
|
308
|
+
n = rb_scan_args (argc, argv, "13", &red, &green, &blue, &alpha);
|
309
|
+
|
310
|
+
if (n == 1 && rb_cairo__is_kind_of (red, rb_cArray))
|
311
|
+
{
|
312
|
+
VALUE ary = red;
|
313
|
+
n = RARRAY_LEN (ary);
|
314
|
+
red = rb_ary_entry (ary, 0);
|
315
|
+
green = rb_ary_entry (ary, 1);
|
316
|
+
blue = rb_ary_entry (ary, 2);
|
317
|
+
alpha = rb_ary_entry (ary, 3);
|
318
|
+
}
|
319
|
+
|
320
|
+
if (n == 3)
|
321
|
+
{
|
322
|
+
cairo_set_source_rgb (_SELF,
|
323
|
+
NUM2DBL (red),
|
324
|
+
NUM2DBL (green),
|
325
|
+
NUM2DBL (blue));
|
326
|
+
}
|
327
|
+
else if (n == 4)
|
328
|
+
{
|
329
|
+
cairo_set_source_rgba (_SELF,
|
330
|
+
NUM2DBL (red),
|
331
|
+
NUM2DBL (green),
|
332
|
+
NUM2DBL (blue),
|
333
|
+
NUM2DBL (alpha));
|
334
|
+
}
|
335
|
+
else
|
336
|
+
{
|
337
|
+
VALUE inspected_arg = rb_inspect (rb_ary_new4 (argc, argv));
|
338
|
+
rb_raise (rb_eArgError,
|
339
|
+
"invalid RGB%s: %s (expect "
|
340
|
+
"(red, green, blue), (red, green, blue, alpha), "
|
341
|
+
"([red, green, blue]) or ([red, green, blue, alpha]))",
|
342
|
+
n == 4 ? "A" : "",
|
343
|
+
StringValuePtr (inspected_arg));
|
344
|
+
}
|
345
|
+
cr_check_status (_SELF);
|
346
|
+
rb_ivar_set (self, cr_id_source, Qnil);
|
347
|
+
return self;
|
348
|
+
}
|
349
|
+
|
350
|
+
static VALUE
|
351
|
+
cr_set_source_surface (VALUE self, VALUE surface, VALUE width, VALUE height)
|
352
|
+
{
|
353
|
+
cairo_set_source_surface (_SELF,
|
354
|
+
RVAL2CRSURFACE (surface),
|
355
|
+
NUM2DBL (width),
|
356
|
+
NUM2DBL (height));
|
357
|
+
cr_check_status (_SELF);
|
358
|
+
rb_ivar_set (self, cr_id_source, Qnil);
|
359
|
+
return self;
|
360
|
+
}
|
361
|
+
|
362
|
+
static VALUE
|
363
|
+
cr_set_source (VALUE self, VALUE pattern)
|
364
|
+
{
|
365
|
+
cairo_set_source (_SELF, RVAL2CRPATTERN (pattern));
|
366
|
+
cr_check_status (_SELF);
|
367
|
+
rb_ivar_set (self, cr_id_source, pattern);
|
368
|
+
return self;
|
369
|
+
}
|
370
|
+
|
371
|
+
static VALUE
|
372
|
+
cr_set_source_generic (int argc, VALUE *argv, VALUE self)
|
373
|
+
{
|
374
|
+
VALUE arg1, arg2, arg3, arg4;
|
375
|
+
int n;
|
376
|
+
|
377
|
+
n = rb_scan_args (argc, argv, "13", &arg1, &arg2, &arg3, &arg4);
|
378
|
+
|
379
|
+
if (n == 1 && rb_cairo__is_kind_of (arg1, rb_cArray))
|
380
|
+
{
|
381
|
+
return cr_set_source_rgba (argc, argv, self);
|
382
|
+
}
|
383
|
+
else if (n == 1 && rb_cairo__is_kind_of (arg1, rb_cCairo_Surface))
|
384
|
+
{
|
385
|
+
return cr_set_source_surface (self, arg1,
|
386
|
+
rb_float_new (0),
|
387
|
+
rb_float_new (0));
|
388
|
+
}
|
389
|
+
else if (n == 1)
|
390
|
+
{
|
391
|
+
return cr_set_source (self, arg1);
|
392
|
+
}
|
393
|
+
else if (n == 3 && rb_cairo__is_kind_of (arg1, rb_cCairo_Surface))
|
394
|
+
{
|
395
|
+
return cr_set_source_surface (self, arg1, arg2, arg3);
|
396
|
+
}
|
397
|
+
else if (n == 3 || n == 4)
|
398
|
+
{
|
399
|
+
return cr_set_source_rgba (argc, argv, self);
|
400
|
+
}
|
401
|
+
else
|
402
|
+
{
|
403
|
+
rb_raise (rb_eArgError,
|
404
|
+
"invalid argument (expect "
|
405
|
+
"(red, green, blue), (red, green, blue, alpha), "
|
406
|
+
"([red, green, blue]), ([red, green, blue, alpha]), "
|
407
|
+
"(surface), (pattern) or (surface, x, y))");
|
408
|
+
}
|
409
|
+
}
|
410
|
+
|
411
|
+
static VALUE
|
412
|
+
cr_set_tolerance (VALUE self, VALUE tolerance)
|
413
|
+
{
|
414
|
+
cairo_set_tolerance (_SELF, NUM2DBL (tolerance));
|
415
|
+
cr_check_status (_SELF);
|
416
|
+
return self;
|
417
|
+
}
|
418
|
+
|
419
|
+
static VALUE
|
420
|
+
cr_set_antialias(VALUE self, VALUE antialias)
|
421
|
+
{
|
422
|
+
cairo_set_antialias(_SELF, RVAL2CRANTIALIAS (antialias));
|
423
|
+
cr_check_status(_SELF);
|
424
|
+
return self;
|
425
|
+
}
|
426
|
+
|
427
|
+
static VALUE
|
428
|
+
cr_set_fill_rule (VALUE self, VALUE rule)
|
429
|
+
{
|
430
|
+
cairo_set_fill_rule (_SELF, RVAL2CRFILLRULE (rule));
|
431
|
+
cr_check_status (_SELF);
|
432
|
+
return self;
|
433
|
+
}
|
434
|
+
|
435
|
+
static VALUE
|
436
|
+
cr_set_line_width (VALUE self, VALUE width)
|
437
|
+
{
|
438
|
+
cairo_set_line_width (_SELF, NUM2DBL (width));
|
439
|
+
return self;
|
440
|
+
}
|
441
|
+
|
442
|
+
static VALUE
|
443
|
+
cr_set_line_cap (VALUE self, VALUE cap)
|
444
|
+
{
|
445
|
+
cairo_set_line_cap (_SELF, RVAL2CRLINECAP (cap));
|
446
|
+
cr_check_status (_SELF);
|
447
|
+
return self;
|
448
|
+
}
|
449
|
+
|
450
|
+
static VALUE
|
451
|
+
cr_set_line_join (VALUE self, VALUE join)
|
452
|
+
{
|
453
|
+
cairo_set_line_join (_SELF, RVAL2CRLINEJOIN (join));
|
454
|
+
cr_check_status (_SELF);
|
455
|
+
return self;
|
456
|
+
}
|
457
|
+
|
458
|
+
static VALUE
|
459
|
+
cr_set_dash (int argc, VALUE *argv, VALUE self)
|
460
|
+
{
|
461
|
+
VALUE dash_array, rb_offset;
|
462
|
+
double offset;
|
463
|
+
cairo_bool_t is_num;
|
464
|
+
|
465
|
+
rb_scan_args(argc, argv, "11", &dash_array, &rb_offset);
|
466
|
+
|
467
|
+
is_num = rb_cairo__is_kind_of (dash_array, rb_cNumeric);
|
468
|
+
if (!(NIL_P (dash_array) || is_num))
|
469
|
+
{
|
470
|
+
Check_Type (dash_array, T_ARRAY);
|
471
|
+
}
|
472
|
+
|
473
|
+
if (NIL_P (rb_offset))
|
474
|
+
offset = 0.0;
|
475
|
+
else
|
476
|
+
offset = NUM2DBL (rb_offset);
|
477
|
+
|
478
|
+
if (is_num)
|
479
|
+
{
|
480
|
+
double values[1];
|
481
|
+
values[0] = NUM2DBL (dash_array);
|
482
|
+
cairo_set_dash (_SELF, values, 1, offset);
|
483
|
+
}
|
484
|
+
else if (NIL_P (dash_array) || RARRAY_LEN (dash_array) == 0)
|
485
|
+
{
|
486
|
+
cairo_set_dash (_SELF, NULL, 0, offset);
|
487
|
+
}
|
488
|
+
else
|
489
|
+
{
|
490
|
+
int i, length;
|
491
|
+
double *values;
|
492
|
+
length = RARRAY_LEN (dash_array);
|
493
|
+
values = ALLOCA_N (double, length);
|
494
|
+
if (!values)
|
495
|
+
{
|
496
|
+
rb_cairo_check_status (CAIRO_STATUS_NO_MEMORY);
|
497
|
+
}
|
498
|
+
for (i = 0; i < length; i++)
|
499
|
+
{
|
500
|
+
values[i] = NUM2DBL (RARRAY_PTR (dash_array)[i]);
|
501
|
+
}
|
502
|
+
cairo_set_dash (_SELF, values, length, offset);
|
503
|
+
}
|
504
|
+
|
505
|
+
cr_check_status (_SELF);
|
506
|
+
return self;
|
507
|
+
}
|
508
|
+
|
509
|
+
static VALUE
|
510
|
+
cr_set_miter_limit (VALUE self, VALUE limit)
|
511
|
+
{
|
512
|
+
cairo_set_miter_limit (_SELF, NUM2DBL (limit));
|
513
|
+
cr_check_status (_SELF);
|
514
|
+
return self;
|
515
|
+
}
|
516
|
+
|
517
|
+
static VALUE
|
518
|
+
cr_translate (VALUE self, VALUE tx, VALUE ty)
|
519
|
+
{
|
520
|
+
cairo_translate (_SELF, NUM2DBL (tx), NUM2DBL (ty));
|
521
|
+
cr_check_status (_SELF);
|
522
|
+
return self;
|
523
|
+
}
|
524
|
+
|
525
|
+
static VALUE
|
526
|
+
cr_scale (VALUE self, VALUE sx, VALUE sy)
|
527
|
+
{
|
528
|
+
cairo_scale (_SELF, NUM2DBL (sx), NUM2DBL (sy));
|
529
|
+
cr_check_status (_SELF);
|
530
|
+
return self;
|
531
|
+
}
|
532
|
+
|
533
|
+
static VALUE
|
534
|
+
cr_rotate (VALUE self, VALUE radians)
|
535
|
+
{
|
536
|
+
cairo_rotate (_SELF, NUM2DBL (radians));
|
537
|
+
cr_check_status (_SELF);
|
538
|
+
return self;
|
539
|
+
}
|
540
|
+
|
541
|
+
static VALUE
|
542
|
+
cr_transform (VALUE self, VALUE matrix)
|
543
|
+
{
|
544
|
+
cairo_transform (_SELF, RVAL2CRMATRIX (matrix));
|
545
|
+
cr_check_status (_SELF);
|
546
|
+
return self;
|
547
|
+
}
|
548
|
+
|
549
|
+
static VALUE
|
550
|
+
cr_set_matrix (VALUE self, VALUE matrix)
|
551
|
+
{
|
552
|
+
cairo_set_matrix (_SELF, RVAL2CRMATRIX (matrix));
|
553
|
+
cr_check_status (_SELF);
|
554
|
+
return self;
|
555
|
+
}
|
556
|
+
|
557
|
+
static VALUE
|
558
|
+
cr_identity_matrix (VALUE self)
|
559
|
+
{
|
560
|
+
cairo_identity_matrix (_SELF);
|
561
|
+
cr_check_status (_SELF);
|
562
|
+
return self;
|
563
|
+
}
|
564
|
+
|
565
|
+
static VALUE
|
566
|
+
cr_user_to_device (VALUE self, VALUE x, VALUE y)
|
567
|
+
{
|
568
|
+
double pair[2];
|
569
|
+
pair[0] = NUM2DBL (x);
|
570
|
+
pair[1] = NUM2DBL (y);
|
571
|
+
cairo_user_to_device (_SELF, pair, pair + 1);
|
572
|
+
cr_check_status (_SELF);
|
573
|
+
return rb_cairo__float_array (pair, 2);
|
574
|
+
}
|
575
|
+
|
576
|
+
static VALUE
|
577
|
+
cr_user_to_device_distance (VALUE self, VALUE dx, VALUE dy)
|
578
|
+
{
|
579
|
+
double pair[2];
|
580
|
+
pair[0] = NUM2DBL (dx);
|
581
|
+
pair[1] = NUM2DBL (dy);
|
582
|
+
cairo_user_to_device_distance (_SELF, pair, pair + 1);
|
583
|
+
cr_check_status (_SELF);
|
584
|
+
return rb_cairo__float_array (pair, 2);
|
585
|
+
}
|
586
|
+
|
587
|
+
static VALUE
|
588
|
+
cr_device_to_user (VALUE self, VALUE x, VALUE y)
|
589
|
+
{
|
590
|
+
double pair[2];
|
591
|
+
pair[0] = NUM2DBL (x);
|
592
|
+
pair[1] = NUM2DBL (y);
|
593
|
+
cairo_device_to_user (_SELF, pair, pair + 1);
|
594
|
+
cr_check_status (_SELF);
|
595
|
+
return rb_cairo__float_array (pair, 2);
|
596
|
+
}
|
597
|
+
|
598
|
+
static VALUE
|
599
|
+
cr_device_to_user_distance (VALUE self, VALUE dx, VALUE dy)
|
600
|
+
{
|
601
|
+
double pair[2];
|
602
|
+
pair[0] = NUM2DBL (dx);
|
603
|
+
pair[1] = NUM2DBL (dy);
|
604
|
+
cairo_device_to_user_distance (_SELF, pair, pair + 1);
|
605
|
+
cr_check_status (_SELF);
|
606
|
+
return rb_cairo__float_array (pair, 2);
|
607
|
+
}
|
608
|
+
|
609
|
+
|
610
|
+
/* Path creation functions */
|
611
|
+
static VALUE
|
612
|
+
cr_new_path (VALUE self)
|
613
|
+
{
|
614
|
+
cairo_new_path (_SELF);
|
615
|
+
cr_check_status (_SELF);
|
616
|
+
return self;
|
617
|
+
}
|
618
|
+
|
619
|
+
static VALUE
|
620
|
+
cr_move_to (VALUE self, VALUE x, VALUE y)
|
621
|
+
{
|
622
|
+
cairo_move_to (_SELF, NUM2DBL (x), NUM2DBL (y));
|
623
|
+
cr_check_status (_SELF);
|
624
|
+
return self;
|
625
|
+
}
|
626
|
+
|
627
|
+
static VALUE
|
628
|
+
cr_new_sub_path (VALUE self)
|
629
|
+
{
|
630
|
+
cairo_new_sub_path (_SELF);
|
631
|
+
cr_check_status (_SELF);
|
632
|
+
return self;
|
633
|
+
}
|
634
|
+
|
635
|
+
static VALUE
|
636
|
+
cr_line_to (VALUE self, VALUE x, VALUE y)
|
637
|
+
{
|
638
|
+
cairo_line_to (_SELF, NUM2DBL (x), NUM2DBL (y));
|
639
|
+
cr_check_status (_SELF);
|
640
|
+
return self;
|
641
|
+
}
|
642
|
+
|
643
|
+
static VALUE
|
644
|
+
cr_curve_to (VALUE self, VALUE x1, VALUE y1,
|
645
|
+
VALUE x2, VALUE y2, VALUE x3, VALUE y3)
|
646
|
+
{
|
647
|
+
cairo_curve_to (_SELF, NUM2DBL (x1), NUM2DBL (y1),
|
648
|
+
NUM2DBL (x2), NUM2DBL (y2), NUM2DBL (x3), NUM2DBL (y3));
|
649
|
+
cr_check_status (_SELF);
|
650
|
+
return self;
|
651
|
+
}
|
652
|
+
|
653
|
+
static VALUE
|
654
|
+
cr_quadratic_curve_to (VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2)
|
655
|
+
{
|
656
|
+
VALUE current_point, x0, y0, cx1, cy1, cx2, cy2;
|
657
|
+
|
658
|
+
current_point = cr_get_current_point (self);
|
659
|
+
x0 = RARRAY_PTR (current_point)[0];
|
660
|
+
y0 = RARRAY_PTR (current_point)[1];
|
661
|
+
|
662
|
+
/* cx1 = x0 + 2 * ((x1 - x0) / 3.0) */
|
663
|
+
cx1 = rb_funcall (x0, cr_id_plus, 1,
|
664
|
+
rb_funcall (INT2NUM(2), cr_id_multi, 1,
|
665
|
+
rb_funcall (rb_funcall (x1, cr_id_minus, 1, x0),
|
666
|
+
cr_id_div, 1, rb_float_new (3.0))));
|
667
|
+
/* cy1 = y0 + 2 * ((y1 - y0) / 3.0) */
|
668
|
+
cy1 = rb_funcall (y0, cr_id_plus, 1,
|
669
|
+
rb_funcall (INT2NUM(2), cr_id_multi, 1,
|
670
|
+
rb_funcall (rb_funcall (y1, cr_id_minus, 1, y0),
|
671
|
+
cr_id_div, 1, rb_float_new (3.0))));
|
672
|
+
/* cx2 = cx1 + (x2 - x0) / 3.0 */
|
673
|
+
cx2 = rb_funcall (cx1, cr_id_plus, 1,
|
674
|
+
rb_funcall (rb_funcall (x2, cr_id_minus, 1, x0),
|
675
|
+
cr_id_div, 1, rb_float_new (3.0)));
|
676
|
+
/* cy2 = cy1 + (y2 - y0) / 3.0 */
|
677
|
+
cy2 = rb_funcall (cy1, cr_id_plus, 1,
|
678
|
+
rb_funcall (rb_funcall (y2, cr_id_minus, 1, y0),
|
679
|
+
cr_id_div, 1, rb_float_new (3.0)));
|
680
|
+
return cr_curve_to (self, cx1, cy1, cx2, cy2, x2, y2);
|
681
|
+
}
|
682
|
+
|
683
|
+
static VALUE
|
684
|
+
cr_curve_to_generic (int argc, VALUE *argv, VALUE self)
|
685
|
+
{
|
686
|
+
VALUE x1, y1, x2, y2, x3, y3;
|
687
|
+
|
688
|
+
rb_scan_args (argc, argv, "42", &x1, &y1, &x2, &y2, &x3, &y3);
|
689
|
+
|
690
|
+
if (!(argc == 4 || argc == 6))
|
691
|
+
{
|
692
|
+
VALUE inspected_arg = rb_inspect (rb_ary_new4 (argc, argv));
|
693
|
+
rb_raise (rb_eArgError,
|
694
|
+
"invalid argument: %s (expect "
|
695
|
+
"(x1, y1, x2, y2) (quadratic) or "
|
696
|
+
"(x1, y1, x2, y2, x3, y3) (cubic))",
|
697
|
+
StringValuePtr (inspected_arg));
|
698
|
+
}
|
699
|
+
|
700
|
+
if (argc == 4)
|
701
|
+
return cr_quadratic_curve_to (self, x1, y1, x2, y2);
|
702
|
+
else
|
703
|
+
return cr_curve_to (self, x1, y1, x2, y2, x3, y3);
|
704
|
+
}
|
705
|
+
|
706
|
+
static VALUE
|
707
|
+
cr_arc (VALUE self, VALUE xc, VALUE yc, VALUE radius,
|
708
|
+
VALUE angle1, VALUE angle2)
|
709
|
+
{
|
710
|
+
cairo_arc (_SELF, NUM2DBL (xc), NUM2DBL (yc), NUM2DBL (radius),
|
711
|
+
NUM2DBL (angle1), NUM2DBL (angle2));
|
712
|
+
cr_check_status (_SELF);
|
713
|
+
return self;
|
714
|
+
}
|
715
|
+
|
716
|
+
static VALUE
|
717
|
+
cr_arc_negative (VALUE self, VALUE xc, VALUE yc, VALUE radius,
|
718
|
+
VALUE angle1, VALUE angle2)
|
719
|
+
{
|
720
|
+
cairo_arc_negative (_SELF, NUM2DBL (xc), NUM2DBL (yc), NUM2DBL (radius),
|
721
|
+
NUM2DBL (angle1), NUM2DBL (angle2));
|
722
|
+
cr_check_status (_SELF);
|
723
|
+
return self;
|
724
|
+
}
|
725
|
+
|
726
|
+
static VALUE
|
727
|
+
cr_rel_move_to (VALUE self, VALUE x, VALUE y)
|
728
|
+
{
|
729
|
+
cairo_rel_move_to (_SELF, NUM2DBL (x), NUM2DBL (y));
|
730
|
+
cr_check_status (_SELF);
|
731
|
+
return self;
|
732
|
+
}
|
733
|
+
|
734
|
+
static VALUE
|
735
|
+
cr_rel_line_to (VALUE self, VALUE x, VALUE y)
|
736
|
+
{
|
737
|
+
cairo_rel_line_to (_SELF, NUM2DBL (x), NUM2DBL (y));
|
738
|
+
cr_check_status (_SELF);
|
739
|
+
return self;
|
740
|
+
}
|
741
|
+
|
742
|
+
static VALUE
|
743
|
+
cr_rel_curve_to (VALUE self, VALUE dx1, VALUE dy1,
|
744
|
+
VALUE dx2, VALUE dy2, VALUE dx3, VALUE dy3)
|
745
|
+
{
|
746
|
+
cairo_rel_curve_to (_SELF, NUM2DBL (dx1), NUM2DBL (dy1),
|
747
|
+
NUM2DBL (dx2), NUM2DBL (dy2),
|
748
|
+
NUM2DBL (dx3), NUM2DBL (dy3));
|
749
|
+
cr_check_status (_SELF);
|
750
|
+
return self;
|
751
|
+
}
|
752
|
+
|
753
|
+
static VALUE
|
754
|
+
cr_rel_quadratic_curve_to (VALUE self, VALUE dx1, VALUE dy1,
|
755
|
+
VALUE dx2, VALUE dy2)
|
756
|
+
{
|
757
|
+
VALUE current_point, x0, y0;
|
758
|
+
|
759
|
+
current_point = cr_get_current_point (self);
|
760
|
+
x0 = RARRAY_PTR (current_point)[0];
|
761
|
+
y0 = RARRAY_PTR (current_point)[1];
|
762
|
+
return cr_quadratic_curve_to (self,
|
763
|
+
rb_funcall (dx1, cr_id_plus, 1, x0),
|
764
|
+
rb_funcall (dy1, cr_id_plus, 1, y0),
|
765
|
+
rb_funcall (dx2, cr_id_plus, 1, x0),
|
766
|
+
rb_funcall (dy2, cr_id_plus, 1, y0));
|
767
|
+
}
|
768
|
+
|
769
|
+
static VALUE
|
770
|
+
cr_rel_curve_to_generic (int argc, VALUE *argv, VALUE self)
|
771
|
+
{
|
772
|
+
VALUE dx1, dy1, dx2, dy2, dx3, dy3;
|
773
|
+
|
774
|
+
rb_scan_args (argc, argv, "42", &dx1, &dy1, &dx2, &dy2, &dx3, &dy3);
|
775
|
+
|
776
|
+
if (!(argc == 4 || argc == 6))
|
777
|
+
{
|
778
|
+
VALUE inspected_arg = rb_inspect (rb_ary_new4 (argc, argv));
|
779
|
+
rb_raise (rb_eArgError,
|
780
|
+
"invalid argument: %s (expect "
|
781
|
+
"(dx1, dy1, dx2, dy2) (quadratic) or "
|
782
|
+
"(dx1, dy1, dx2, dy2, dx3, dy3) (cubic))",
|
783
|
+
StringValuePtr (inspected_arg));
|
784
|
+
}
|
785
|
+
|
786
|
+
if (argc == 4)
|
787
|
+
return cr_rel_quadratic_curve_to (self, dx1, dy1, dx2, dy2);
|
788
|
+
else
|
789
|
+
return cr_rel_curve_to (self, dx1, dy1, dx2, dy2, dx3, dy3);
|
790
|
+
}
|
791
|
+
|
792
|
+
static VALUE
|
793
|
+
cr_rectangle (VALUE self, VALUE x, VALUE y, VALUE width, VALUE height)
|
794
|
+
{
|
795
|
+
cairo_rectangle (_SELF, NUM2DBL (x), NUM2DBL (y),
|
796
|
+
NUM2DBL (width), NUM2DBL (height));
|
797
|
+
cr_check_status (_SELF);
|
798
|
+
return self;
|
799
|
+
}
|
800
|
+
|
801
|
+
static VALUE
|
802
|
+
cr_close_path (VALUE self)
|
803
|
+
{
|
804
|
+
cairo_close_path (_SELF);
|
805
|
+
cr_check_status (_SELF);
|
806
|
+
return self;
|
807
|
+
}
|
808
|
+
|
809
|
+
#if CAIRO_CHECK_VERSION(1, 5, 8)
|
810
|
+
static VALUE
|
811
|
+
cr_path_extents (VALUE self)
|
812
|
+
{
|
813
|
+
double x1, y1, x2, y2;
|
814
|
+
cairo_path_extents (_SELF, &x1, &y1, &x2, &y2);
|
815
|
+
cr_check_status (_SELF);
|
816
|
+
return rb_ary_new3 (4,
|
817
|
+
rb_float_new(x1), rb_float_new(y1),
|
818
|
+
rb_float_new(x2), rb_float_new(y2));
|
819
|
+
}
|
820
|
+
#endif
|
821
|
+
|
822
|
+
/* Painting functions */
|
823
|
+
static VALUE
|
824
|
+
cr_paint (VALUE self)
|
825
|
+
{
|
826
|
+
cairo_paint (_SELF);
|
827
|
+
cr_check_status (_SELF);
|
828
|
+
return self;
|
829
|
+
}
|
830
|
+
|
831
|
+
static VALUE
|
832
|
+
cr_paint_with_alpha (VALUE self, VALUE alpha)
|
833
|
+
{
|
834
|
+
cairo_paint_with_alpha (_SELF, NUM2DBL (alpha));
|
835
|
+
cr_check_status (_SELF);
|
836
|
+
return self;
|
837
|
+
}
|
838
|
+
|
839
|
+
static VALUE
|
840
|
+
cr_paint_generic(int argc, VALUE *argv, VALUE self)
|
841
|
+
{
|
842
|
+
VALUE alpha;
|
843
|
+
int n;
|
844
|
+
|
845
|
+
n = rb_scan_args (argc, argv, "01", &alpha);
|
846
|
+
|
847
|
+
if (n == 0 || (n == 1 && NIL_P (alpha)))
|
848
|
+
{
|
849
|
+
return cr_paint (self);
|
850
|
+
}
|
851
|
+
if (n == 1)
|
852
|
+
{
|
853
|
+
return cr_paint_with_alpha (self, alpha);
|
854
|
+
}
|
855
|
+
else
|
856
|
+
{
|
857
|
+
rb_raise (rb_eArgError,
|
858
|
+
"invalid argument (expect () or (alpha))");
|
859
|
+
}
|
860
|
+
}
|
861
|
+
|
862
|
+
static VALUE
|
863
|
+
cr_mask(VALUE self, VALUE pattern)
|
864
|
+
{
|
865
|
+
cairo_mask (_SELF, RVAL2CRPATTERN (pattern));
|
866
|
+
cr_check_status (_SELF);
|
867
|
+
return self;
|
868
|
+
}
|
869
|
+
|
870
|
+
static VALUE
|
871
|
+
cr_mask_surface (VALUE self, VALUE surface, VALUE x, VALUE y)
|
872
|
+
{
|
873
|
+
cairo_mask_surface (_SELF, RVAL2CRSURFACE (surface),
|
874
|
+
NUM2DBL (x), NUM2DBL (y));
|
875
|
+
cr_check_status (_SELF);
|
876
|
+
return self;
|
877
|
+
}
|
878
|
+
|
879
|
+
static VALUE
|
880
|
+
cr_mask_generic (int argc, VALUE *argv, VALUE self)
|
881
|
+
{
|
882
|
+
VALUE arg1, arg2, arg3;
|
883
|
+
int n;
|
884
|
+
|
885
|
+
n = rb_scan_args (argc, argv, "12", &arg1, &arg2, &arg3);
|
886
|
+
|
887
|
+
if (n == 1)
|
888
|
+
{
|
889
|
+
return cr_mask (self, arg1);
|
890
|
+
}
|
891
|
+
else if (n == 3)
|
892
|
+
{
|
893
|
+
return cr_mask_surface (self, arg1, arg2, arg3);
|
894
|
+
}
|
895
|
+
else
|
896
|
+
{
|
897
|
+
rb_raise (rb_eArgError,
|
898
|
+
"invalid argument (expect (pattern) or (surface, x, y))");
|
899
|
+
}
|
900
|
+
}
|
901
|
+
|
902
|
+
static VALUE
|
903
|
+
cr_stroke (int argc, VALUE *argv, VALUE self)
|
904
|
+
{
|
905
|
+
VALUE preserve;
|
906
|
+
|
907
|
+
rb_scan_args (argc, argv, "01", &preserve);
|
908
|
+
|
909
|
+
if (rb_block_given_p ())
|
910
|
+
{
|
911
|
+
cr_new_path (self);
|
912
|
+
rb_yield (self);
|
913
|
+
}
|
914
|
+
|
915
|
+
if (RVAL2CBOOL (preserve))
|
916
|
+
cairo_stroke_preserve (_SELF);
|
917
|
+
else
|
918
|
+
cairo_stroke (_SELF);
|
919
|
+
|
920
|
+
cr_check_status (_SELF);
|
921
|
+
return self;
|
922
|
+
}
|
923
|
+
|
924
|
+
static VALUE
|
925
|
+
cr_fill (int argc, VALUE *argv, VALUE self)
|
926
|
+
{
|
927
|
+
VALUE preserve;
|
928
|
+
|
929
|
+
rb_scan_args (argc, argv, "01", &preserve);
|
930
|
+
|
931
|
+
if (rb_block_given_p ())
|
932
|
+
{
|
933
|
+
cr_new_path (self);
|
934
|
+
rb_yield (self);
|
935
|
+
}
|
936
|
+
|
937
|
+
if (RVAL2CBOOL (preserve))
|
938
|
+
cairo_fill_preserve (_SELF);
|
939
|
+
else
|
940
|
+
cairo_fill (_SELF);
|
941
|
+
|
942
|
+
cr_check_status (_SELF);
|
943
|
+
return self;
|
944
|
+
}
|
945
|
+
|
946
|
+
|
947
|
+
static VALUE
|
948
|
+
cr_copy_page (VALUE self)
|
949
|
+
{
|
950
|
+
cairo_copy_page (_SELF);
|
951
|
+
cr_check_status (_SELF);
|
952
|
+
return self;
|
953
|
+
}
|
954
|
+
|
955
|
+
static VALUE
|
956
|
+
cr_show_page (VALUE self)
|
957
|
+
{
|
958
|
+
cairo_show_page (_SELF);
|
959
|
+
cr_check_status (_SELF);
|
960
|
+
return self;
|
961
|
+
}
|
962
|
+
|
963
|
+
/* Insideness testing */
|
964
|
+
static VALUE
|
965
|
+
cr_in_stroke (VALUE self, VALUE x, VALUE y)
|
966
|
+
{
|
967
|
+
if (rb_block_given_p ())
|
968
|
+
{
|
969
|
+
cr_new_path (self);
|
970
|
+
rb_yield (self);
|
971
|
+
}
|
972
|
+
return CBOOL2RVAL (cairo_in_stroke (_SELF, NUM2DBL (x), NUM2DBL (y)));
|
973
|
+
}
|
974
|
+
|
975
|
+
static VALUE
|
976
|
+
cr_in_fill (VALUE self, VALUE x, VALUE y)
|
977
|
+
{
|
978
|
+
if (rb_block_given_p ())
|
979
|
+
{
|
980
|
+
cr_new_path (self);
|
981
|
+
rb_yield (self);
|
982
|
+
}
|
983
|
+
return CBOOL2RVAL (cairo_in_fill (_SELF, NUM2DBL (x), NUM2DBL (y)));
|
984
|
+
}
|
985
|
+
|
986
|
+
/* Rectangular extents */
|
987
|
+
static VALUE
|
988
|
+
cr_stroke_extents (VALUE self)
|
989
|
+
{
|
990
|
+
double extents[4];
|
991
|
+
if (rb_block_given_p ())
|
992
|
+
{
|
993
|
+
cr_new_path (self);
|
994
|
+
rb_yield (self);
|
995
|
+
}
|
996
|
+
cairo_stroke_extents (_SELF, extents, extents + 1, extents + 2, extents + 3);
|
997
|
+
return rb_cairo__float_array (extents, 4);
|
998
|
+
}
|
999
|
+
|
1000
|
+
static VALUE
|
1001
|
+
cr_fill_extents (VALUE self)
|
1002
|
+
{
|
1003
|
+
double extents[4];
|
1004
|
+
if (rb_block_given_p ())
|
1005
|
+
{
|
1006
|
+
cr_new_path (self);
|
1007
|
+
rb_yield (self);
|
1008
|
+
}
|
1009
|
+
cairo_fill_extents (_SELF, extents, extents + 1, extents + 2, extents + 3);
|
1010
|
+
return rb_cairo__float_array (extents, 4);
|
1011
|
+
}
|
1012
|
+
|
1013
|
+
/* Clipping */
|
1014
|
+
static VALUE
|
1015
|
+
cr_reset_clip (VALUE self)
|
1016
|
+
{
|
1017
|
+
cairo_reset_clip (_SELF);
|
1018
|
+
cr_check_status (_SELF);
|
1019
|
+
return self;
|
1020
|
+
}
|
1021
|
+
|
1022
|
+
static VALUE
|
1023
|
+
cr_clip (int argc, VALUE *argv, VALUE self)
|
1024
|
+
{
|
1025
|
+
VALUE preserve;
|
1026
|
+
|
1027
|
+
rb_scan_args(argc, argv, "01", &preserve);
|
1028
|
+
|
1029
|
+
if (rb_block_given_p ())
|
1030
|
+
{
|
1031
|
+
cr_new_path (self);
|
1032
|
+
rb_yield (self);
|
1033
|
+
}
|
1034
|
+
|
1035
|
+
if (RVAL2CBOOL (preserve))
|
1036
|
+
cairo_clip_preserve(_SELF);
|
1037
|
+
else
|
1038
|
+
cairo_clip (_SELF);
|
1039
|
+
|
1040
|
+
cr_check_status (_SELF);
|
1041
|
+
return self;
|
1042
|
+
}
|
1043
|
+
|
1044
|
+
#if CAIRO_CHECK_VERSION(1, 3, 0)
|
1045
|
+
static VALUE
|
1046
|
+
cr_clip_extents (VALUE self)
|
1047
|
+
{
|
1048
|
+
double x1, y1, x2, y2;
|
1049
|
+
cairo_clip_extents (_SELF, &x1, &y1, &x2, &y2);
|
1050
|
+
cr_check_status (_SELF);
|
1051
|
+
return rb_ary_new3 (4,
|
1052
|
+
rb_float_new (x1), rb_float_new (y1),
|
1053
|
+
rb_float_new (x2), rb_float_new (y2));
|
1054
|
+
}
|
1055
|
+
|
1056
|
+
static VALUE
|
1057
|
+
cr_clip_rectangle_list (VALUE self)
|
1058
|
+
{
|
1059
|
+
VALUE rb_rectangles;
|
1060
|
+
cairo_rectangle_list_t *rectangles;
|
1061
|
+
int i;
|
1062
|
+
|
1063
|
+
rectangles = cairo_copy_clip_rectangle_list (_SELF);
|
1064
|
+
rb_cairo_check_status (rectangles->status);
|
1065
|
+
|
1066
|
+
rb_rectangles = rb_ary_new2 (rectangles->num_rectangles);
|
1067
|
+
for (i = 0; i < rectangles->num_rectangles; i++) {
|
1068
|
+
VALUE argv[4];
|
1069
|
+
cairo_rectangle_t rectangle = rectangles->rectangles[i];
|
1070
|
+
|
1071
|
+
argv[0] = rb_float_new (rectangle.x);
|
1072
|
+
argv[1] = rb_float_new (rectangle.y);
|
1073
|
+
argv[2] = rb_float_new (rectangle.width);
|
1074
|
+
argv[3] = rb_float_new (rectangle.height);
|
1075
|
+
rb_ary_push (rb_rectangles,
|
1076
|
+
rb_class_new_instance (4, argv, rb_cCairo_Rectangle));
|
1077
|
+
}
|
1078
|
+
cairo_rectangle_list_destroy (rectangles);
|
1079
|
+
|
1080
|
+
return rb_rectangles;
|
1081
|
+
}
|
1082
|
+
#endif
|
1083
|
+
|
1084
|
+
/* Font/Text functions */
|
1085
|
+
static VALUE
|
1086
|
+
cr_select_font_face (int argc, VALUE *argv, VALUE self)
|
1087
|
+
{
|
1088
|
+
VALUE rb_family, rb_slant, rb_weight;
|
1089
|
+
const char *family;
|
1090
|
+
cairo_font_slant_t slant;
|
1091
|
+
cairo_font_weight_t weight;
|
1092
|
+
|
1093
|
+
rb_scan_args(argc, argv, "03", &rb_family, &rb_slant, &rb_weight);
|
1094
|
+
|
1095
|
+
if (NIL_P (rb_family))
|
1096
|
+
{
|
1097
|
+
family = "";
|
1098
|
+
}
|
1099
|
+
else if (rb_cairo__is_kind_of (rb_family, rb_cString))
|
1100
|
+
{
|
1101
|
+
family = RSTRING_PTR (rb_family);
|
1102
|
+
}
|
1103
|
+
else if (rb_cairo__is_kind_of (rb_family, rb_cSymbol))
|
1104
|
+
{
|
1105
|
+
family = rb_id2name (SYM2ID (rb_family));
|
1106
|
+
}
|
1107
|
+
else
|
1108
|
+
{
|
1109
|
+
rb_raise (rb_eArgError,
|
1110
|
+
"family name should be nil, String or Symbol: %s",
|
1111
|
+
rb_cairo__inspect (rb_family));
|
1112
|
+
}
|
1113
|
+
|
1114
|
+
if (NIL_P (rb_slant))
|
1115
|
+
slant = CAIRO_FONT_SLANT_NORMAL;
|
1116
|
+
else
|
1117
|
+
slant = RVAL2CRFONTSLANT (rb_slant);
|
1118
|
+
|
1119
|
+
if (NIL_P (rb_weight))
|
1120
|
+
weight = CAIRO_FONT_WEIGHT_NORMAL;
|
1121
|
+
else
|
1122
|
+
weight = RVAL2CRFONTWEIGHT (rb_weight);
|
1123
|
+
|
1124
|
+
cairo_select_font_face (_SELF, family, slant, weight);
|
1125
|
+
cr_check_status (_SELF);
|
1126
|
+
return self;
|
1127
|
+
}
|
1128
|
+
|
1129
|
+
static VALUE
|
1130
|
+
cr_set_font_size (VALUE self, VALUE scale)
|
1131
|
+
{
|
1132
|
+
cairo_set_font_size (_SELF, NUM2DBL (scale));
|
1133
|
+
cr_check_status (_SELF);
|
1134
|
+
return self;
|
1135
|
+
}
|
1136
|
+
|
1137
|
+
static VALUE
|
1138
|
+
cr_set_font_matrix (VALUE self, VALUE matrix)
|
1139
|
+
{
|
1140
|
+
cairo_set_font_matrix (_SELF, RVAL2CRMATRIX (matrix));
|
1141
|
+
cr_check_status (_SELF);
|
1142
|
+
return self;
|
1143
|
+
}
|
1144
|
+
|
1145
|
+
static VALUE
|
1146
|
+
cr_get_font_matrix (VALUE self)
|
1147
|
+
{
|
1148
|
+
cairo_matrix_t matrix;
|
1149
|
+
cairo_get_font_matrix (_SELF, &matrix);
|
1150
|
+
cr_check_status (_SELF);
|
1151
|
+
return CRMATRIX2RVAL (&matrix);
|
1152
|
+
}
|
1153
|
+
|
1154
|
+
static VALUE
|
1155
|
+
cr_set_font_options (VALUE self, VALUE options)
|
1156
|
+
{
|
1157
|
+
cairo_set_font_options (_SELF, RVAL2CRFONTOPTIONS (options));
|
1158
|
+
cr_check_status (_SELF);
|
1159
|
+
return self;
|
1160
|
+
}
|
1161
|
+
|
1162
|
+
static VALUE
|
1163
|
+
cr_get_font_options (VALUE self)
|
1164
|
+
{
|
1165
|
+
cairo_font_options_t *options = cairo_font_options_create ();
|
1166
|
+
rb_cairo_check_status (cairo_font_options_status (options));
|
1167
|
+
cairo_get_font_options (_SELF, options);
|
1168
|
+
rb_cairo_check_status (cairo_font_options_status (options));
|
1169
|
+
return CRFONTOPTIONS2RVAL (options);
|
1170
|
+
}
|
1171
|
+
|
1172
|
+
static VALUE
|
1173
|
+
cr_set_scaled_font (VALUE self, VALUE scaled_font)
|
1174
|
+
{
|
1175
|
+
cairo_set_scaled_font (_SELF, RVAL2CRSCALEDFONT (scaled_font));
|
1176
|
+
cr_check_status (_SELF);
|
1177
|
+
return self;
|
1178
|
+
}
|
1179
|
+
|
1180
|
+
#if CAIRO_CHECK_VERSION(1, 3, 16)
|
1181
|
+
static VALUE
|
1182
|
+
cr_get_scaled_font (VALUE self)
|
1183
|
+
{
|
1184
|
+
return CRSCALEDFONT2RVAL (cairo_get_scaled_font (_SELF));
|
1185
|
+
}
|
1186
|
+
#endif
|
1187
|
+
|
1188
|
+
static VALUE
|
1189
|
+
cr_show_text (VALUE self, VALUE utf8)
|
1190
|
+
{
|
1191
|
+
cairo_show_text (_SELF, RVAL2CSTR (utf8));
|
1192
|
+
cr_check_status (_SELF);
|
1193
|
+
return self;
|
1194
|
+
}
|
1195
|
+
|
1196
|
+
static VALUE
|
1197
|
+
cr_show_glyphs (VALUE self, VALUE rb_glyphs)
|
1198
|
+
{
|
1199
|
+
int count;
|
1200
|
+
cairo_glyph_t *glyphs;
|
1201
|
+
|
1202
|
+
RB_CAIRO__GLYPHS_TO_ARRAY (rb_glyphs, glyphs, count);
|
1203
|
+
cairo_show_glyphs (_SELF, glyphs, count);
|
1204
|
+
cr_check_status (_SELF);
|
1205
|
+
return self;
|
1206
|
+
}
|
1207
|
+
|
1208
|
+
#if CAIRO_CHECK_VERSION(1, 8, 0)
|
1209
|
+
static VALUE
|
1210
|
+
cr_show_text_glyphs (VALUE self, VALUE rb_utf8, VALUE rb_glyphs,
|
1211
|
+
VALUE rb_clusters, VALUE rb_cluster_flags)
|
1212
|
+
{
|
1213
|
+
cairo_t *cr;
|
1214
|
+
const char *utf8;
|
1215
|
+
int utf8_len;
|
1216
|
+
cairo_glyph_t *glyphs = NULL;
|
1217
|
+
int num_glyphs = 0;
|
1218
|
+
cairo_text_cluster_t *clusters = NULL;
|
1219
|
+
int num_clusters = 0;
|
1220
|
+
cairo_text_cluster_flags_t cluster_flags;
|
1221
|
+
|
1222
|
+
cr = _SELF;
|
1223
|
+
utf8 = RSTRING_PTR (rb_utf8);
|
1224
|
+
utf8_len = RSTRING_LEN (rb_utf8);
|
1225
|
+
rb_cairo__glyphs_from_ruby_object (rb_glyphs, &glyphs, &num_glyphs);
|
1226
|
+
rb_cairo__text_clusters_from_ruby_object (rb_clusters,
|
1227
|
+
&clusters, &num_clusters);
|
1228
|
+
cluster_flags = RVAL2CRTEXTCLUSTERFLAGS (rb_cluster_flags);
|
1229
|
+
cairo_show_text_glyphs (cr, utf8, utf8_len,
|
1230
|
+
glyphs, num_glyphs,
|
1231
|
+
clusters, num_clusters,
|
1232
|
+
cluster_flags);
|
1233
|
+
if (glyphs)
|
1234
|
+
cairo_glyph_free (glyphs);
|
1235
|
+
if (clusters)
|
1236
|
+
cairo_text_cluster_free (clusters);
|
1237
|
+
|
1238
|
+
return self;
|
1239
|
+
}
|
1240
|
+
#endif
|
1241
|
+
|
1242
|
+
static VALUE
|
1243
|
+
cr_get_font_face (VALUE self)
|
1244
|
+
{
|
1245
|
+
cairo_font_face_t *face;
|
1246
|
+
|
1247
|
+
face = cairo_get_font_face (_SELF);
|
1248
|
+
rb_cairo_check_status (cairo_font_face_status (face));
|
1249
|
+
return CRFONTFACE2RVAL (face);
|
1250
|
+
}
|
1251
|
+
|
1252
|
+
static VALUE
|
1253
|
+
cr_font_extents (VALUE self)
|
1254
|
+
{
|
1255
|
+
cairo_font_extents_t extents;
|
1256
|
+
cairo_font_extents (_SELF, &extents);
|
1257
|
+
cr_check_status (_SELF);
|
1258
|
+
return CRFONTEXTENTS2RVAL (&extents);
|
1259
|
+
}
|
1260
|
+
|
1261
|
+
static VALUE
|
1262
|
+
cr_set_font_face (VALUE self, VALUE face)
|
1263
|
+
{
|
1264
|
+
cairo_set_font_face (_SELF, NIL_P (face) ? NULL : RVAL2CRFONTFACE (face));
|
1265
|
+
cr_check_status (_SELF);
|
1266
|
+
return self;
|
1267
|
+
}
|
1268
|
+
|
1269
|
+
static VALUE
|
1270
|
+
cr_text_extents (VALUE self, VALUE utf8)
|
1271
|
+
{
|
1272
|
+
cairo_text_extents_t extents;
|
1273
|
+
cairo_text_extents (_SELF, StringValuePtr (utf8), &extents);
|
1274
|
+
cr_check_status (_SELF);
|
1275
|
+
return CRTEXTEXTENTS2RVAL (&extents);
|
1276
|
+
}
|
1277
|
+
|
1278
|
+
static VALUE
|
1279
|
+
cr_glyph_extents (VALUE self, VALUE rb_glyphs)
|
1280
|
+
{
|
1281
|
+
cairo_text_extents_t extents;
|
1282
|
+
cairo_glyph_t *glyphs;
|
1283
|
+
int length;
|
1284
|
+
|
1285
|
+
RB_CAIRO__GLYPHS_TO_ARRAY (rb_glyphs, glyphs, length);
|
1286
|
+
cairo_glyph_extents (_SELF, glyphs, length, &extents);
|
1287
|
+
cr_check_status (_SELF);
|
1288
|
+
return CRTEXTEXTENTS2RVAL (&extents);
|
1289
|
+
}
|
1290
|
+
|
1291
|
+
static VALUE
|
1292
|
+
cr_text_path (VALUE self, VALUE utf8)
|
1293
|
+
{
|
1294
|
+
cairo_text_path (_SELF, StringValuePtr (utf8));
|
1295
|
+
cr_check_status (_SELF);
|
1296
|
+
return self;
|
1297
|
+
}
|
1298
|
+
|
1299
|
+
static VALUE
|
1300
|
+
cr_glyph_path (VALUE self, VALUE rb_glyphs)
|
1301
|
+
{
|
1302
|
+
int count;
|
1303
|
+
cairo_glyph_t *glyphs;
|
1304
|
+
|
1305
|
+
RB_CAIRO__GLYPHS_TO_ARRAY (rb_glyphs, glyphs, count);
|
1306
|
+
cairo_glyph_path (_SELF, glyphs, count);
|
1307
|
+
cr_check_status (_SELF);
|
1308
|
+
|
1309
|
+
return self;
|
1310
|
+
}
|
1311
|
+
|
1312
|
+
/* Query functions */
|
1313
|
+
static VALUE
|
1314
|
+
cr_get_operator (VALUE self)
|
1315
|
+
{
|
1316
|
+
return INT2FIX (cairo_get_operator (_SELF));
|
1317
|
+
}
|
1318
|
+
|
1319
|
+
static VALUE
|
1320
|
+
cr_get_source (VALUE self)
|
1321
|
+
{
|
1322
|
+
VALUE rb_source = Qnil;
|
1323
|
+
cairo_pattern_t *source;
|
1324
|
+
source = cairo_get_source (_SELF);
|
1325
|
+
|
1326
|
+
if (source)
|
1327
|
+
{
|
1328
|
+
rb_cairo_check_status (cairo_pattern_status (source));
|
1329
|
+
rb_source = rb_ivar_get (self, cr_id_source);
|
1330
|
+
if (NIL_P (rb_source) || RVAL2CRPATTERN (rb_source) != source)
|
1331
|
+
{
|
1332
|
+
rb_source = CRPATTERN2RVAL (source);
|
1333
|
+
rb_ivar_set (self, cr_id_source, rb_source);
|
1334
|
+
}
|
1335
|
+
}
|
1336
|
+
else
|
1337
|
+
{
|
1338
|
+
rb_source = Qnil;
|
1339
|
+
rb_ivar_set (self, cr_id_source, rb_source);
|
1340
|
+
}
|
1341
|
+
|
1342
|
+
return rb_source;
|
1343
|
+
}
|
1344
|
+
|
1345
|
+
static VALUE
|
1346
|
+
cr_get_tolerance (VALUE self)
|
1347
|
+
{
|
1348
|
+
return rb_float_new (cairo_get_tolerance (_SELF));
|
1349
|
+
}
|
1350
|
+
|
1351
|
+
static VALUE
|
1352
|
+
cr_get_antialias(VALUE self)
|
1353
|
+
{
|
1354
|
+
return INT2NUM (cairo_get_antialias (_SELF));
|
1355
|
+
}
|
1356
|
+
|
1357
|
+
#if CAIRO_CHECK_VERSION(1, 5, 10)
|
1358
|
+
static VALUE
|
1359
|
+
cr_has_current_point(VALUE self)
|
1360
|
+
{
|
1361
|
+
return RTEST (cairo_has_current_point (_SELF));
|
1362
|
+
}
|
1363
|
+
#endif
|
1364
|
+
|
1365
|
+
static VALUE
|
1366
|
+
cr_get_current_point (VALUE self)
|
1367
|
+
{
|
1368
|
+
double point[2];
|
1369
|
+
cairo_get_current_point (_SELF, point, point + 1);
|
1370
|
+
return rb_cairo__float_array (point, 2);
|
1371
|
+
}
|
1372
|
+
|
1373
|
+
static VALUE
|
1374
|
+
cr_get_fill_rule (VALUE self)
|
1375
|
+
{
|
1376
|
+
return INT2FIX (cairo_get_fill_rule (_SELF));
|
1377
|
+
}
|
1378
|
+
|
1379
|
+
static VALUE
|
1380
|
+
cr_get_line_width (VALUE self)
|
1381
|
+
{
|
1382
|
+
return rb_float_new (cairo_get_line_width (_SELF));
|
1383
|
+
}
|
1384
|
+
|
1385
|
+
static VALUE
|
1386
|
+
cr_get_line_cap (VALUE self)
|
1387
|
+
{
|
1388
|
+
return INT2FIX (cairo_get_line_cap (_SELF));
|
1389
|
+
}
|
1390
|
+
|
1391
|
+
static VALUE
|
1392
|
+
cr_get_line_join (VALUE self)
|
1393
|
+
{
|
1394
|
+
return INT2FIX (cairo_get_line_join (_SELF));
|
1395
|
+
}
|
1396
|
+
|
1397
|
+
static VALUE
|
1398
|
+
cr_get_miter_limit (VALUE self)
|
1399
|
+
{
|
1400
|
+
return rb_float_new (cairo_get_miter_limit (_SELF));
|
1401
|
+
}
|
1402
|
+
|
1403
|
+
#if CAIRO_CHECK_VERSION(1, 3, 0)
|
1404
|
+
static VALUE
|
1405
|
+
cr_get_dash_count (VALUE self)
|
1406
|
+
{
|
1407
|
+
return INT2NUM (cairo_get_dash_count (_SELF));
|
1408
|
+
}
|
1409
|
+
|
1410
|
+
static VALUE
|
1411
|
+
cr_get_dash (VALUE self)
|
1412
|
+
{
|
1413
|
+
int count;
|
1414
|
+
double *dashes, offset;
|
1415
|
+
|
1416
|
+
count = cairo_get_dash_count (_SELF);
|
1417
|
+
dashes = ALLOCA_N (double, count);
|
1418
|
+
cairo_get_dash (_SELF, dashes, &offset);
|
1419
|
+
|
1420
|
+
return rb_ary_new3 (2,
|
1421
|
+
rb_cairo__float_array (dashes, count),
|
1422
|
+
rb_float_new (offset));
|
1423
|
+
}
|
1424
|
+
#endif
|
1425
|
+
|
1426
|
+
static VALUE
|
1427
|
+
cr_get_matrix (VALUE self)
|
1428
|
+
{
|
1429
|
+
cairo_matrix_t matrix;
|
1430
|
+
cairo_get_matrix (_SELF, &matrix);
|
1431
|
+
cr_check_status (_SELF);
|
1432
|
+
return CRMATRIX2RVAL (&matrix);
|
1433
|
+
}
|
1434
|
+
|
1435
|
+
static VALUE
|
1436
|
+
cr_get_target (VALUE self)
|
1437
|
+
{
|
1438
|
+
cairo_surface_t *surface;
|
1439
|
+
VALUE rb_surface;
|
1440
|
+
|
1441
|
+
surface = cairo_get_target (_SELF);
|
1442
|
+
rb_cairo_check_status (cairo_surface_status (surface));
|
1443
|
+
|
1444
|
+
rb_surface = rb_ivar_get (self, cr_id_surface);
|
1445
|
+
if (NIL_P (rb_surface) || RVAL2CRSURFACE (rb_surface) != surface)
|
1446
|
+
{
|
1447
|
+
rb_surface = CRSURFACE2RVAL (surface);
|
1448
|
+
rb_ivar_set (self, cr_id_surface, rb_surface);
|
1449
|
+
}
|
1450
|
+
|
1451
|
+
return rb_surface;
|
1452
|
+
}
|
1453
|
+
|
1454
|
+
static VALUE
|
1455
|
+
cr_get_group_target (VALUE self)
|
1456
|
+
{
|
1457
|
+
cairo_surface_t *surface;
|
1458
|
+
|
1459
|
+
surface = cairo_get_group_target (_SELF);
|
1460
|
+
if (!surface)
|
1461
|
+
return Qnil;
|
1462
|
+
rb_cairo_check_status (cairo_surface_status (surface));
|
1463
|
+
return CRSURFACE2RVAL (surface);
|
1464
|
+
}
|
1465
|
+
|
1466
|
+
/* Paths */
|
1467
|
+
static VALUE
|
1468
|
+
cr_copy_path (VALUE self)
|
1469
|
+
{
|
1470
|
+
cairo_path_t *path;
|
1471
|
+
|
1472
|
+
path = cairo_copy_path (_SELF);
|
1473
|
+
rb_cairo_check_status (path->status);
|
1474
|
+
return CRPATH2RVAL (path);
|
1475
|
+
}
|
1476
|
+
|
1477
|
+
static VALUE
|
1478
|
+
cr_copy_path_flat (VALUE self)
|
1479
|
+
{
|
1480
|
+
cairo_path_t *path;
|
1481
|
+
|
1482
|
+
path = cairo_copy_path_flat (_SELF);
|
1483
|
+
rb_cairo_check_status (path->status);
|
1484
|
+
return CRPATH2RVAL (path);
|
1485
|
+
}
|
1486
|
+
|
1487
|
+
static VALUE
|
1488
|
+
cr_copy_append_path (VALUE self, VALUE path)
|
1489
|
+
{
|
1490
|
+
cairo_append_path (_SELF, RVAL2CRPATH (path));
|
1491
|
+
cr_check_status (_SELF);
|
1492
|
+
return self;
|
1493
|
+
}
|
1494
|
+
|
1495
|
+
static int
|
1496
|
+
cr_destroy_all_guarded_contexts_at_end_iter (VALUE key, VALUE value, VALUE data)
|
1497
|
+
{
|
1498
|
+
cr_destroy (key);
|
1499
|
+
return ST_CONTINUE;
|
1500
|
+
}
|
1501
|
+
|
1502
|
+
static void
|
1503
|
+
cr_destroy_all_guarded_contexts_at_end (VALUE data)
|
1504
|
+
{
|
1505
|
+
rb_hash_foreach (rb_cairo__gc_guarded_objects (rb_cCairo_Context),
|
1506
|
+
cr_destroy_all_guarded_contexts_at_end_iter,
|
1507
|
+
Qnil);
|
1508
|
+
}
|
1509
|
+
|
1510
|
+
void
|
1511
|
+
Init_cairo_context (void)
|
1512
|
+
{
|
1513
|
+
cr_id_surface = rb_intern ("surface");
|
1514
|
+
cr_id_source = rb_intern ("source");
|
1515
|
+
|
1516
|
+
cr_id_plus = rb_intern ("+");
|
1517
|
+
cr_id_minus = rb_intern ("-");
|
1518
|
+
cr_id_multi = rb_intern ("*");
|
1519
|
+
cr_id_div = rb_intern ("/");
|
1520
|
+
|
1521
|
+
#if CAIRO_CHECK_VERSION(1, 3, 0)
|
1522
|
+
rb_cCairo_Rectangle =
|
1523
|
+
rb_define_class_under (rb_mCairo, "Rectangle", rb_cObject);
|
1524
|
+
at_x = rb_intern ("@x");
|
1525
|
+
at_y = rb_intern ("@y");
|
1526
|
+
at_width = rb_intern ("@width");
|
1527
|
+
at_height = rb_intern ("@height");
|
1528
|
+
|
1529
|
+
rb_define_attr (rb_cCairo_Rectangle, "x", CR_TRUE, CR_TRUE);
|
1530
|
+
rb_define_attr (rb_cCairo_Rectangle, "y", CR_TRUE, CR_TRUE);
|
1531
|
+
rb_define_attr (rb_cCairo_Rectangle, "width", CR_TRUE, CR_TRUE);
|
1532
|
+
rb_define_attr (rb_cCairo_Rectangle, "height", CR_TRUE, CR_TRUE);
|
1533
|
+
|
1534
|
+
rb_define_method (rb_cCairo_Rectangle, "initialize",
|
1535
|
+
cr_rectangle_initialize, 4);
|
1536
|
+
#endif
|
1537
|
+
|
1538
|
+
rb_cCairo_Context =
|
1539
|
+
rb_define_class_under (rb_mCairo, "Context", rb_cObject);
|
1540
|
+
|
1541
|
+
rb_define_alloc_func (rb_cCairo_Context, cr_allocate);
|
1542
|
+
|
1543
|
+
rb_cairo__initialize_gc_guard_holder_class (rb_cCairo_Context);
|
1544
|
+
rb_set_end_proc(cr_destroy_all_guarded_contexts_at_end, Qnil);
|
1545
|
+
|
1546
|
+
/* Functions for manipulating state objects */
|
1547
|
+
rb_define_method (rb_cCairo_Context, "initialize", cr_initialize, 1);
|
1548
|
+
rb_define_method (rb_cCairo_Context, "destroy", cr_destroy, 0);
|
1549
|
+
|
1550
|
+
rb_define_method (rb_cCairo_Context, "save", cr_save, 0);
|
1551
|
+
rb_define_method (rb_cCairo_Context, "restore", cr_restore, 0);
|
1552
|
+
rb_define_method (rb_cCairo_Context, "push_group", cr_push_group, -1);
|
1553
|
+
rb_define_method (rb_cCairo_Context, "pop_group", cr_pop_group_generic, -1);
|
1554
|
+
rb_define_method (rb_cCairo_Context, "pop_group_to_source",
|
1555
|
+
cr_pop_group_to_source, 0);
|
1556
|
+
|
1557
|
+
/* Modify state */
|
1558
|
+
rb_define_method (rb_cCairo_Context, "set_operator", cr_set_operator, 1);
|
1559
|
+
rb_define_method (rb_cCairo_Context, "set_source", cr_set_source_generic, -1);
|
1560
|
+
rb_define_method (rb_cCairo_Context, "set_source_rgb",
|
1561
|
+
cr_set_source_rgb, -1);
|
1562
|
+
rb_define_method (rb_cCairo_Context, "set_source_rgba",
|
1563
|
+
cr_set_source_rgba, -1);
|
1564
|
+
rb_define_method (rb_cCairo_Context, "set_tolerance", cr_set_tolerance, 1);
|
1565
|
+
rb_define_method (rb_cCairo_Context, "set_antialias", cr_set_antialias, 1);
|
1566
|
+
rb_define_method (rb_cCairo_Context, "set_fill_rule", cr_set_fill_rule, 1);
|
1567
|
+
rb_define_method (rb_cCairo_Context, "set_line_width", cr_set_line_width, 1);
|
1568
|
+
rb_define_method (rb_cCairo_Context, "set_line_cap", cr_set_line_cap, 1);
|
1569
|
+
rb_define_method (rb_cCairo_Context, "set_line_join", cr_set_line_join, 1);
|
1570
|
+
rb_define_method (rb_cCairo_Context, "set_dash", cr_set_dash, -1);
|
1571
|
+
rb_define_method (rb_cCairo_Context, "set_miter_limit",
|
1572
|
+
cr_set_miter_limit, 1);
|
1573
|
+
|
1574
|
+
rb_define_method (rb_cCairo_Context, "translate", cr_translate, 2);
|
1575
|
+
rb_define_method (rb_cCairo_Context, "scale", cr_scale, 2);
|
1576
|
+
rb_define_method (rb_cCairo_Context, "rotate", cr_rotate, 1);
|
1577
|
+
rb_define_method (rb_cCairo_Context, "transform", cr_transform, 1);
|
1578
|
+
|
1579
|
+
rb_define_method (rb_cCairo_Context, "set_matrix", cr_set_matrix, 1);
|
1580
|
+
rb_define_method (rb_cCairo_Context, "identity_matrix",
|
1581
|
+
cr_identity_matrix, 0);
|
1582
|
+
rb_define_method (rb_cCairo_Context, "user_to_device", cr_user_to_device, 2);
|
1583
|
+
rb_define_method (rb_cCairo_Context, "user_to_device_distance",
|
1584
|
+
cr_user_to_device_distance, 2);
|
1585
|
+
rb_define_method (rb_cCairo_Context, "device_to_user", cr_device_to_user, 2);
|
1586
|
+
rb_define_method (rb_cCairo_Context, "device_to_user_distance",
|
1587
|
+
cr_device_to_user_distance, 2);
|
1588
|
+
|
1589
|
+
/* Path creation functions */
|
1590
|
+
rb_define_method (rb_cCairo_Context, "new_path", cr_new_path, 0);
|
1591
|
+
rb_define_method (rb_cCairo_Context, "move_to", cr_move_to, 2);
|
1592
|
+
rb_define_method (rb_cCairo_Context, "new_sub_path", cr_new_sub_path, 0);
|
1593
|
+
rb_define_method (rb_cCairo_Context, "line_to", cr_line_to, 2);
|
1594
|
+
rb_define_method (rb_cCairo_Context, "curve_to", cr_curve_to_generic, -1);
|
1595
|
+
rb_define_method (rb_cCairo_Context, "arc", cr_arc, 5);
|
1596
|
+
rb_define_method (rb_cCairo_Context, "arc_negative", cr_arc_negative, 5);
|
1597
|
+
rb_define_method (rb_cCairo_Context, "rel_move_to", cr_rel_move_to, 2);
|
1598
|
+
rb_define_method (rb_cCairo_Context, "rel_line_to", cr_rel_line_to, 2);
|
1599
|
+
rb_define_method (rb_cCairo_Context, "rel_curve_to",
|
1600
|
+
cr_rel_curve_to_generic, -1);
|
1601
|
+
rb_define_method (rb_cCairo_Context, "rectangle", cr_rectangle, 4);
|
1602
|
+
rb_define_method (rb_cCairo_Context, "close_path", cr_close_path, 0);
|
1603
|
+
#if CAIRO_CHECK_VERSION(1, 5, 8)
|
1604
|
+
rb_define_method (rb_cCairo_Context, "path_extents", cr_path_extents, 0);
|
1605
|
+
#endif
|
1606
|
+
|
1607
|
+
/* Painting functions */
|
1608
|
+
rb_define_method (rb_cCairo_Context, "paint", cr_paint_generic, -1);
|
1609
|
+
rb_define_method (rb_cCairo_Context, "mask", cr_mask_generic, -1);
|
1610
|
+
rb_define_method (rb_cCairo_Context, "stroke", cr_stroke, -1);
|
1611
|
+
rb_define_method (rb_cCairo_Context, "fill", cr_fill, -1);
|
1612
|
+
rb_define_method (rb_cCairo_Context, "copy_page", cr_copy_page, 0);
|
1613
|
+
rb_define_method (rb_cCairo_Context, "show_page", cr_show_page, 0);
|
1614
|
+
|
1615
|
+
/* Insideness testing */
|
1616
|
+
rb_define_method (rb_cCairo_Context, "in_stroke?", cr_in_stroke, 2);
|
1617
|
+
rb_define_method (rb_cCairo_Context, "in_fill?", cr_in_fill, 2);
|
1618
|
+
|
1619
|
+
/* Rectangular extents */
|
1620
|
+
rb_define_method (rb_cCairo_Context, "stroke_extents", cr_stroke_extents, 0);
|
1621
|
+
rb_define_method (rb_cCairo_Context, "fill_extents", cr_fill_extents, 0);
|
1622
|
+
|
1623
|
+
/* Clipping */
|
1624
|
+
rb_define_method (rb_cCairo_Context, "reset_clip", cr_reset_clip, 0);
|
1625
|
+
rb_define_method (rb_cCairo_Context, "clip", cr_clip, -1);
|
1626
|
+
#if CAIRO_CHECK_VERSION(1, 3, 0)
|
1627
|
+
rb_define_method (rb_cCairo_Context, "clip_extents", cr_clip_extents, 0);
|
1628
|
+
rb_define_method (rb_cCairo_Context, "clip_rectangle_list",
|
1629
|
+
cr_clip_rectangle_list, 0);
|
1630
|
+
#endif
|
1631
|
+
|
1632
|
+
/* Font/Text functions */
|
1633
|
+
rb_define_method (rb_cCairo_Context, "select_font_face",
|
1634
|
+
cr_select_font_face, -1);
|
1635
|
+
rb_define_method (rb_cCairo_Context, "set_font_size", cr_set_font_size, 1);
|
1636
|
+
rb_define_method (rb_cCairo_Context, "set_font_matrix",
|
1637
|
+
cr_set_font_matrix, 1);
|
1638
|
+
rb_define_method (rb_cCairo_Context, "font_matrix", cr_get_font_matrix, 0);
|
1639
|
+
rb_define_method (rb_cCairo_Context, "set_font_options",
|
1640
|
+
cr_set_font_options, 1);
|
1641
|
+
rb_define_method (rb_cCairo_Context, "font_options", cr_get_font_options, 0);
|
1642
|
+
rb_define_method (rb_cCairo_Context, "set_font_face", cr_set_font_face, 1);
|
1643
|
+
rb_define_method (rb_cCairo_Context, "font_face", cr_get_font_face, 0);
|
1644
|
+
rb_define_method (rb_cCairo_Context, "set_scaled_font",
|
1645
|
+
cr_set_scaled_font, 1);
|
1646
|
+
#if CAIRO_CHECK_VERSION(1, 3, 16)
|
1647
|
+
rb_define_method (rb_cCairo_Context, "scaled_font", cr_get_scaled_font, 0);
|
1648
|
+
#endif
|
1649
|
+
rb_define_method (rb_cCairo_Context, "show_text", cr_show_text, 1);
|
1650
|
+
rb_define_method (rb_cCairo_Context, "show_glyphs", cr_show_glyphs, 1);
|
1651
|
+
#if CAIRO_CHECK_VERSION(1, 8, 0)
|
1652
|
+
rb_define_method (rb_cCairo_Context, "show_text_glyphs",
|
1653
|
+
cr_show_text_glyphs, 4);
|
1654
|
+
#endif
|
1655
|
+
rb_define_method (rb_cCairo_Context, "text_path", cr_text_path, 1);
|
1656
|
+
rb_define_method (rb_cCairo_Context, "glyph_path", cr_glyph_path, 1);
|
1657
|
+
rb_define_method (rb_cCairo_Context, "text_extents", cr_text_extents, 1);
|
1658
|
+
rb_define_method (rb_cCairo_Context, "glyph_extents", cr_glyph_extents, 1);
|
1659
|
+
rb_define_method (rb_cCairo_Context, "font_extents", cr_font_extents, 0);
|
1660
|
+
|
1661
|
+
/* Query functions */
|
1662
|
+
rb_define_method (rb_cCairo_Context, "operator", cr_get_operator, 0);
|
1663
|
+
rb_define_method (rb_cCairo_Context, "source", cr_get_source, 0);
|
1664
|
+
rb_define_method (rb_cCairo_Context, "tolerance", cr_get_tolerance, 0);
|
1665
|
+
rb_define_method (rb_cCairo_Context, "antialias", cr_get_antialias, 0);
|
1666
|
+
#if CAIRO_CHECK_VERSION(1, 5, 10)
|
1667
|
+
rb_define_method (rb_cCairo_Context, "have_current_point?",
|
1668
|
+
cr_has_current_point, 0);
|
1669
|
+
rb_define_alias (rb_cCairo_Context,
|
1670
|
+
"has_current_point?", "have_current_point?");
|
1671
|
+
#endif
|
1672
|
+
rb_define_method (rb_cCairo_Context, "current_point",
|
1673
|
+
cr_get_current_point, 0);
|
1674
|
+
rb_define_method (rb_cCairo_Context, "fill_rule", cr_get_fill_rule, 0);
|
1675
|
+
rb_define_method (rb_cCairo_Context, "line_width", cr_get_line_width, 0);
|
1676
|
+
rb_define_method (rb_cCairo_Context, "line_cap", cr_get_line_cap, 0);
|
1677
|
+
rb_define_method (rb_cCairo_Context, "line_join", cr_get_line_join, 0);
|
1678
|
+
rb_define_method (rb_cCairo_Context, "miter_limit", cr_get_miter_limit, 0);
|
1679
|
+
#if CAIRO_CHECK_VERSION(1, 3, 0)
|
1680
|
+
rb_define_method (rb_cCairo_Context, "dash_count", cr_get_dash_count, 0);
|
1681
|
+
rb_define_method (rb_cCairo_Context, "dash", cr_get_dash, 0);
|
1682
|
+
#endif
|
1683
|
+
rb_define_method (rb_cCairo_Context, "matrix", cr_get_matrix, 0);
|
1684
|
+
rb_define_method (rb_cCairo_Context, "target", cr_get_target, 0);
|
1685
|
+
rb_define_method (rb_cCairo_Context, "group_target", cr_get_group_target, 0);
|
1686
|
+
|
1687
|
+
/* Paths */
|
1688
|
+
rb_define_method (rb_cCairo_Context, "copy_path", cr_copy_path, 0);
|
1689
|
+
rb_define_method (rb_cCairo_Context, "copy_path_flat", cr_copy_path_flat, 0);
|
1690
|
+
rb_define_method (rb_cCairo_Context, "append_path", cr_copy_append_path, 1);
|
1691
|
+
|
1692
|
+
RB_CAIRO_DEF_SETTERS (rb_cCairo_Context);
|
1693
|
+
}
|