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,540 @@
|
|
1
|
+
/* -*- c-file-style: "gnu"; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Ruby Cairo Binding
|
4
|
+
*
|
5
|
+
* $Author: kou $
|
6
|
+
* $Date: 2008-06-12 10:59:54 $
|
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
|
+
VALUE rb_cCairo_Pattern;
|
19
|
+
VALUE rb_cCairo_SolidPattern;
|
20
|
+
VALUE rb_cCairo_SurfacePattern;
|
21
|
+
VALUE rb_cCairo_GradientPattern;
|
22
|
+
VALUE rb_cCairo_LinearPattern;
|
23
|
+
VALUE rb_cCairo_RadialPattern;
|
24
|
+
|
25
|
+
static ID id_parse, id_to_rgb, id_to_a, id_inspect;
|
26
|
+
|
27
|
+
#define _SELF(self) (RVAL2CRPATTERN(self))
|
28
|
+
|
29
|
+
static VALUE
|
30
|
+
cr_color_parse (VALUE color)
|
31
|
+
{
|
32
|
+
return rb_funcall (rb_mCairo_Color, id_parse, 1, color);
|
33
|
+
}
|
34
|
+
|
35
|
+
static inline void
|
36
|
+
cr_pattern_check_status (cairo_pattern_t *pattern)
|
37
|
+
{
|
38
|
+
rb_cairo_check_status (cairo_pattern_status (pattern));
|
39
|
+
}
|
40
|
+
|
41
|
+
static VALUE
|
42
|
+
cr_pattern_get_klass (cairo_pattern_t *pattern)
|
43
|
+
{
|
44
|
+
VALUE klass;
|
45
|
+
cairo_pattern_type_t type;
|
46
|
+
|
47
|
+
type = cairo_pattern_get_type (pattern);
|
48
|
+
switch (type)
|
49
|
+
{
|
50
|
+
case CAIRO_PATTERN_TYPE_SOLID:
|
51
|
+
klass = rb_cCairo_SolidPattern;
|
52
|
+
break;
|
53
|
+
case CAIRO_PATTERN_TYPE_SURFACE:
|
54
|
+
klass = rb_cCairo_SurfacePattern;
|
55
|
+
break;
|
56
|
+
case CAIRO_PATTERN_TYPE_LINEAR:
|
57
|
+
klass = rb_cCairo_LinearPattern;
|
58
|
+
break;
|
59
|
+
case CAIRO_PATTERN_TYPE_RADIAL:
|
60
|
+
klass = rb_cCairo_RadialPattern;
|
61
|
+
break;
|
62
|
+
default:
|
63
|
+
rb_raise (rb_eArgError, "unknown pattern type: %d", type);
|
64
|
+
break;
|
65
|
+
}
|
66
|
+
|
67
|
+
return klass;
|
68
|
+
}
|
69
|
+
|
70
|
+
|
71
|
+
cairo_pattern_t *
|
72
|
+
rb_cairo_pattern_from_ruby_object (VALUE obj)
|
73
|
+
{
|
74
|
+
cairo_pattern_t *pattern;
|
75
|
+
if (!rb_cairo__is_kind_of (obj, rb_cCairo_Pattern))
|
76
|
+
{
|
77
|
+
rb_raise (rb_eTypeError, "not a cairo pattern");
|
78
|
+
}
|
79
|
+
Data_Get_Struct (obj, cairo_pattern_t, pattern);
|
80
|
+
return pattern;
|
81
|
+
}
|
82
|
+
|
83
|
+
static void
|
84
|
+
cr_pattern_free (void *ptr)
|
85
|
+
{
|
86
|
+
if (ptr)
|
87
|
+
{
|
88
|
+
cairo_pattern_destroy ((cairo_pattern_t *) ptr);
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
VALUE
|
93
|
+
rb_cairo_pattern_to_ruby_object (cairo_pattern_t *pattern)
|
94
|
+
{
|
95
|
+
if (pattern)
|
96
|
+
{
|
97
|
+
VALUE klass;
|
98
|
+
klass = cr_pattern_get_klass (pattern);
|
99
|
+
cairo_pattern_reference (pattern);
|
100
|
+
return Data_Wrap_Struct (klass, NULL, cr_pattern_free, pattern);
|
101
|
+
}
|
102
|
+
else
|
103
|
+
{
|
104
|
+
return Qnil;
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
static VALUE
|
109
|
+
cr_pattern_allocate (VALUE klass)
|
110
|
+
{
|
111
|
+
return Data_Wrap_Struct (klass, NULL, cr_pattern_free, NULL);
|
112
|
+
}
|
113
|
+
|
114
|
+
static VALUE
|
115
|
+
cr_pattern_initialize (VALUE self)
|
116
|
+
{
|
117
|
+
rb_raise (rb_eTypeError, "abstract class");
|
118
|
+
return Qnil;
|
119
|
+
}
|
120
|
+
|
121
|
+
static VALUE
|
122
|
+
cr_solid_pattern_initialize (int argc, VALUE *argv, VALUE self)
|
123
|
+
{
|
124
|
+
VALUE red, green, blue, alpha;
|
125
|
+
int n;
|
126
|
+
cairo_pattern_t *pattern;
|
127
|
+
|
128
|
+
n = rb_scan_args (argc, argv, "13", &red, &green, &blue, &alpha);
|
129
|
+
|
130
|
+
if (n == 1)
|
131
|
+
{
|
132
|
+
VALUE color = red;
|
133
|
+
|
134
|
+
color = cr_color_parse (color);
|
135
|
+
if (rb_cairo__is_kind_of (color, rb_cCairo_Color_Base))
|
136
|
+
red = rb_funcall (rb_funcall (color, id_to_rgb, 0), id_to_a, 0);
|
137
|
+
}
|
138
|
+
|
139
|
+
if (n == 1 && rb_cairo__is_kind_of (red, rb_cArray) &&
|
140
|
+
(RARRAY_LEN (red) == 3 || RARRAY_LEN (red) == 4))
|
141
|
+
{
|
142
|
+
VALUE ary = red;
|
143
|
+
n = RARRAY_LEN (ary);
|
144
|
+
|
145
|
+
red = rb_ary_entry (ary, 0);
|
146
|
+
green = rb_ary_entry (ary, 1);
|
147
|
+
blue = rb_ary_entry (ary, 2);
|
148
|
+
alpha = rb_ary_entry (ary, 3);
|
149
|
+
}
|
150
|
+
|
151
|
+
if (n == 3)
|
152
|
+
{
|
153
|
+
pattern = cairo_pattern_create_rgb (NUM2DBL (red),
|
154
|
+
NUM2DBL (green),
|
155
|
+
NUM2DBL (blue));
|
156
|
+
}
|
157
|
+
else if (n == 4)
|
158
|
+
{
|
159
|
+
pattern = cairo_pattern_create_rgba (NUM2DBL (red),
|
160
|
+
NUM2DBL (green),
|
161
|
+
NUM2DBL (blue),
|
162
|
+
NUM2DBL (alpha));
|
163
|
+
}
|
164
|
+
else
|
165
|
+
{
|
166
|
+
VALUE inspected;
|
167
|
+
|
168
|
+
inspected = rb_funcall (argc == 1 ? red : rb_ary_new4 (argc, argv),
|
169
|
+
id_inspect, 0);
|
170
|
+
rb_raise (rb_eArgError,
|
171
|
+
"invalid argument: %s (expect "
|
172
|
+
"(color_name), "
|
173
|
+
"(color_hex_triplet), "
|
174
|
+
"(Cairo::Color::RGB), "
|
175
|
+
"(Cairo::Color::CMYK), "
|
176
|
+
"(Cairo::Color::HSV), "
|
177
|
+
"(red, green, blue), "
|
178
|
+
"([red, green, blue]), "
|
179
|
+
"(red, green, blue, alpha) or "
|
180
|
+
"([red, green, blue, alpha])"
|
181
|
+
")",
|
182
|
+
RVAL2CSTR (inspected));
|
183
|
+
}
|
184
|
+
|
185
|
+
cr_pattern_check_status (pattern);
|
186
|
+
DATA_PTR (self) = pattern;
|
187
|
+
return Qnil;
|
188
|
+
}
|
189
|
+
|
190
|
+
static VALUE
|
191
|
+
cr_surface_pattern_initialize (VALUE self, VALUE surface)
|
192
|
+
{
|
193
|
+
cairo_pattern_t *pattern;
|
194
|
+
|
195
|
+
pattern = cairo_pattern_create_for_surface (RVAL2CRSURFACE (surface));
|
196
|
+
cr_pattern_check_status (pattern);
|
197
|
+
DATA_PTR (self) = pattern;
|
198
|
+
return Qnil;
|
199
|
+
}
|
200
|
+
|
201
|
+
static VALUE
|
202
|
+
cr_linear_pattern_initialize (VALUE self, VALUE x0, VALUE y0,
|
203
|
+
VALUE x1, VALUE y1)
|
204
|
+
{
|
205
|
+
cairo_pattern_t *pattern;
|
206
|
+
|
207
|
+
pattern = cairo_pattern_create_linear (NUM2DBL (x0), NUM2DBL (y0),
|
208
|
+
NUM2DBL (x1), NUM2DBL (y1));
|
209
|
+
cr_pattern_check_status (pattern);
|
210
|
+
DATA_PTR (self) = pattern;
|
211
|
+
return Qnil;
|
212
|
+
}
|
213
|
+
|
214
|
+
static VALUE
|
215
|
+
cr_radial_pattern_initialize (VALUE self, VALUE cx0, VALUE cy0, VALUE radius0,
|
216
|
+
VALUE cx1, VALUE cy1, VALUE radius1)
|
217
|
+
{
|
218
|
+
cairo_pattern_t *pattern;
|
219
|
+
|
220
|
+
pattern = cairo_pattern_create_radial (NUM2DBL (cx0), NUM2DBL (cy0),
|
221
|
+
NUM2DBL (radius0),
|
222
|
+
NUM2DBL (cx1), NUM2DBL (cy1),
|
223
|
+
NUM2DBL (radius1));
|
224
|
+
cr_pattern_check_status (pattern);
|
225
|
+
DATA_PTR (self) = pattern;
|
226
|
+
return Qnil;
|
227
|
+
}
|
228
|
+
|
229
|
+
/* Cairo::GradientPattern */
|
230
|
+
static VALUE
|
231
|
+
cr_gradient_pattern_add_color_stop_generic (int argc, VALUE *argv, VALUE self)
|
232
|
+
{
|
233
|
+
VALUE offset, red, green, blue, alpha;
|
234
|
+
int n;
|
235
|
+
|
236
|
+
n = rb_scan_args (argc, argv, "23", &offset, &red, &green, &blue, &alpha);
|
237
|
+
|
238
|
+
if (n == 2)
|
239
|
+
{
|
240
|
+
VALUE color = red;
|
241
|
+
|
242
|
+
color = cr_color_parse (color);
|
243
|
+
if (rb_cairo__is_kind_of (color, rb_cCairo_Color_Base))
|
244
|
+
red = rb_funcall (rb_funcall (color, id_to_rgb, 0), id_to_a, 0);
|
245
|
+
}
|
246
|
+
|
247
|
+
if (n == 2 && rb_cairo__is_kind_of (red, rb_cArray))
|
248
|
+
{
|
249
|
+
VALUE ary = red;
|
250
|
+
n = RARRAY_LEN (ary) + 1;
|
251
|
+
|
252
|
+
red = rb_ary_entry (ary, 0);
|
253
|
+
green = rb_ary_entry (ary, 1);
|
254
|
+
blue = rb_ary_entry (ary, 2);
|
255
|
+
alpha = rb_ary_entry (ary, 3);
|
256
|
+
}
|
257
|
+
|
258
|
+
if (n == 4 || (n == 5 && NIL_P (alpha)))
|
259
|
+
{
|
260
|
+
cairo_pattern_add_color_stop_rgb (_SELF (self), NUM2DBL (offset),
|
261
|
+
NUM2DBL (red), NUM2DBL (green),
|
262
|
+
NUM2DBL (blue));
|
263
|
+
}
|
264
|
+
else if (n == 5)
|
265
|
+
{
|
266
|
+
cairo_pattern_add_color_stop_rgba (_SELF (self), NUM2DBL (offset),
|
267
|
+
NUM2DBL (red), NUM2DBL (green),
|
268
|
+
NUM2DBL (blue), NUM2DBL (alpha));
|
269
|
+
}
|
270
|
+
else
|
271
|
+
{
|
272
|
+
VALUE inspected;
|
273
|
+
|
274
|
+
inspected = rb_funcall (rb_ary_new4 (argc, argv), id_inspect, 0);
|
275
|
+
rb_raise (rb_eArgError,
|
276
|
+
"invalid argument: %s (expect "
|
277
|
+
"(offset, color_name), "
|
278
|
+
"(offset, color_hex_triplet), "
|
279
|
+
"(offset, Cairo::Color::RGB), "
|
280
|
+
"(offset, Cairo::Color::CMYK), "
|
281
|
+
"(offset, Cairo::Color::HSV), "
|
282
|
+
"(offset, red, green, blue), "
|
283
|
+
"(offset, [red, green, blue]), "
|
284
|
+
"(offset, red, green, blue, alpha) or "
|
285
|
+
"(offset, [red, green, blue, alpha])"
|
286
|
+
")",
|
287
|
+
RVAL2CSTR (inspected));
|
288
|
+
}
|
289
|
+
|
290
|
+
cr_pattern_check_status (_SELF (self));
|
291
|
+
return self;
|
292
|
+
}
|
293
|
+
|
294
|
+
/* Cairo::Pattern */
|
295
|
+
static VALUE
|
296
|
+
cr_pattern_set_matrix (VALUE self, VALUE matrix)
|
297
|
+
{
|
298
|
+
cairo_pattern_set_matrix (_SELF (self), RVAL2CRMATRIX (matrix));
|
299
|
+
cr_pattern_check_status (_SELF (self));
|
300
|
+
return self;
|
301
|
+
}
|
302
|
+
|
303
|
+
static VALUE
|
304
|
+
cr_pattern_get_matrix (VALUE self)
|
305
|
+
{
|
306
|
+
cairo_matrix_t matrix;
|
307
|
+
cairo_pattern_get_matrix (_SELF (self), &matrix);
|
308
|
+
cr_pattern_check_status (_SELF (self));
|
309
|
+
return CRMATRIX2RVAL (&matrix);
|
310
|
+
}
|
311
|
+
|
312
|
+
static VALUE
|
313
|
+
cr_pattern_set_extend (VALUE self, VALUE extend)
|
314
|
+
{
|
315
|
+
cairo_pattern_set_extend (_SELF (self), RVAL2CREXTEND (extend));
|
316
|
+
cr_pattern_check_status (_SELF (self));
|
317
|
+
return self;
|
318
|
+
}
|
319
|
+
|
320
|
+
static VALUE
|
321
|
+
cr_pattern_get_extend (VALUE self)
|
322
|
+
{
|
323
|
+
return INT2NUM (cairo_pattern_get_extend (_SELF (self)));
|
324
|
+
}
|
325
|
+
|
326
|
+
static VALUE
|
327
|
+
cr_pattern_set_filter (VALUE self, VALUE filter)
|
328
|
+
{
|
329
|
+
cairo_pattern_set_filter (_SELF (self), RVAL2CRFILTER (filter));
|
330
|
+
cr_pattern_check_status (_SELF (self));
|
331
|
+
return self;
|
332
|
+
}
|
333
|
+
|
334
|
+
static VALUE
|
335
|
+
cr_pattern_get_filter (VALUE self)
|
336
|
+
{
|
337
|
+
return INT2NUM (cairo_pattern_get_filter (_SELF (self)));
|
338
|
+
}
|
339
|
+
|
340
|
+
#if CAIRO_CHECK_VERSION(1, 3, 0)
|
341
|
+
static VALUE
|
342
|
+
cr_solid_pattern_get_rgba (VALUE self)
|
343
|
+
{
|
344
|
+
double red, green, blue, alpha;
|
345
|
+
|
346
|
+
rb_cairo_check_status (cairo_pattern_get_rgba (_SELF (self),
|
347
|
+
&red, &green, &blue, &alpha));
|
348
|
+
return rb_ary_new3 (4,
|
349
|
+
rb_float_new (red), rb_float_new (green),
|
350
|
+
rb_float_new (blue), rb_float_new (alpha));
|
351
|
+
}
|
352
|
+
|
353
|
+
static VALUE
|
354
|
+
cr_solid_pattern_get_color (VALUE self)
|
355
|
+
{
|
356
|
+
return cr_color_parse (cr_solid_pattern_get_rgba (self));
|
357
|
+
}
|
358
|
+
|
359
|
+
static VALUE
|
360
|
+
cr_surface_pattern_get_surface (VALUE self)
|
361
|
+
{
|
362
|
+
cairo_surface_t *surface;
|
363
|
+
|
364
|
+
rb_cairo_check_status (cairo_pattern_get_surface (_SELF (self), &surface));
|
365
|
+
return CRSURFACE2RVAL (surface);
|
366
|
+
}
|
367
|
+
|
368
|
+
static VALUE
|
369
|
+
cr_gradient_pattern_get_color_stop_rgba (VALUE self, VALUE index)
|
370
|
+
{
|
371
|
+
cairo_status_t status;
|
372
|
+
double offset, red, green, blue, alpha;
|
373
|
+
|
374
|
+
status = cairo_pattern_get_color_stop_rgba (_SELF (self), NUM2INT (index),
|
375
|
+
&offset, &red, &green, &blue,
|
376
|
+
&alpha);
|
377
|
+
rb_cairo_check_status (status);
|
378
|
+
return rb_ary_new3 (5, rb_float_new (offset),
|
379
|
+
rb_float_new (red), rb_float_new (green),
|
380
|
+
rb_float_new (blue), rb_float_new (alpha));
|
381
|
+
}
|
382
|
+
|
383
|
+
static VALUE
|
384
|
+
cr_gradient_pattern_get_color_stop_color (VALUE self, VALUE index)
|
385
|
+
{
|
386
|
+
VALUE result, offset, rgba;
|
387
|
+
|
388
|
+
result = cr_gradient_pattern_get_color_stop_rgba (self, index);
|
389
|
+
offset = rb_ary_shift (result);
|
390
|
+
rgba = result;
|
391
|
+
|
392
|
+
return rb_ary_new3 (2, offset, cr_color_parse (rgba));
|
393
|
+
}
|
394
|
+
|
395
|
+
static VALUE
|
396
|
+
cr_gradient_pattern_get_color_stop_count (VALUE self)
|
397
|
+
{
|
398
|
+
cairo_status_t status;
|
399
|
+
int count;
|
400
|
+
|
401
|
+
status = cairo_pattern_get_color_stop_count (_SELF (self), &count);
|
402
|
+
rb_cairo_check_status (status);
|
403
|
+
return INT2NUM (count);
|
404
|
+
}
|
405
|
+
|
406
|
+
static VALUE
|
407
|
+
cr_linear_pattern_get_linear_points (VALUE self)
|
408
|
+
{
|
409
|
+
cairo_status_t status;
|
410
|
+
double x0, y0, x1, y1;
|
411
|
+
|
412
|
+
status = cairo_pattern_get_linear_points (_SELF (self), &x0, &y0, &x1, &y1);
|
413
|
+
rb_cairo_check_status (status);
|
414
|
+
return rb_ary_new3 (4,
|
415
|
+
rb_float_new (x0), rb_float_new (y0),
|
416
|
+
rb_float_new (x1), rb_float_new (y1));
|
417
|
+
}
|
418
|
+
|
419
|
+
static VALUE
|
420
|
+
cr_radial_pattern_get_radial_circles (VALUE self)
|
421
|
+
{
|
422
|
+
cairo_status_t status;
|
423
|
+
double x0, y0, r0, x1, y1, r1;
|
424
|
+
|
425
|
+
status = cairo_pattern_get_radial_circles (_SELF (self),
|
426
|
+
&x0, &y0, &r0,
|
427
|
+
&x1, &y1, &r1);
|
428
|
+
rb_cairo_check_status (status);
|
429
|
+
return rb_ary_new3 (2,
|
430
|
+
rb_ary_new3 (3,
|
431
|
+
rb_float_new (x0),
|
432
|
+
rb_float_new (y0),
|
433
|
+
rb_float_new (r0)),
|
434
|
+
rb_ary_new3 (3,
|
435
|
+
rb_float_new (x1),
|
436
|
+
rb_float_new (y1),
|
437
|
+
rb_float_new (r1)));
|
438
|
+
}
|
439
|
+
#endif
|
440
|
+
|
441
|
+
/* Cairo::SurfacePattern */
|
442
|
+
/* none */
|
443
|
+
|
444
|
+
void
|
445
|
+
Init_cairo_pattern (void)
|
446
|
+
{
|
447
|
+
id_parse = rb_intern ("parse");
|
448
|
+
id_to_rgb = rb_intern ("to_rgb");
|
449
|
+
id_to_a = rb_intern ("to_a");
|
450
|
+
id_inspect = rb_intern ("inspect");
|
451
|
+
|
452
|
+
rb_cCairo_Pattern =
|
453
|
+
rb_define_class_under (rb_mCairo, "Pattern", rb_cObject);
|
454
|
+
|
455
|
+
rb_define_alloc_func (rb_cCairo_Pattern, cr_pattern_allocate);
|
456
|
+
|
457
|
+
rb_define_method (rb_cCairo_Pattern, "initialize", cr_pattern_initialize, 0);
|
458
|
+
|
459
|
+
rb_define_method (rb_cCairo_Pattern, "set_matrix", cr_pattern_set_matrix, 1);
|
460
|
+
rb_define_method (rb_cCairo_Pattern, "matrix", cr_pattern_get_matrix, 0);
|
461
|
+
rb_define_method (rb_cCairo_Pattern, "set_extend", cr_pattern_set_extend, 1);
|
462
|
+
rb_define_alias (rb_cCairo_Pattern, "__extend__", "extend");
|
463
|
+
rb_define_method (rb_cCairo_Pattern, "extend", cr_pattern_get_extend, 0);
|
464
|
+
rb_define_method (rb_cCairo_Pattern, "set_filter", cr_pattern_set_filter, 1);
|
465
|
+
rb_define_method (rb_cCairo_Pattern, "filter", cr_pattern_get_filter, 0);
|
466
|
+
|
467
|
+
RB_CAIRO_DEF_SETTERS (rb_cCairo_Pattern);
|
468
|
+
|
469
|
+
rb_cCairo_SolidPattern =
|
470
|
+
rb_define_class_under (rb_mCairo, "SolidPattern", rb_cCairo_Pattern);
|
471
|
+
|
472
|
+
rb_define_method (rb_cCairo_SolidPattern, "initialize",
|
473
|
+
cr_solid_pattern_initialize, -1);
|
474
|
+
#if CAIRO_CHECK_VERSION(1, 3, 0)
|
475
|
+
rb_define_method (rb_cCairo_SolidPattern, "rgba",
|
476
|
+
cr_solid_pattern_get_rgba, 0);
|
477
|
+
rb_define_method (rb_cCairo_SolidPattern, "color",
|
478
|
+
cr_solid_pattern_get_color, 0);
|
479
|
+
#endif
|
480
|
+
|
481
|
+
RB_CAIRO_DEF_SETTERS (rb_cCairo_SolidPattern);
|
482
|
+
|
483
|
+
rb_cCairo_SurfacePattern =
|
484
|
+
rb_define_class_under (rb_mCairo, "SurfacePattern", rb_cCairo_Pattern);
|
485
|
+
|
486
|
+
rb_define_method (rb_cCairo_SurfacePattern, "initialize",
|
487
|
+
cr_surface_pattern_initialize, 1);
|
488
|
+
#if CAIRO_CHECK_VERSION(1, 3, 0)
|
489
|
+
rb_define_method (rb_cCairo_SurfacePattern, "surface",
|
490
|
+
cr_surface_pattern_get_surface, 0);
|
491
|
+
#endif
|
492
|
+
|
493
|
+
RB_CAIRO_DEF_SETTERS (rb_cCairo_SurfacePattern);
|
494
|
+
|
495
|
+
rb_cCairo_GradientPattern =
|
496
|
+
rb_define_class_under (rb_mCairo, "GradientPattern", rb_cCairo_Pattern);
|
497
|
+
|
498
|
+
rb_define_method (rb_cCairo_GradientPattern, "add_color_stop",
|
499
|
+
cr_gradient_pattern_add_color_stop_generic, -1);
|
500
|
+
rb_define_alias (rb_cCairo_GradientPattern,
|
501
|
+
"add_color_stop_rgb", "add_color_stop");
|
502
|
+
rb_define_alias (rb_cCairo_GradientPattern,
|
503
|
+
"add_color_stop_rgba", "add_color_stop");
|
504
|
+
#if CAIRO_CHECK_VERSION(1, 3, 0)
|
505
|
+
rb_define_method (rb_cCairo_GradientPattern, "get_color_stop_rgba",
|
506
|
+
cr_gradient_pattern_get_color_stop_rgba, 1);
|
507
|
+
rb_define_method (rb_cCairo_GradientPattern, "get_color_stop_color",
|
508
|
+
cr_gradient_pattern_get_color_stop_color, 1);
|
509
|
+
rb_define_method (rb_cCairo_GradientPattern, "color_stop_count",
|
510
|
+
cr_gradient_pattern_get_color_stop_count, 0);
|
511
|
+
#endif
|
512
|
+
|
513
|
+
RB_CAIRO_DEF_SETTERS (rb_cCairo_GradientPattern);
|
514
|
+
|
515
|
+
rb_cCairo_LinearPattern =
|
516
|
+
rb_define_class_under (rb_mCairo, "LinearPattern",
|
517
|
+
rb_cCairo_GradientPattern);
|
518
|
+
|
519
|
+
rb_define_method (rb_cCairo_LinearPattern, "initialize",
|
520
|
+
cr_linear_pattern_initialize, 4);
|
521
|
+
#if CAIRO_CHECK_VERSION(1, 3, 0)
|
522
|
+
rb_define_method (rb_cCairo_LinearPattern, "points",
|
523
|
+
cr_linear_pattern_get_linear_points, 0);
|
524
|
+
#endif
|
525
|
+
|
526
|
+
RB_CAIRO_DEF_SETTERS (rb_cCairo_LinearPattern);
|
527
|
+
|
528
|
+
rb_cCairo_RadialPattern =
|
529
|
+
rb_define_class_under (rb_mCairo, "RadialPattern",
|
530
|
+
rb_cCairo_GradientPattern);
|
531
|
+
|
532
|
+
rb_define_method (rb_cCairo_RadialPattern, "initialize",
|
533
|
+
cr_radial_pattern_initialize, 6);
|
534
|
+
#if CAIRO_CHECK_VERSION(1, 3, 0)
|
535
|
+
rb_define_method (rb_cCairo_RadialPattern, "circles",
|
536
|
+
cr_radial_pattern_get_radial_circles, 0);
|
537
|
+
#endif
|
538
|
+
|
539
|
+
RB_CAIRO_DEF_SETTERS (rb_cCairo_RadialPattern);
|
540
|
+
}
|