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,459 @@
|
|
1
|
+
/* -*- c-file-style: "gnu"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Ruby Cairo Binding
|
4
|
+
*
|
5
|
+
* $Author: kou $
|
6
|
+
* $Date: 2008-04-04 03:52:31 $
|
7
|
+
*
|
8
|
+
* Copyright 2005 Kouhei Sutou <kou@cozmixng.org>
|
9
|
+
*
|
10
|
+
* This file is made available under the same terms as Ruby
|
11
|
+
*
|
12
|
+
*/
|
13
|
+
|
14
|
+
#include "rb_cairo.h"
|
15
|
+
#include "rb_cairo_private.h"
|
16
|
+
|
17
|
+
#define _SELF(self) (RVAL2CRPATH (self))
|
18
|
+
|
19
|
+
VALUE rb_cCairo_Point;
|
20
|
+
VALUE rb_cCairo_Path;
|
21
|
+
VALUE rb_cCairo_PathData;
|
22
|
+
VALUE rb_cCairo_PathMoveTo;
|
23
|
+
VALUE rb_cCairo_PathLineTo;
|
24
|
+
VALUE rb_cCairo_PathCurveTo;
|
25
|
+
VALUE rb_cCairo_PathClosePath;
|
26
|
+
|
27
|
+
static ID id_new, id_current_path;
|
28
|
+
static ID id_at_x, id_at_y, id_at_type, id_at_points, id_at_context;
|
29
|
+
|
30
|
+
static VALUE
|
31
|
+
cr_point_new (VALUE x, VALUE y)
|
32
|
+
{
|
33
|
+
return rb_funcall (rb_cCairo_Point, id_new, 2, x, y);
|
34
|
+
}
|
35
|
+
|
36
|
+
static VALUE
|
37
|
+
cr_point_initialize (VALUE self, VALUE x, VALUE y)
|
38
|
+
{
|
39
|
+
rb_ivar_set (self, id_at_x, x);
|
40
|
+
rb_ivar_set (self, id_at_y, y);
|
41
|
+
return Qnil;
|
42
|
+
}
|
43
|
+
|
44
|
+
static VALUE
|
45
|
+
cr_point_to_a (VALUE self)
|
46
|
+
{
|
47
|
+
return rb_ary_new3 (2,
|
48
|
+
rb_ivar_get (self, id_at_x),
|
49
|
+
rb_ivar_get (self, id_at_y));
|
50
|
+
}
|
51
|
+
|
52
|
+
static VALUE
|
53
|
+
cr_path_data_initialize (VALUE self, VALUE type, VALUE points)
|
54
|
+
{
|
55
|
+
rb_ivar_set (self, id_at_type, type);
|
56
|
+
rb_ivar_set (self, id_at_points, points);
|
57
|
+
return Qnil;
|
58
|
+
}
|
59
|
+
|
60
|
+
static VALUE
|
61
|
+
cr_path_data_move_to_p (VALUE self)
|
62
|
+
{
|
63
|
+
return CBOOL2RVAL (RVAL2CRPATHDATATYPE (rb_ivar_get (self, id_at_type)) ==
|
64
|
+
CAIRO_PATH_MOVE_TO);
|
65
|
+
}
|
66
|
+
|
67
|
+
static VALUE
|
68
|
+
cr_path_data_line_to_p (VALUE self)
|
69
|
+
{
|
70
|
+
return CBOOL2RVAL (RVAL2CRPATHDATATYPE (rb_ivar_get (self, id_at_type)) ==
|
71
|
+
CAIRO_PATH_LINE_TO);
|
72
|
+
}
|
73
|
+
|
74
|
+
static VALUE
|
75
|
+
cr_path_data_curve_to_p (VALUE self)
|
76
|
+
{
|
77
|
+
return CBOOL2RVAL (RVAL2CRPATHDATATYPE (rb_ivar_get (self, id_at_type)) ==
|
78
|
+
CAIRO_PATH_CURVE_TO);
|
79
|
+
}
|
80
|
+
|
81
|
+
static VALUE
|
82
|
+
cr_path_data_close_path_p (VALUE self)
|
83
|
+
{
|
84
|
+
return CBOOL2RVAL (RVAL2CRPATHDATATYPE (rb_ivar_get (self, id_at_type)) ==
|
85
|
+
CAIRO_PATH_CLOSE_PATH);
|
86
|
+
}
|
87
|
+
|
88
|
+
static VALUE
|
89
|
+
cr_path_data_each (VALUE self)
|
90
|
+
{
|
91
|
+
return rb_ary_each (rb_ivar_get (self, id_at_points));
|
92
|
+
}
|
93
|
+
|
94
|
+
|
95
|
+
static VALUE
|
96
|
+
cr_path_data_to_a (VALUE self)
|
97
|
+
{
|
98
|
+
return rb_ary_new3 (2,
|
99
|
+
rb_ivar_get (self, id_at_type),
|
100
|
+
rb_ivar_get (self, id_at_points));
|
101
|
+
}
|
102
|
+
|
103
|
+
static VALUE
|
104
|
+
cr_path_data_to_ruby_object (cairo_path_data_t *data)
|
105
|
+
{
|
106
|
+
VALUE rb_data = Qnil;
|
107
|
+
|
108
|
+
switch (data->header.type)
|
109
|
+
{
|
110
|
+
case CAIRO_PATH_MOVE_TO:
|
111
|
+
rb_data = rb_funcall (rb_cCairo_PathMoveTo, id_new, 2,
|
112
|
+
rb_float_new (data[1].point.x),
|
113
|
+
rb_float_new (data[1].point.y));
|
114
|
+
break;
|
115
|
+
case CAIRO_PATH_LINE_TO:
|
116
|
+
rb_data = rb_funcall (rb_cCairo_PathLineTo, id_new, 2,
|
117
|
+
rb_float_new (data[1].point.x),
|
118
|
+
rb_float_new (data[1].point.y));
|
119
|
+
break;
|
120
|
+
case CAIRO_PATH_CURVE_TO:
|
121
|
+
rb_data = rb_funcall (rb_cCairo_PathCurveTo, id_new, 6,
|
122
|
+
rb_float_new (data[1].point.x),
|
123
|
+
rb_float_new (data[1].point.y),
|
124
|
+
rb_float_new (data[2].point.x),
|
125
|
+
rb_float_new (data[2].point.y),
|
126
|
+
rb_float_new (data[3].point.x),
|
127
|
+
rb_float_new (data[3].point.y));
|
128
|
+
break;
|
129
|
+
case CAIRO_PATH_CLOSE_PATH:
|
130
|
+
rb_data = rb_funcall (rb_cCairo_PathClosePath, id_new, 0);
|
131
|
+
break;
|
132
|
+
}
|
133
|
+
|
134
|
+
return rb_data;
|
135
|
+
}
|
136
|
+
|
137
|
+
|
138
|
+
static VALUE
|
139
|
+
cr_path_move_to_initialize (int argc, VALUE *argv, VALUE self)
|
140
|
+
{
|
141
|
+
VALUE point, x, y;
|
142
|
+
VALUE super_argv[2];
|
143
|
+
|
144
|
+
rb_scan_args (argc, argv, "11", &x, &y);
|
145
|
+
|
146
|
+
if (argc == 1)
|
147
|
+
point = x;
|
148
|
+
else
|
149
|
+
point = cr_point_new (x, y);
|
150
|
+
|
151
|
+
super_argv[0] = INT2NUM (CAIRO_PATH_MOVE_TO);
|
152
|
+
super_argv[1] = rb_ary_new3 (1, point);
|
153
|
+
rb_call_super (2, super_argv);
|
154
|
+
return Qnil;
|
155
|
+
}
|
156
|
+
|
157
|
+
static VALUE
|
158
|
+
cr_path_line_to_initialize (int argc, VALUE *argv, VALUE self)
|
159
|
+
{
|
160
|
+
VALUE point, x, y;
|
161
|
+
VALUE super_argv[2];
|
162
|
+
|
163
|
+
rb_scan_args (argc, argv, "11", &x, &y);
|
164
|
+
|
165
|
+
if (argc == 1)
|
166
|
+
point = x;
|
167
|
+
else
|
168
|
+
point = cr_point_new (x, y);
|
169
|
+
|
170
|
+
super_argv[0] = INT2NUM (CAIRO_PATH_LINE_TO);
|
171
|
+
super_argv[1] = rb_ary_new3 (1, point);
|
172
|
+
rb_call_super (2, super_argv);
|
173
|
+
return Qnil;
|
174
|
+
}
|
175
|
+
|
176
|
+
static VALUE
|
177
|
+
cr_path_curve_to_initialize (int argc, VALUE *argv, VALUE self)
|
178
|
+
{
|
179
|
+
VALUE point1, point2, point3, x1, y1, x2, y2, x3, y3;
|
180
|
+
VALUE super_argv[2];
|
181
|
+
|
182
|
+
rb_scan_args (argc, argv, "33", &x1, &y1, &x2, &y2, &x3, &y3);
|
183
|
+
|
184
|
+
if (argc == 3)
|
185
|
+
{
|
186
|
+
point1 = x1;
|
187
|
+
point2 = y1;
|
188
|
+
point3 = x2;
|
189
|
+
}
|
190
|
+
else if (argc == 6)
|
191
|
+
{
|
192
|
+
point1 = cr_point_new (x1, y1);
|
193
|
+
point2 = cr_point_new (x2, y2);
|
194
|
+
point3 = cr_point_new (x3, y3);
|
195
|
+
}
|
196
|
+
else
|
197
|
+
{
|
198
|
+
VALUE inspected_arg = rb_inspect (rb_ary_new4 (argc, argv));
|
199
|
+
rb_raise (rb_eArgError,
|
200
|
+
"invalid argument: %s (expect "
|
201
|
+
"(point1, point2, point3) or "
|
202
|
+
"(x1, y1, x2, y2, x3, y3))",
|
203
|
+
StringValuePtr (inspected_arg));
|
204
|
+
}
|
205
|
+
|
206
|
+
super_argv[0] = INT2NUM (CAIRO_PATH_CURVE_TO);
|
207
|
+
super_argv[1] = rb_ary_new3 (3, point1, point2, point3);
|
208
|
+
rb_call_super (2, super_argv);
|
209
|
+
return Qnil;
|
210
|
+
}
|
211
|
+
|
212
|
+
static VALUE
|
213
|
+
cr_path_close_path_initialize (VALUE self)
|
214
|
+
{
|
215
|
+
VALUE super_argv[2];
|
216
|
+
super_argv[0] = INT2NUM (CAIRO_PATH_CLOSE_PATH);
|
217
|
+
super_argv[1] = rb_ary_new ();
|
218
|
+
rb_call_super (2, super_argv);
|
219
|
+
return Qnil;
|
220
|
+
}
|
221
|
+
|
222
|
+
|
223
|
+
static void
|
224
|
+
cr_path_free (void *ptr)
|
225
|
+
{
|
226
|
+
if (ptr)
|
227
|
+
{
|
228
|
+
cairo_path_destroy ((cairo_path_t *)ptr);
|
229
|
+
}
|
230
|
+
}
|
231
|
+
|
232
|
+
cairo_path_t *
|
233
|
+
rb_cairo_path_from_ruby_object (VALUE obj)
|
234
|
+
{
|
235
|
+
VALUE context;
|
236
|
+
cairo_t *cr;
|
237
|
+
cairo_path_t *path, *copied_path;
|
238
|
+
|
239
|
+
if (!rb_cairo__is_kind_of (obj, rb_cCairo_Path))
|
240
|
+
{
|
241
|
+
rb_raise (rb_eTypeError, "not a cairo path");
|
242
|
+
}
|
243
|
+
Data_Get_Struct (obj, cairo_path_t, path);
|
244
|
+
|
245
|
+
context = rb_ivar_get (obj, id_at_context);
|
246
|
+
if (NIL_P (context))
|
247
|
+
return path;
|
248
|
+
|
249
|
+
cr = RVAL2CRCONTEXT (context);
|
250
|
+
if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
|
251
|
+
return path;
|
252
|
+
|
253
|
+
copied_path = cairo_copy_path (cr);
|
254
|
+
rb_ivar_set (obj, id_current_path, CRPATH2RVAL (copied_path));
|
255
|
+
return copied_path;
|
256
|
+
}
|
257
|
+
|
258
|
+
static void
|
259
|
+
cr_path_ensure_internal_context (VALUE rb_path, cairo_path_t *path)
|
260
|
+
{
|
261
|
+
cairo_surface_t *surface;
|
262
|
+
cairo_t *cr;
|
263
|
+
|
264
|
+
if (!NIL_P (rb_ivar_get (rb_path, id_at_context)))
|
265
|
+
return;
|
266
|
+
|
267
|
+
surface = cairo_image_surface_create (CAIRO_FORMAT_A1, 1, 1);
|
268
|
+
cr = cairo_create (surface);
|
269
|
+
if (path->num_data > 0)
|
270
|
+
cairo_append_path (cr, path);
|
271
|
+
rb_cairo_check_status (cairo_status (cr));
|
272
|
+
rb_ivar_set (rb_path, id_at_context, CRCONTEXT2RVAL (cr));
|
273
|
+
cairo_destroy (cr);
|
274
|
+
}
|
275
|
+
|
276
|
+
VALUE
|
277
|
+
rb_cairo_path_to_ruby_object (cairo_path_t *path)
|
278
|
+
{
|
279
|
+
if (path)
|
280
|
+
{
|
281
|
+
VALUE rb_path;
|
282
|
+
rb_path = Data_Wrap_Struct (rb_cCairo_Path, NULL, cr_path_free, path);
|
283
|
+
cr_path_ensure_internal_context (rb_path, path);
|
284
|
+
return rb_path;
|
285
|
+
}
|
286
|
+
else
|
287
|
+
{
|
288
|
+
return Qnil;
|
289
|
+
}
|
290
|
+
}
|
291
|
+
|
292
|
+
static VALUE
|
293
|
+
cr_path_allocate (VALUE klass)
|
294
|
+
{
|
295
|
+
return Data_Wrap_Struct (klass, NULL, cr_path_free, NULL);
|
296
|
+
}
|
297
|
+
|
298
|
+
static VALUE
|
299
|
+
cr_path_initialize (VALUE self)
|
300
|
+
{
|
301
|
+
cairo_path_t *path;
|
302
|
+
|
303
|
+
path = ALLOC(cairo_path_t);
|
304
|
+
path->status = CAIRO_STATUS_SUCCESS;
|
305
|
+
path->data = NULL;
|
306
|
+
path->num_data = 0;
|
307
|
+
|
308
|
+
DATA_PTR (self) = path;
|
309
|
+
cr_path_ensure_internal_context (self, path);
|
310
|
+
|
311
|
+
return Qnil;
|
312
|
+
}
|
313
|
+
|
314
|
+
static VALUE
|
315
|
+
cr_path_empty_p (VALUE self)
|
316
|
+
{
|
317
|
+
cairo_path_t *path = _SELF (self);
|
318
|
+
|
319
|
+
return CBOOL2RVAL (path->num_data == 0);
|
320
|
+
}
|
321
|
+
|
322
|
+
static int
|
323
|
+
cairo_path_get_size (cairo_path_t *path)
|
324
|
+
{
|
325
|
+
int i, size;
|
326
|
+
|
327
|
+
for (i = 0, size = 0; i < path->num_data; i += path->data[i].header.length)
|
328
|
+
size++;
|
329
|
+
|
330
|
+
return size;
|
331
|
+
}
|
332
|
+
|
333
|
+
static VALUE
|
334
|
+
cr_path_size (VALUE self)
|
335
|
+
{
|
336
|
+
cairo_path_t *path = _SELF (self);
|
337
|
+
return INT2NUM (cairo_path_get_size (path));
|
338
|
+
}
|
339
|
+
|
340
|
+
static VALUE
|
341
|
+
cr_path_ref (VALUE self, VALUE index)
|
342
|
+
{
|
343
|
+
cairo_path_t *path = _SELF (self);
|
344
|
+
int i, requested_index, real_index;
|
345
|
+
|
346
|
+
requested_index = NUM2INT (index);
|
347
|
+
if (requested_index < 0)
|
348
|
+
{
|
349
|
+
requested_index += cairo_path_get_size (path);
|
350
|
+
if (requested_index < 0)
|
351
|
+
return Qnil;
|
352
|
+
}
|
353
|
+
|
354
|
+
|
355
|
+
for (i = 0, real_index = 0; i < requested_index; i++)
|
356
|
+
{
|
357
|
+
if (real_index >= path->num_data)
|
358
|
+
return Qnil;
|
359
|
+
real_index += path->data[real_index].header.length;
|
360
|
+
}
|
361
|
+
|
362
|
+
if (real_index < path->num_data)
|
363
|
+
return cr_path_data_to_ruby_object (&path->data[real_index]);
|
364
|
+
else
|
365
|
+
return Qnil;
|
366
|
+
}
|
367
|
+
|
368
|
+
static VALUE
|
369
|
+
cr_path_each (VALUE self)
|
370
|
+
{
|
371
|
+
cairo_path_t *path = _SELF(self);
|
372
|
+
int i;
|
373
|
+
|
374
|
+
for (i = 0; i < path->num_data; i += path->data[i].header.length)
|
375
|
+
{
|
376
|
+
rb_yield (cr_path_data_to_ruby_object (&(path->data[i])));
|
377
|
+
}
|
378
|
+
|
379
|
+
return self;
|
380
|
+
}
|
381
|
+
|
382
|
+
void
|
383
|
+
Init_cairo_path (void)
|
384
|
+
{
|
385
|
+
id_new = rb_intern ("new");
|
386
|
+
id_current_path = rb_intern ("current_path");
|
387
|
+
|
388
|
+
id_at_x = rb_intern ("@x");
|
389
|
+
id_at_y = rb_intern ("@y");
|
390
|
+
id_at_type = rb_intern ("@type");
|
391
|
+
id_at_points = rb_intern ("@points");
|
392
|
+
id_at_context = rb_intern ("@context");
|
393
|
+
|
394
|
+
rb_cCairo_Point = rb_define_class_under (rb_mCairo, "Point", rb_cObject);
|
395
|
+
rb_define_attr (rb_cCairo_Point, "x", CR_TRUE, CR_FALSE);
|
396
|
+
rb_define_attr (rb_cCairo_Point, "y", CR_TRUE, CR_FALSE);
|
397
|
+
rb_define_method (rb_cCairo_Point, "initialize", cr_point_initialize, 2);
|
398
|
+
|
399
|
+
rb_define_method (rb_cCairo_Point, "to_a", cr_point_to_a, 0);
|
400
|
+
rb_define_alias (rb_cCairo_Point, "to_ary", "to_a");
|
401
|
+
|
402
|
+
|
403
|
+
rb_cCairo_PathData = rb_define_class_under (rb_mCairo, "PathData", rb_cObject);
|
404
|
+
|
405
|
+
rb_include_module (rb_cCairo_PathData, rb_mEnumerable);
|
406
|
+
|
407
|
+
rb_define_attr (rb_cCairo_PathData, "type", CR_TRUE, CR_FALSE);
|
408
|
+
rb_define_attr (rb_cCairo_PathData, "points", CR_TRUE, CR_FALSE);
|
409
|
+
rb_define_method (rb_cCairo_PathData, "initialize",
|
410
|
+
cr_path_data_initialize, 2);
|
411
|
+
|
412
|
+
rb_define_method (rb_cCairo_PathData, "move_to?", cr_path_data_move_to_p, 0);
|
413
|
+
rb_define_method (rb_cCairo_PathData, "line_to?", cr_path_data_line_to_p, 0);
|
414
|
+
rb_define_method (rb_cCairo_PathData, "curve_to?",
|
415
|
+
cr_path_data_curve_to_p, 0);
|
416
|
+
rb_define_method (rb_cCairo_PathData, "close_path?",
|
417
|
+
cr_path_data_close_path_p, 0);
|
418
|
+
|
419
|
+
rb_define_method (rb_cCairo_PathData, "each", cr_path_data_each, 0);
|
420
|
+
|
421
|
+
rb_define_method (rb_cCairo_PathData, "to_a", cr_path_data_to_a, 0);
|
422
|
+
rb_define_alias (rb_cCairo_PathData, "to_ary", "to_a");
|
423
|
+
|
424
|
+
|
425
|
+
rb_cCairo_PathMoveTo =
|
426
|
+
rb_define_class_under (rb_mCairo, "PathMoveTo", rb_cCairo_PathData);
|
427
|
+
rb_define_method (rb_cCairo_PathMoveTo, "initialize",
|
428
|
+
cr_path_move_to_initialize, -1);
|
429
|
+
|
430
|
+
rb_cCairo_PathLineTo =
|
431
|
+
rb_define_class_under (rb_mCairo, "PathLineTo", rb_cCairo_PathData);
|
432
|
+
rb_define_method (rb_cCairo_PathLineTo, "initialize",
|
433
|
+
cr_path_line_to_initialize, -1);
|
434
|
+
|
435
|
+
rb_cCairo_PathCurveTo =
|
436
|
+
rb_define_class_under (rb_mCairo, "PathCurveTo", rb_cCairo_PathData);
|
437
|
+
rb_define_method (rb_cCairo_PathCurveTo, "initialize",
|
438
|
+
cr_path_curve_to_initialize, -1);
|
439
|
+
|
440
|
+
rb_cCairo_PathClosePath =
|
441
|
+
rb_define_class_under (rb_mCairo, "PathClosePath", rb_cCairo_PathData);
|
442
|
+
rb_define_method (rb_cCairo_PathClosePath, "initialize",
|
443
|
+
cr_path_close_path_initialize, 0);
|
444
|
+
|
445
|
+
|
446
|
+
rb_cCairo_Path = rb_define_class_under (rb_mCairo, "Path", rb_cObject);
|
447
|
+
rb_define_alloc_func (rb_cCairo_Path, cr_path_allocate);
|
448
|
+
|
449
|
+
rb_include_module (rb_cCairo_Path, rb_mEnumerable);
|
450
|
+
|
451
|
+
rb_define_method (rb_cCairo_Path, "initialize", cr_path_initialize, 0);
|
452
|
+
|
453
|
+
rb_define_method (rb_cCairo_Path, "empty?", cr_path_empty_p, 0);
|
454
|
+
rb_define_method (rb_cCairo_Path, "size", cr_path_size, 0);
|
455
|
+
rb_define_alias (rb_cCairo_Path, "length", "size");
|
456
|
+
rb_define_method (rb_cCairo_Path, "[]", cr_path_ref, 1);
|
457
|
+
|
458
|
+
rb_define_method (rb_cCairo_Path, "each", cr_path_each, 0);
|
459
|
+
}
|