rdp-rmagick 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +769 -0
- data/Doxyfile +1514 -0
- data/README-Mac-OSX.txt +1 -0
- data/README.md +231 -0
- data/build_tarball.rake +215 -0
- data/doc/comtasks.html +287 -0
- data/doc/constants.html +1581 -0
- data/doc/css/doc.css +299 -0
- data/doc/css/popup.css +34 -0
- data/doc/css/ref.css +67 -0
- data/doc/draw.html +3269 -0
- data/doc/ex/InitialCoords.rb +23 -0
- data/doc/ex/NewCoordSys.rb +32 -0
- data/doc/ex/OrigCoordSys.rb +18 -0
- data/doc/ex/PreserveAspectRatio.rb +205 -0
- data/doc/ex/RotateScale.rb +37 -0
- data/doc/ex/Skew.rb +38 -0
- data/doc/ex/Use01.rb +16 -0
- data/doc/ex/Use02.rb +21 -0
- data/doc/ex/Use03.rb +16 -0
- data/doc/ex/ViewBox.rb +33 -0
- data/doc/ex/adaptive_threshold.rb +10 -0
- data/doc/ex/add_noise.rb +17 -0
- data/doc/ex/affine.rb +48 -0
- data/doc/ex/affine_transform.rb +20 -0
- data/doc/ex/arc.rb +49 -0
- data/doc/ex/arcpath.rb +33 -0
- data/doc/ex/arcs01.rb +28 -0
- data/doc/ex/arcs02.rb +61 -0
- data/doc/ex/average.rb +15 -0
- data/doc/ex/axes.rb +64 -0
- data/doc/ex/baseline_shift01.rb +18 -0
- data/doc/ex/bilevel_channel.rb +9 -0
- data/doc/ex/blur_image.rb +12 -0
- data/doc/ex/border.rb +10 -0
- data/doc/ex/bounding_box.rb +44 -0
- data/doc/ex/cbezier1.rb +42 -0
- data/doc/ex/cbezier2.rb +42 -0
- data/doc/ex/cbezier3.rb +42 -0
- data/doc/ex/cbezier4.rb +43 -0
- data/doc/ex/cbezier5.rb +43 -0
- data/doc/ex/cbezier6.rb +53 -0
- data/doc/ex/channel.rb +26 -0
- data/doc/ex/charcoal.rb +12 -0
- data/doc/ex/chop.rb +29 -0
- data/doc/ex/circle.rb +33 -0
- data/doc/ex/circle01.rb +17 -0
- data/doc/ex/clip_path.rb +60 -0
- data/doc/ex/coalesce.rb +60 -0
- data/doc/ex/color_fill_to_border.rb +29 -0
- data/doc/ex/color_floodfill.rb +28 -0
- data/doc/ex/color_histogram.rb +48 -0
- data/doc/ex/color_reset.rb +11 -0
- data/doc/ex/colorize.rb +16 -0
- data/doc/ex/colors.rb +64 -0
- data/doc/ex/compose_mask.rb +23 -0
- data/doc/ex/composite.rb +135 -0
- data/doc/ex/composite_layers.rb +53 -0
- data/doc/ex/composite_tiled.rb +23 -0
- data/doc/ex/contrast.rb +36 -0
- data/doc/ex/crop.rb +31 -0
- data/doc/ex/crop_with_gravity.rb +46 -0
- data/doc/ex/cubic01.rb +45 -0
- data/doc/ex/cubic02.rb +94 -0
- data/doc/ex/cycle_colormap.rb +21 -0
- data/doc/ex/dissolve.rb +13 -0
- data/doc/ex/drawcomp.rb +42 -0
- data/doc/ex/drop_shadow.rb +60 -0
- data/doc/ex/edge.rb +11 -0
- data/doc/ex/ellipse.rb +45 -0
- data/doc/ex/ellipse01.rb +22 -0
- data/doc/ex/emboss.rb +11 -0
- data/doc/ex/enhance.rb +28 -0
- data/doc/ex/equalize.rb +11 -0
- data/doc/ex/evenodd.rb +43 -0
- data/doc/ex/fill_pattern.rb +26 -0
- data/doc/ex/flatten_images.rb +36 -0
- data/doc/ex/flip.rb +11 -0
- data/doc/ex/flop.rb +11 -0
- data/doc/ex/font_styles.rb +34 -0
- data/doc/ex/fonts.rb +20 -0
- data/doc/ex/frame.rb +12 -0
- data/doc/ex/gaussian_blur.rb +11 -0
- data/doc/ex/get_multiline_type_metrics.rb +42 -0
- data/doc/ex/get_pixels.rb +48 -0
- data/doc/ex/get_type_metrics.rb +146 -0
- data/doc/ex/gradientfill.rb +27 -0
- data/doc/ex/grav.rb +46 -0
- data/doc/ex/gravity.rb +79 -0
- data/doc/ex/group.rb +26 -0
- data/doc/ex/hatchfill.rb +27 -0
- data/doc/ex/image.rb +46 -0
- data/doc/ex/images/Apple.miff +0 -0
- data/doc/ex/images/Ballerina.jpg +0 -0
- data/doc/ex/images/Ballerina3.jpg +0 -0
- data/doc/ex/images/Button_0.gif +0 -0
- data/doc/ex/images/Button_1.gif +0 -0
- data/doc/ex/images/Button_2.gif +0 -0
- data/doc/ex/images/Button_3.gif +0 -0
- data/doc/ex/images/Button_4.gif +0 -0
- data/doc/ex/images/Button_5.gif +0 -0
- data/doc/ex/images/Button_6.gif +0 -0
- data/doc/ex/images/Button_7.gif +0 -0
- data/doc/ex/images/Button_8.gif +0 -0
- data/doc/ex/images/Button_9.gif +0 -0
- data/doc/ex/images/Button_A.gif +0 -0
- data/doc/ex/images/Button_B.gif +0 -0
- data/doc/ex/images/Button_C.gif +0 -0
- data/doc/ex/images/Button_D.gif +0 -0
- data/doc/ex/images/Button_E.gif +0 -0
- data/doc/ex/images/Button_F.gif +0 -0
- data/doc/ex/images/Button_G.gif +0 -0
- data/doc/ex/images/Button_H.gif +0 -0
- data/doc/ex/images/Button_I.gif +0 -0
- data/doc/ex/images/Button_J.gif +0 -0
- data/doc/ex/images/Button_K.gif +0 -0
- data/doc/ex/images/Button_L.gif +0 -0
- data/doc/ex/images/Button_M.gif +0 -0
- data/doc/ex/images/Button_N.gif +0 -0
- data/doc/ex/images/Button_O.gif +0 -0
- data/doc/ex/images/Button_P.gif +0 -0
- data/doc/ex/images/Button_Q.gif +0 -0
- data/doc/ex/images/Button_R.gif +0 -0
- data/doc/ex/images/Button_S.gif +0 -0
- data/doc/ex/images/Button_T.gif +0 -0
- data/doc/ex/images/Button_U.gif +0 -0
- data/doc/ex/images/Button_V.gif +0 -0
- data/doc/ex/images/Button_W.gif +0 -0
- data/doc/ex/images/Button_X.gif +0 -0
- data/doc/ex/images/Button_Y.gif +0 -0
- data/doc/ex/images/Button_Z.gif +0 -0
- data/doc/ex/images/Cheetah.jpg +0 -0
- data/doc/ex/images/Coffee.wmf +0 -0
- data/doc/ex/images/Flower_Hat.jpg +0 -0
- data/doc/ex/images/Gold_Statue.jpg +0 -0
- data/doc/ex/images/Hot_Air_Balloons.jpg +0 -0
- data/doc/ex/images/Hot_Air_Balloons_H.jpg +0 -0
- data/doc/ex/images/Leaf.miff +0 -0
- data/doc/ex/images/No.wmf +0 -0
- data/doc/ex/images/Polynesia.jpg +0 -0
- data/doc/ex/images/Red_Rocks.jpg +0 -0
- data/doc/ex/images/Rocks_On_Beach.miff +0 -0
- data/doc/ex/images/Shorts.jpg +0 -0
- data/doc/ex/images/Snake.wmf +0 -0
- data/doc/ex/images/Violin.jpg +0 -0
- data/doc/ex/images/Yellow_Rose.miff +0 -0
- data/doc/ex/images/big-duck.gif +0 -0
- data/doc/ex/images/duck.gif +0 -0
- data/doc/ex/images/duck0.gif +0 -0
- data/doc/ex/images/duck1.gif +0 -0
- data/doc/ex/images/duck10.gif +0 -0
- data/doc/ex/images/duck11.gif +0 -0
- data/doc/ex/images/duck12.gif +0 -0
- data/doc/ex/images/duck13.gif +0 -0
- data/doc/ex/images/duck14.gif +0 -0
- data/doc/ex/images/duck15.gif +0 -0
- data/doc/ex/images/duck2.gif +0 -0
- data/doc/ex/images/duck3.gif +0 -0
- data/doc/ex/images/duck4.gif +0 -0
- data/doc/ex/images/duck5.gif +0 -0
- data/doc/ex/images/duck6.gif +0 -0
- data/doc/ex/images/duck7.gif +0 -0
- data/doc/ex/images/duck8.gif +0 -0
- data/doc/ex/images/duck9.gif +0 -0
- data/doc/ex/images/graydient230x6.gif +0 -0
- data/doc/ex/images/logo400x83.gif +0 -0
- data/doc/ex/images/model.miff +0 -0
- data/doc/ex/images/notimplemented.gif +0 -0
- data/doc/ex/images/smile.miff +0 -0
- data/doc/ex/images/spin.gif +0 -0
- data/doc/ex/implode.rb +34 -0
- data/doc/ex/level.rb +11 -0
- data/doc/ex/level_colors.rb +11 -0
- data/doc/ex/line.rb +42 -0
- data/doc/ex/line01.rb +23 -0
- data/doc/ex/mask.rb +36 -0
- data/doc/ex/matte_fill_to_border.rb +40 -0
- data/doc/ex/matte_floodfill.rb +33 -0
- data/doc/ex/matte_replace.rb +40 -0
- data/doc/ex/median_filter.rb +28 -0
- data/doc/ex/modulate.rb +11 -0
- data/doc/ex/mono.rb +23 -0
- data/doc/ex/morph.rb +26 -0
- data/doc/ex/mosaic.rb +35 -0
- data/doc/ex/motion_blur.rb +11 -0
- data/doc/ex/negate.rb +11 -0
- data/doc/ex/negate_channel.rb +9 -0
- data/doc/ex/nested_rvg.rb +21 -0
- data/doc/ex/nonzero.rb +43 -0
- data/doc/ex/normalize.rb +11 -0
- data/doc/ex/oil_paint.rb +11 -0
- data/doc/ex/opacity.rb +37 -0
- data/doc/ex/ordered_dither.rb +11 -0
- data/doc/ex/path.rb +64 -0
- data/doc/ex/pattern1.rb +25 -0
- data/doc/ex/pattern2.rb +26 -0
- data/doc/ex/polaroid.rb +28 -0
- data/doc/ex/polygon.rb +24 -0
- data/doc/ex/polygon01.rb +23 -0
- data/doc/ex/polyline.rb +23 -0
- data/doc/ex/polyline01.rb +23 -0
- data/doc/ex/posterize.rb +8 -0
- data/doc/ex/preview.rb +9 -0
- data/doc/ex/qbezierpath.rb +52 -0
- data/doc/ex/quad01.rb +36 -0
- data/doc/ex/quantize-m.rb +25 -0
- data/doc/ex/radial_blur.rb +9 -0
- data/doc/ex/raise.rb +8 -0
- data/doc/ex/random_threshold_channel.rb +13 -0
- data/doc/ex/rect01.rb +15 -0
- data/doc/ex/rect02.rb +22 -0
- data/doc/ex/rectangle.rb +35 -0
- data/doc/ex/reduce_noise.rb +28 -0
- data/doc/ex/remap.rb +12 -0
- data/doc/ex/remap_images.rb +21 -0
- data/doc/ex/resize_to_fill.rb +10 -0
- data/doc/ex/resize_to_fit.rb +10 -0
- data/doc/ex/roll.rb +9 -0
- data/doc/ex/rotate.rb +45 -0
- data/doc/ex/rotate_f.rb +14 -0
- data/doc/ex/roundrect.rb +34 -0
- data/doc/ex/rubyname.rb +30 -0
- data/doc/ex/rvg_clippath.rb +14 -0
- data/doc/ex/rvg_linecap.rb +43 -0
- data/doc/ex/rvg_linejoin.rb +41 -0
- data/doc/ex/rvg_opacity.rb +19 -0
- data/doc/ex/rvg_pattern.rb +26 -0
- data/doc/ex/rvg_stroke_dasharray.rb +12 -0
- data/doc/ex/segment.rb +11 -0
- data/doc/ex/sepiatone.rb +8 -0
- data/doc/ex/shade.rb +11 -0
- data/doc/ex/shadow.rb +31 -0
- data/doc/ex/shave.rb +15 -0
- data/doc/ex/shear.rb +10 -0
- data/doc/ex/sketch.rb +18 -0
- data/doc/ex/skewx.rb +52 -0
- data/doc/ex/skewy.rb +47 -0
- data/doc/ex/smile.rb +125 -0
- data/doc/ex/solarize.rb +11 -0
- data/doc/ex/sparse_color.rb +55 -0
- data/doc/ex/splice.rb +9 -0
- data/doc/ex/spread.rb +11 -0
- data/doc/ex/stegano.rb +55 -0
- data/doc/ex/stroke_dasharray.rb +43 -0
- data/doc/ex/stroke_fill.rb +11 -0
- data/doc/ex/stroke_linecap.rb +44 -0
- data/doc/ex/stroke_linejoin.rb +48 -0
- data/doc/ex/stroke_width.rb +49 -0
- data/doc/ex/swirl.rb +17 -0
- data/doc/ex/text.rb +37 -0
- data/doc/ex/text01.rb +17 -0
- data/doc/ex/text_align.rb +36 -0
- data/doc/ex/text_antialias.rb +38 -0
- data/doc/ex/text_styles.rb +21 -0
- data/doc/ex/text_undercolor.rb +28 -0
- data/doc/ex/texture_fill_to_border.rb +34 -0
- data/doc/ex/texture_floodfill.rb +32 -0
- data/doc/ex/texturefill.rb +25 -0
- data/doc/ex/threshold.rb +13 -0
- data/doc/ex/to_blob.rb +14 -0
- data/doc/ex/translate.rb +39 -0
- data/doc/ex/transparent.rb +38 -0
- data/doc/ex/transpose.rb +9 -0
- data/doc/ex/transverse.rb +9 -0
- data/doc/ex/tref01.rb +25 -0
- data/doc/ex/triangle01.rb +16 -0
- data/doc/ex/trim.rb +24 -0
- data/doc/ex/tspan01.rb +18 -0
- data/doc/ex/tspan02.rb +19 -0
- data/doc/ex/tspan03.rb +21 -0
- data/doc/ex/unsharp_mask.rb +28 -0
- data/doc/ex/viewex.rb +35 -0
- data/doc/ex/vignette.rb +12 -0
- data/doc/ex/watermark.rb +28 -0
- data/doc/ex/wave.rb +9 -0
- data/doc/ex/wet_floor.rb +59 -0
- data/doc/ex/writing_mode01.rb +27 -0
- data/doc/ex/writing_mode02.rb +26 -0
- data/doc/ilist.html +2056 -0
- data/doc/image1.html +4680 -0
- data/doc/image2.html +3665 -0
- data/doc/image3.html +4522 -0
- data/doc/imageattrs.html +1638 -0
- data/doc/imusage.html +514 -0
- data/doc/index.html +416 -0
- data/doc/info.html +1499 -0
- data/doc/magick.html +565 -0
- data/doc/optequiv.html +2435 -0
- data/doc/rvg.html +975 -0
- data/doc/rvgclip.html +248 -0
- data/doc/rvggroup.html +305 -0
- data/doc/rvgimage.html +289 -0
- data/doc/rvgpattern.html +475 -0
- data/doc/rvgshape.html +406 -0
- data/doc/rvgstyle.html +270 -0
- data/doc/rvgtext.html +465 -0
- data/doc/rvgtspan.html +238 -0
- data/doc/rvgtut.html +530 -0
- data/doc/rvguse.html +145 -0
- data/doc/rvgxform.html +294 -0
- data/doc/scripts/doc.js +22 -0
- data/doc/scripts/stripeTables.js +23 -0
- data/doc/struct.html +1339 -0
- data/doc/usage.html +1621 -0
- data/examples/constitute.rb +7 -0
- data/examples/crop_with_gravity.rb +46 -0
- data/examples/demo.rb +324 -0
- data/examples/describe.rb +44 -0
- data/examples/find_similar_region.rb +34 -0
- data/examples/histogram.rb +325 -0
- data/examples/identify.rb +187 -0
- data/examples/image_opacity.rb +29 -0
- data/examples/import_export.rb +31 -0
- data/examples/pattern_fill.rb +38 -0
- data/examples/rotating_text.rb +45 -0
- data/examples/spinner.rb +50 -0
- data/examples/thumbnail.rb +65 -0
- data/examples/vignette.rb +79 -0
- data/ext/RMagick/Makefile +180 -0
- data/ext/RMagick/RMagick2.so +0 -0
- data/ext/RMagick/extconf.h +119 -0
- data/ext/RMagick/extconf.rb +406 -0
- data/ext/RMagick/mkmf.log +3022 -0
- data/ext/RMagick/rmagick.c +394 -0
- data/ext/RMagick/rmagick.h +1307 -0
- data/ext/RMagick/rmagick.o +0 -0
- data/ext/RMagick/rmdraw.c +1991 -0
- data/ext/RMagick/rmdraw.o +0 -0
- data/ext/RMagick/rmenum.c +1224 -0
- data/ext/RMagick/rmenum.o +0 -0
- data/ext/RMagick/rmfill.c +717 -0
- data/ext/RMagick/rmfill.o +0 -0
- data/ext/RMagick/rmilist.c +1217 -0
- data/ext/RMagick/rmilist.o +0 -0
- data/ext/RMagick/rmimage.c +15099 -0
- data/ext/RMagick/rmimage.o +0 -0
- data/ext/RMagick/rminfo.c +2567 -0
- data/ext/RMagick/rminfo.o +0 -0
- data/ext/RMagick/rmmain.c +1705 -0
- data/ext/RMagick/rmmain.o +0 -0
- data/ext/RMagick/rmmontage.c +511 -0
- data/ext/RMagick/rmmontage.o +0 -0
- data/ext/RMagick/rmpixel.c +1103 -0
- data/ext/RMagick/rmpixel.o +0 -0
- data/ext/RMagick/rmstruct.c +1047 -0
- data/ext/RMagick/rmstruct.o +0 -0
- data/ext/RMagick/rmutil.c +1730 -0
- data/ext/RMagick/rmutil.o +0 -0
- data/lib/RMagick.rb +1962 -0
- data/lib/rvg/clippath.rb +48 -0
- data/lib/rvg/container.rb +131 -0
- data/lib/rvg/deep_equal.rb +56 -0
- data/lib/rvg/describable.rb +53 -0
- data/lib/rvg/embellishable.rb +417 -0
- data/lib/rvg/misc.rb +740 -0
- data/lib/rvg/paint.rb +55 -0
- data/lib/rvg/pathdata.rb +131 -0
- data/lib/rvg/rvg.rb +283 -0
- data/lib/rvg/stretchable.rb +168 -0
- data/lib/rvg/stylable.rb +124 -0
- data/lib/rvg/text.rb +187 -0
- data/lib/rvg/to_c.rb +103 -0
- data/lib/rvg/transformable.rb +133 -0
- data/lib/rvg/units.rb +66 -0
- data/metaconfig +7 -0
- data/post-clean.rb +12 -0
- data/post-install.rb +50 -0
- data/post-setup.rb +254 -0
- data/rmagick.gemspec +20 -0
- data/setup.rb +1585 -0
- data/test/Draw.rb +121 -0
- data/test/Image1.rb +762 -0
- data/test/Image2.rb +1308 -0
- data/test/Image3.rb +1001 -0
- data/test/ImageList1.rb +808 -0
- data/test/ImageList2.rb +389 -0
- data/test/Image_attributes.rb +682 -0
- data/test/Import_Export.rb +116 -0
- data/test/Info.rb +349 -0
- data/test/Magick.rb +364 -0
- data/test/Pixel.rb +120 -0
- data/test/Preview.rb +62 -0
- data/test/all_basic.rb +39 -0
- data/test/cmyk.icm +0 -0
- data/test/srgb.icm +0 -0
- data/test/test.0 +0 -0
- data/uninstall.rb +74 -0
- metadata +455 -0
Binary file
|
@@ -0,0 +1,717 @@
|
|
1
|
+
/**************************************************************************//**
|
2
|
+
* GradientFill, TextureFill class definitions for RMagick.
|
3
|
+
*
|
4
|
+
* Copyright © 2002 - 2009 by Timothy P. Hunter
|
5
|
+
*
|
6
|
+
* Changes since Nov. 2009 copyright © by Benjamin Thomas and Omer Bar-or
|
7
|
+
*
|
8
|
+
* @file rmfill.c
|
9
|
+
* @version $Id: rmfill.c,v 1.33 2009/12/20 02:33:33 baror Exp $
|
10
|
+
* @author Tim Hunter
|
11
|
+
******************************************************************************/
|
12
|
+
|
13
|
+
#include "rmagick.h"
|
14
|
+
|
15
|
+
/** Data associated with a GradientFill */
|
16
|
+
typedef struct
|
17
|
+
{
|
18
|
+
double x1; /**< x position of first point */
|
19
|
+
double y1; /**< y position of first point */
|
20
|
+
double x2; /**< x position of second point */
|
21
|
+
double y2; /**< y position of second point */
|
22
|
+
PixelPacket start_color; /**< the start color */
|
23
|
+
PixelPacket stop_color; /**< the stop color */
|
24
|
+
} rm_GradientFill;
|
25
|
+
|
26
|
+
/** Data associated with a TextureFill */
|
27
|
+
typedef struct
|
28
|
+
{
|
29
|
+
Image *texture; /**< the texture */
|
30
|
+
} rm_TextureFill;
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Free Fill or Fill subclass object (except for TextureFill).
|
34
|
+
*
|
35
|
+
* No Ruby usage (internal function)
|
36
|
+
*
|
37
|
+
* @param fill the fill
|
38
|
+
*/
|
39
|
+
static void free_Fill(void *fill)
|
40
|
+
{
|
41
|
+
xfree(fill);
|
42
|
+
}
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Create new GradientFill object.
|
46
|
+
*
|
47
|
+
* No Ruby usage (internal function)
|
48
|
+
*
|
49
|
+
* @param class the Ruby class to use
|
50
|
+
* @return a new GradientFill object
|
51
|
+
*/
|
52
|
+
VALUE
|
53
|
+
GradientFill_alloc(VALUE class)
|
54
|
+
{
|
55
|
+
rm_GradientFill *fill;
|
56
|
+
|
57
|
+
return Data_Make_Struct(class, rm_GradientFill, NULL, free_Fill, fill);
|
58
|
+
}
|
59
|
+
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Store the vector points and the start and stop colors.
|
63
|
+
*
|
64
|
+
* Ruby usage:
|
65
|
+
* - @verbatim GradientFill#initialize(x1,y1,x2,y2,start_color,stop_color) @endverbatim
|
66
|
+
*
|
67
|
+
* @param self this object
|
68
|
+
* @param x1 x position of first point
|
69
|
+
* @param y1 y position of first point
|
70
|
+
* @param x2 x position of second point
|
71
|
+
* @param y2 y position of second point
|
72
|
+
* @param start_color the start color
|
73
|
+
* @param stop_color the stop color
|
74
|
+
* @return self
|
75
|
+
*/
|
76
|
+
VALUE
|
77
|
+
GradientFill_initialize(
|
78
|
+
VALUE self,
|
79
|
+
VALUE x1,
|
80
|
+
VALUE y1,
|
81
|
+
VALUE x2,
|
82
|
+
VALUE y2,
|
83
|
+
VALUE start_color,
|
84
|
+
VALUE stop_color)
|
85
|
+
{
|
86
|
+
rm_GradientFill *fill;
|
87
|
+
|
88
|
+
Data_Get_Struct(self, rm_GradientFill, fill);
|
89
|
+
|
90
|
+
fill->x1 = NUM2DBL(x1);
|
91
|
+
fill->y1 = NUM2DBL(y1);
|
92
|
+
fill->x2 = NUM2DBL(x2);
|
93
|
+
fill->y2 = NUM2DBL(y2);
|
94
|
+
Color_to_PixelPacket(&fill->start_color, start_color);
|
95
|
+
Color_to_PixelPacket(&fill->stop_color, stop_color);
|
96
|
+
|
97
|
+
return self;
|
98
|
+
}
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Do a gradient that radiates from a point.
|
102
|
+
*
|
103
|
+
* No Ruby usage (internal function)
|
104
|
+
*
|
105
|
+
* @param image the image on which to do the gradient
|
106
|
+
* @param x0 x position of the point
|
107
|
+
* @param y0 y position of the point
|
108
|
+
* @param start_color the start color
|
109
|
+
* @param stop_color the stop color
|
110
|
+
*/
|
111
|
+
static void
|
112
|
+
point_fill(
|
113
|
+
Image *image,
|
114
|
+
double x0,
|
115
|
+
double y0,
|
116
|
+
PixelPacket *start_color,
|
117
|
+
PixelPacket *stop_color)
|
118
|
+
{
|
119
|
+
double steps, distance;
|
120
|
+
unsigned long x, y;
|
121
|
+
MagickRealType red_step, green_step, blue_step;
|
122
|
+
#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
|
123
|
+
ExceptionInfo exception;
|
124
|
+
|
125
|
+
GetExceptionInfo(&exception);
|
126
|
+
#endif
|
127
|
+
|
128
|
+
steps = sqrt((double)((image->columns-x0)*(image->columns-x0)
|
129
|
+
+ (image->rows-y0)*(image->rows-y0)));
|
130
|
+
|
131
|
+
red_step = ((MagickRealType)stop_color->red - (MagickRealType)start_color->red) / steps;
|
132
|
+
green_step = ((MagickRealType)stop_color->green - (MagickRealType)start_color->green) / steps;
|
133
|
+
blue_step = ((MagickRealType)stop_color->blue - (MagickRealType)start_color->blue) / steps;
|
134
|
+
|
135
|
+
for (y = 0; y < image->rows; y++)
|
136
|
+
{
|
137
|
+
PixelPacket *row_pixels;
|
138
|
+
|
139
|
+
#if defined(HAVE_QUEUEAUTHENTICPIXELS)
|
140
|
+
row_pixels = QueueAuthenticPixels(image, 0, (long int)y, image->columns, 1, &exception);
|
141
|
+
CHECK_EXCEPTION()
|
142
|
+
#else
|
143
|
+
row_pixels = SetImagePixels(image, 0, (long int)y, image->columns, 1);
|
144
|
+
rm_check_image_exception(image, RetainOnError);
|
145
|
+
#endif
|
146
|
+
for (x = 0; x < image->columns; x++)
|
147
|
+
{
|
148
|
+
distance = sqrt((double)((x-x0)*(x-x0)+(y-y0)*(y-y0)));
|
149
|
+
row_pixels[x].red = ROUND_TO_QUANTUM(start_color->red + (distance * red_step));
|
150
|
+
row_pixels[x].green = ROUND_TO_QUANTUM(start_color->green + (distance * green_step));
|
151
|
+
row_pixels[x].blue = ROUND_TO_QUANTUM(start_color->blue + (distance * blue_step));
|
152
|
+
row_pixels[x].opacity = OpaqueOpacity;
|
153
|
+
}
|
154
|
+
|
155
|
+
#if defined(HAVE_SYNCAUTHENTICPIXELS)
|
156
|
+
SyncAuthenticPixels(image, &exception);
|
157
|
+
CHECK_EXCEPTION()
|
158
|
+
#else
|
159
|
+
SyncImagePixels(image);
|
160
|
+
rm_check_image_exception(image, RetainOnError);
|
161
|
+
#endif
|
162
|
+
}
|
163
|
+
|
164
|
+
#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
|
165
|
+
DestroyExceptionInfo(&exception);
|
166
|
+
#endif
|
167
|
+
}
|
168
|
+
|
169
|
+
/**
|
170
|
+
* Do a gradient fill that proceeds from a vertical line to the right and left
|
171
|
+
* sides of the image.
|
172
|
+
*
|
173
|
+
* No Ruby usage (internal function)
|
174
|
+
*
|
175
|
+
* @param image the image on which to do the gradient
|
176
|
+
* @param x1 x position of the vertical line
|
177
|
+
* @param start_color the start color
|
178
|
+
* @param stop_color the stop color
|
179
|
+
*/
|
180
|
+
static void
|
181
|
+
vertical_fill(
|
182
|
+
Image *image,
|
183
|
+
double x1,
|
184
|
+
PixelPacket *start_color,
|
185
|
+
PixelPacket *stop_color)
|
186
|
+
{
|
187
|
+
double steps;
|
188
|
+
unsigned long x, y;
|
189
|
+
PixelPacket *master;
|
190
|
+
MagickRealType red_step, green_step, blue_step;
|
191
|
+
#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
|
192
|
+
ExceptionInfo exception;
|
193
|
+
|
194
|
+
GetExceptionInfo(&exception);
|
195
|
+
#endif
|
196
|
+
|
197
|
+
steps = FMAX(x1, ((long)image->columns)-x1);
|
198
|
+
|
199
|
+
// If x is to the left of the x-axis, add that many steps so that
|
200
|
+
// the color at the right side will be that many steps away from
|
201
|
+
// the stop color.
|
202
|
+
if (x1 < 0)
|
203
|
+
{
|
204
|
+
steps -= x1;
|
205
|
+
}
|
206
|
+
|
207
|
+
red_step = ((MagickRealType)stop_color->red - (MagickRealType)start_color->red) / steps;
|
208
|
+
green_step = ((MagickRealType)stop_color->green - (MagickRealType)start_color->green) / steps;
|
209
|
+
blue_step = ((MagickRealType)stop_color->blue - (MagickRealType)start_color->blue) / steps;
|
210
|
+
|
211
|
+
// All the rows are the same. Make a "master row" and simply copy
|
212
|
+
// it to each actual row.
|
213
|
+
master = ALLOC_N(PixelPacket, image->columns);
|
214
|
+
|
215
|
+
for (x = 0; x < image->columns; x++)
|
216
|
+
{
|
217
|
+
double distance = fabs(x1 - x);
|
218
|
+
master[x].red = ROUND_TO_QUANTUM(start_color->red + (red_step * distance));
|
219
|
+
master[x].green = ROUND_TO_QUANTUM(start_color->green + (green_step * distance));
|
220
|
+
master[x].blue = ROUND_TO_QUANTUM(start_color->blue + (blue_step * distance));
|
221
|
+
master[x].opacity = OpaqueOpacity;
|
222
|
+
}
|
223
|
+
|
224
|
+
// Now copy the master row to each actual row.
|
225
|
+
for (y = 0; y < image->rows; y++)
|
226
|
+
{
|
227
|
+
PixelPacket *row_pixels;
|
228
|
+
|
229
|
+
#if defined(HAVE_QUEUEAUTHENTICPIXELS)
|
230
|
+
row_pixels = QueueAuthenticPixels(image, 0, (long int)y, image->columns, 1, &exception);
|
231
|
+
CHECK_EXCEPTION()
|
232
|
+
#else
|
233
|
+
row_pixels = SetImagePixels(image, 0, (long int)y, image->columns, 1);
|
234
|
+
rm_check_image_exception(image, RetainOnError);
|
235
|
+
#endif
|
236
|
+
|
237
|
+
memcpy(row_pixels, master, image->columns * sizeof(PixelPacket));
|
238
|
+
|
239
|
+
#if defined(HAVE_SYNCAUTHENTICPIXELS)
|
240
|
+
SyncAuthenticPixels(image, &exception);
|
241
|
+
CHECK_EXCEPTION()
|
242
|
+
#else
|
243
|
+
SyncImagePixels(image);
|
244
|
+
rm_check_image_exception(image, RetainOnError);
|
245
|
+
#endif
|
246
|
+
}
|
247
|
+
|
248
|
+
#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
|
249
|
+
DestroyExceptionInfo(&exception);
|
250
|
+
#endif
|
251
|
+
|
252
|
+
xfree((void *)master);
|
253
|
+
}
|
254
|
+
|
255
|
+
/**
|
256
|
+
* Do a gradient fill that starts from a horizontal line.
|
257
|
+
*
|
258
|
+
* No Ruby usage (internal function)
|
259
|
+
*
|
260
|
+
* @param image the image on which to do the gradient
|
261
|
+
* @param y1 y position of the horizontal line
|
262
|
+
* @param start_color the start color
|
263
|
+
* @param stop_color the stop color
|
264
|
+
*/
|
265
|
+
static void
|
266
|
+
horizontal_fill(
|
267
|
+
Image *image,
|
268
|
+
double y1,
|
269
|
+
PixelPacket *start_color,
|
270
|
+
PixelPacket *stop_color)
|
271
|
+
{
|
272
|
+
double steps;
|
273
|
+
unsigned long x, y;
|
274
|
+
PixelPacket *master;
|
275
|
+
MagickRealType red_step, green_step, blue_step;
|
276
|
+
#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
|
277
|
+
ExceptionInfo exception;
|
278
|
+
|
279
|
+
GetExceptionInfo(&exception);
|
280
|
+
#endif
|
281
|
+
|
282
|
+
steps = FMAX(y1, ((long)image->rows)-y1);
|
283
|
+
|
284
|
+
// If the line is below the y-axis, add that many steps so the color
|
285
|
+
// at the bottom of the image is that many steps away from the stop color
|
286
|
+
if (y1 < 0)
|
287
|
+
{
|
288
|
+
steps -= y1;
|
289
|
+
}
|
290
|
+
|
291
|
+
red_step = ((MagickRealType)stop_color->red - (MagickRealType)start_color->red) / steps;
|
292
|
+
green_step = ((MagickRealType)stop_color->green - (MagickRealType)start_color->green) / steps;
|
293
|
+
blue_step = ((MagickRealType)stop_color->blue - (MagickRealType)start_color->blue) / steps;
|
294
|
+
|
295
|
+
// All the columns are the same, so make a master column and copy it to
|
296
|
+
// each of the "real" columns.
|
297
|
+
master = ALLOC_N(PixelPacket, image->rows);
|
298
|
+
|
299
|
+
for (y = 0; y < image->rows; y++)
|
300
|
+
{
|
301
|
+
double distance = fabs(y1 - y);
|
302
|
+
master[y].red = ROUND_TO_QUANTUM(start_color->red + (distance * red_step));
|
303
|
+
master[y].green = ROUND_TO_QUANTUM(start_color->green + (distance * green_step));
|
304
|
+
master[y].blue = ROUND_TO_QUANTUM(start_color->blue + (distance * blue_step));
|
305
|
+
master[y].opacity = OpaqueOpacity;
|
306
|
+
}
|
307
|
+
|
308
|
+
for (x = 0; x < image->columns; x++)
|
309
|
+
{
|
310
|
+
PixelPacket *col_pixels;
|
311
|
+
|
312
|
+
#if defined(HAVE_QUEUEAUTHENTICPIXELS)
|
313
|
+
col_pixels = QueueAuthenticPixels(image, (long int)x, 0, 1, image->rows, &exception);
|
314
|
+
#else
|
315
|
+
col_pixels = SetImagePixels(image, (long int)x, 0, 1, image->rows);
|
316
|
+
rm_check_image_exception(image, RetainOnError);
|
317
|
+
#endif
|
318
|
+
memcpy(col_pixels, master, image->rows * sizeof(PixelPacket));
|
319
|
+
|
320
|
+
#if defined(HAVE_SYNCAUTHENTICPIXELS)
|
321
|
+
SyncAuthenticPixels(image, &exception);
|
322
|
+
CHECK_EXCEPTION()
|
323
|
+
#else
|
324
|
+
SyncImagePixels(image);
|
325
|
+
rm_check_image_exception(image, RetainOnError);
|
326
|
+
#endif
|
327
|
+
}
|
328
|
+
|
329
|
+
#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
|
330
|
+
DestroyExceptionInfo(&exception);
|
331
|
+
#endif
|
332
|
+
|
333
|
+
xfree((PixelPacket *)master);
|
334
|
+
}
|
335
|
+
|
336
|
+
/**
|
337
|
+
* Do a gradient fill that starts from a diagonal line and ends at the top and
|
338
|
+
* bottom of the image.
|
339
|
+
*
|
340
|
+
* No Ruby usage (internal function)
|
341
|
+
*
|
342
|
+
* @param image the image on which to do the gradient
|
343
|
+
* @param x1 x position of the start of the diagonal line
|
344
|
+
* @param y1 y position of the start of the diagonal line
|
345
|
+
* @param x2 x position of the end of the diagonal line
|
346
|
+
* @param y2 y position of the end of the diagonal line
|
347
|
+
* @param start_color the start color
|
348
|
+
* @param stop_color the stop color
|
349
|
+
*/
|
350
|
+
static void
|
351
|
+
v_diagonal_fill(
|
352
|
+
Image *image,
|
353
|
+
double x1,
|
354
|
+
double y1,
|
355
|
+
double x2,
|
356
|
+
double y2,
|
357
|
+
PixelPacket *start_color,
|
358
|
+
PixelPacket *stop_color)
|
359
|
+
{
|
360
|
+
unsigned long x, y;
|
361
|
+
MagickRealType red_step, green_step, blue_step;
|
362
|
+
double m, b, steps = 0.0;
|
363
|
+
double d1, d2;
|
364
|
+
#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
|
365
|
+
ExceptionInfo exception;
|
366
|
+
|
367
|
+
GetExceptionInfo(&exception);
|
368
|
+
#endif
|
369
|
+
|
370
|
+
// Compute the equation of the line: y=mx+b
|
371
|
+
m = ((double)(y2 - y1))/((double)(x2 - x1));
|
372
|
+
b = y1 - (m * x1);
|
373
|
+
|
374
|
+
// The number of steps is the greatest distance between the line and
|
375
|
+
// the top or bottom of the image between x=0 and x=image->columns
|
376
|
+
// When x=0, y=b. When x=image->columns, y = m*image->columns+b
|
377
|
+
d1 = b;
|
378
|
+
d2 = m * image->columns + b;
|
379
|
+
|
380
|
+
if (d1 < 0 && d2 < 0)
|
381
|
+
{
|
382
|
+
steps += FMAX(fabs(d1),fabs(d2));
|
383
|
+
}
|
384
|
+
else if (d1 > (double)image->rows && d2 > (double)image->rows)
|
385
|
+
{
|
386
|
+
steps += FMAX(d1-image->rows, d2-image->rows);
|
387
|
+
}
|
388
|
+
|
389
|
+
d1 = FMAX(b, image->rows-b);
|
390
|
+
d2 = FMAX(d2, image->rows-d2);
|
391
|
+
steps += FMAX(d1, d2);
|
392
|
+
|
393
|
+
// If the line is entirely > image->rows, swap the start & end color
|
394
|
+
if (steps < 0)
|
395
|
+
{
|
396
|
+
PixelPacket t = *stop_color;
|
397
|
+
*stop_color = *start_color;
|
398
|
+
*start_color = t;
|
399
|
+
steps = -steps;
|
400
|
+
}
|
401
|
+
|
402
|
+
red_step = ((MagickRealType)stop_color->red - (MagickRealType)start_color->red) / steps;
|
403
|
+
green_step = ((MagickRealType)stop_color->green - (MagickRealType)start_color->green) / steps;
|
404
|
+
blue_step = ((MagickRealType)stop_color->blue - (MagickRealType)start_color->blue) / steps;
|
405
|
+
|
406
|
+
for (y = 0; y < image->rows; y++)
|
407
|
+
{
|
408
|
+
PixelPacket *row_pixels;
|
409
|
+
|
410
|
+
#if defined(HAVE_QUEUEAUTHENTICPIXELS)
|
411
|
+
row_pixels = QueueAuthenticPixels(image, 0, (long int)y, image->columns, 1, &exception);
|
412
|
+
CHECK_EXCEPTION()
|
413
|
+
#else
|
414
|
+
row_pixels = SetImagePixels(image, 0, (long int)y, image->columns, 1);
|
415
|
+
rm_check_image_exception(image, RetainOnError);
|
416
|
+
#endif
|
417
|
+
for (x = 0; x < image->columns; x++)
|
418
|
+
{
|
419
|
+
double distance = (double) abs((int)(y-(m * x + b)));
|
420
|
+
row_pixels[x].red = ROUND_TO_QUANTUM(start_color->red + (distance * red_step));
|
421
|
+
row_pixels[x].green = ROUND_TO_QUANTUM(start_color->green + (distance * green_step));
|
422
|
+
row_pixels[x].blue = ROUND_TO_QUANTUM(start_color->blue + (distance * blue_step));
|
423
|
+
row_pixels[x].opacity = OpaqueOpacity;
|
424
|
+
}
|
425
|
+
|
426
|
+
#if defined(HAVE_SYNCAUTHENTICPIXELS)
|
427
|
+
SyncAuthenticPixels(image, &exception);
|
428
|
+
CHECK_EXCEPTION()
|
429
|
+
#else
|
430
|
+
SyncImagePixels(image);
|
431
|
+
rm_check_image_exception(image, RetainOnError);
|
432
|
+
#endif
|
433
|
+
}
|
434
|
+
|
435
|
+
#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
|
436
|
+
DestroyExceptionInfo(&exception);
|
437
|
+
#endif
|
438
|
+
|
439
|
+
}
|
440
|
+
|
441
|
+
/**
|
442
|
+
* Do a gradient fill that starts from a diagonal line and ends at the sides of
|
443
|
+
* the image.
|
444
|
+
*
|
445
|
+
* No Ruby usage (internal function)
|
446
|
+
*
|
447
|
+
* @param image the image on which to do the gradient
|
448
|
+
* @param x1 x position of the start of the diagonal line
|
449
|
+
* @param y1 y position of the start of the diagonal line
|
450
|
+
* @param x2 x position of the end of the diagonal line
|
451
|
+
* @param y2 y position of the end of the diagonal line
|
452
|
+
* @param start_color the start color
|
453
|
+
* @param stop_color the stop color
|
454
|
+
*/
|
455
|
+
static void
|
456
|
+
h_diagonal_fill(
|
457
|
+
Image *image,
|
458
|
+
double x1,
|
459
|
+
double y1,
|
460
|
+
double x2,
|
461
|
+
double y2,
|
462
|
+
PixelPacket *start_color,
|
463
|
+
PixelPacket *stop_color)
|
464
|
+
{
|
465
|
+
unsigned long x, y;
|
466
|
+
double m, b, steps = 0.0;
|
467
|
+
MagickRealType red_step, green_step, blue_step;
|
468
|
+
double d1, d2;
|
469
|
+
#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
|
470
|
+
ExceptionInfo exception;
|
471
|
+
|
472
|
+
GetExceptionInfo(&exception);
|
473
|
+
#endif
|
474
|
+
|
475
|
+
// Compute the equation of the line: y=mx+b
|
476
|
+
m = ((double)(y2 - y1))/((double)(x2 - x1));
|
477
|
+
b = y1 - (m * x1);
|
478
|
+
|
479
|
+
// The number of steps is the greatest distance between the line and
|
480
|
+
// the left or right side of the image between y=0 and y=image->rows.
|
481
|
+
// When y=0, x=-b/m. When y=image->rows, x = (image->rows-b)/m.
|
482
|
+
d1 = -b/m;
|
483
|
+
d2 = (double) ((image->rows-b) / m);
|
484
|
+
|
485
|
+
// If the line is entirely to the right or left of the image, increase
|
486
|
+
// the number of steps.
|
487
|
+
if (d1 < 0 && d2 < 0)
|
488
|
+
{
|
489
|
+
steps += FMAX(fabs(d1),fabs(d2));
|
490
|
+
}
|
491
|
+
else if (d1 > (double)image->columns && d2 > (double)image->columns)
|
492
|
+
{
|
493
|
+
steps += FMAX(abs((int)(image->columns-d1)),abs((int)(image->columns-d2)));
|
494
|
+
}
|
495
|
+
|
496
|
+
d1 = FMAX(d1, image->columns-d1);
|
497
|
+
d2 = FMAX(d2, image->columns-d2);
|
498
|
+
steps += FMAX(d1, d2);
|
499
|
+
|
500
|
+
// If the line is entirely > image->columns, swap the start & end color
|
501
|
+
if (steps < 0)
|
502
|
+
{
|
503
|
+
PixelPacket t = *stop_color;
|
504
|
+
*stop_color = *start_color;
|
505
|
+
*start_color = t;
|
506
|
+
steps = -steps;
|
507
|
+
}
|
508
|
+
|
509
|
+
red_step = ((MagickRealType)stop_color->red - (MagickRealType)start_color->red) / steps;
|
510
|
+
green_step = ((MagickRealType)stop_color->green - (MagickRealType)start_color->green) / steps;
|
511
|
+
blue_step = ((MagickRealType)stop_color->blue - (MagickRealType)start_color->blue) / steps;
|
512
|
+
|
513
|
+
for (y = 0; y < image->rows; y++)
|
514
|
+
{
|
515
|
+
PixelPacket *row_pixels;
|
516
|
+
|
517
|
+
#if defined(HAVE_QUEUEAUTHENTICPIXELS)
|
518
|
+
row_pixels = QueueAuthenticPixels(image, 0, (long int)y, image->columns, 1, &exception);
|
519
|
+
CHECK_EXCEPTION()
|
520
|
+
#else
|
521
|
+
row_pixels = SetImagePixels(image, 0, (long int)y, image->columns, 1);
|
522
|
+
rm_check_image_exception(image, RetainOnError);
|
523
|
+
#endif
|
524
|
+
for (x = 0; x < image->columns; x++)
|
525
|
+
{
|
526
|
+
double distance = (double) abs((int)(x-((y-b)/m)));
|
527
|
+
row_pixels[x].red = ROUND_TO_QUANTUM(start_color->red + (distance * red_step));
|
528
|
+
row_pixels[x].green = ROUND_TO_QUANTUM(start_color->green + (distance * green_step));
|
529
|
+
row_pixels[x].blue = ROUND_TO_QUANTUM(start_color->blue + (distance * blue_step));
|
530
|
+
row_pixels[x].opacity = OpaqueOpacity;
|
531
|
+
}
|
532
|
+
|
533
|
+
#if defined(HAVE_SYNCAUTHENTICPIXELS)
|
534
|
+
SyncAuthenticPixels(image, &exception);
|
535
|
+
CHECK_EXCEPTION()
|
536
|
+
#else
|
537
|
+
SyncImagePixels(image);
|
538
|
+
rm_check_image_exception(image, RetainOnError);
|
539
|
+
#endif
|
540
|
+
}
|
541
|
+
|
542
|
+
#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
|
543
|
+
DestroyExceptionInfo(&exception);
|
544
|
+
#endif
|
545
|
+
}
|
546
|
+
|
547
|
+
/**
|
548
|
+
* Call GradientFill with the start and stop colors specified when this fill
|
549
|
+
* object was created.
|
550
|
+
*
|
551
|
+
* Ruby usage:
|
552
|
+
* - @verbatim GradientFill#fill(image) @endverbatim
|
553
|
+
*
|
554
|
+
* @param self this object
|
555
|
+
* @param image_obj the image
|
556
|
+
* @return self
|
557
|
+
*/
|
558
|
+
VALUE
|
559
|
+
GradientFill_fill(VALUE self, VALUE image_obj)
|
560
|
+
{
|
561
|
+
rm_GradientFill *fill;
|
562
|
+
Image *image;
|
563
|
+
PixelPacket start_color, stop_color;
|
564
|
+
double x1, y1, x2, y2; // points on the line
|
565
|
+
|
566
|
+
Data_Get_Struct(self, rm_GradientFill, fill);
|
567
|
+
image = rm_check_destroyed(image_obj);
|
568
|
+
|
569
|
+
x1 = fill->x1;
|
570
|
+
y1 = fill->y1;
|
571
|
+
x2 = fill->x2;
|
572
|
+
y2 = fill->y2;
|
573
|
+
start_color = fill->start_color;
|
574
|
+
stop_color = fill->stop_color;
|
575
|
+
|
576
|
+
if (fabs(x2-x1) < 0.5) // vertical?
|
577
|
+
{
|
578
|
+
// If the x1,y1 and x2,y2 points are essentially the same
|
579
|
+
if (fabs(y2-y1) < 0.5)
|
580
|
+
{
|
581
|
+
point_fill(image, x1, y1, &start_color, &stop_color);
|
582
|
+
}
|
583
|
+
|
584
|
+
// A vertical line is a special case.
|
585
|
+
else
|
586
|
+
{
|
587
|
+
vertical_fill(image, x1, &start_color, &stop_color);
|
588
|
+
}
|
589
|
+
}
|
590
|
+
|
591
|
+
// A horizontal line is a special case.
|
592
|
+
else if (fabs(y2-y1) < 0.5)
|
593
|
+
{
|
594
|
+
horizontal_fill(image, y1, &start_color, &stop_color);
|
595
|
+
}
|
596
|
+
|
597
|
+
// This is the general case - a diagonal line. If the line is more horizontal
|
598
|
+
// than vertical, use the top and bottom of the image as the ends of the
|
599
|
+
// gradient, otherwise use the sides of the image.
|
600
|
+
else
|
601
|
+
{
|
602
|
+
double m = ((double)(y2 - y1))/((double)(x2 - x1));
|
603
|
+
double diagonal = ((double)image->rows)/image->columns;
|
604
|
+
if (fabs(m) <= diagonal)
|
605
|
+
{
|
606
|
+
v_diagonal_fill(image, x1, y1, x2, y2, &start_color, &stop_color);
|
607
|
+
}
|
608
|
+
else
|
609
|
+
{
|
610
|
+
h_diagonal_fill(image, x1, y1, x2, y2, &start_color, &stop_color);
|
611
|
+
}
|
612
|
+
}
|
613
|
+
|
614
|
+
return self;
|
615
|
+
}
|
616
|
+
|
617
|
+
|
618
|
+
/**
|
619
|
+
* Free the TextureFill struct and the texture image it points to.
|
620
|
+
*
|
621
|
+
* No Ruby usage (internal function)
|
622
|
+
*
|
623
|
+
* Notes:
|
624
|
+
* - Called from GC
|
625
|
+
*
|
626
|
+
* @param fill_obj the TextureFill
|
627
|
+
*/
|
628
|
+
static void
|
629
|
+
free_TextureFill(void *fill_obj)
|
630
|
+
{
|
631
|
+
rm_TextureFill *fill = (rm_TextureFill *)fill_obj;
|
632
|
+
|
633
|
+
// Do not trace destruction
|
634
|
+
(void) DestroyImage(fill->texture);
|
635
|
+
xfree(fill);
|
636
|
+
}
|
637
|
+
|
638
|
+
/**
|
639
|
+
* Create new TextureFill object.
|
640
|
+
*
|
641
|
+
* No Ruby usage (internal function)
|
642
|
+
*
|
643
|
+
* Notes:
|
644
|
+
* - The texture is an Image or Image *object
|
645
|
+
*
|
646
|
+
* @param class the Ruby class to use
|
647
|
+
* @return a new TextureFill object
|
648
|
+
*/
|
649
|
+
VALUE
|
650
|
+
TextureFill_alloc(VALUE class)
|
651
|
+
{
|
652
|
+
rm_TextureFill *fill;
|
653
|
+
return Data_Make_Struct(class
|
654
|
+
, rm_TextureFill
|
655
|
+
, NULL
|
656
|
+
, free_TextureFill
|
657
|
+
, fill);
|
658
|
+
}
|
659
|
+
|
660
|
+
/**
|
661
|
+
* Store the texture image.
|
662
|
+
*
|
663
|
+
* Ruby usage:
|
664
|
+
* - @verbatim TextureFill#initialize(texture) @endverbatim
|
665
|
+
*
|
666
|
+
* Notes:
|
667
|
+
* - The texture is an Image or Image *object
|
668
|
+
*
|
669
|
+
* @param self this object
|
670
|
+
* @param texture_arg the texture
|
671
|
+
* @return self
|
672
|
+
*/
|
673
|
+
VALUE
|
674
|
+
TextureFill_initialize(VALUE self, VALUE texture_arg)
|
675
|
+
{
|
676
|
+
rm_TextureFill *fill;
|
677
|
+
Image *texture;
|
678
|
+
volatile VALUE texture_image;
|
679
|
+
|
680
|
+
Data_Get_Struct(self, rm_TextureFill, fill);
|
681
|
+
|
682
|
+
texture_image = rm_cur_image(texture_arg);
|
683
|
+
|
684
|
+
// Bump the reference count on the texture image.
|
685
|
+
texture = rm_check_destroyed(texture_image);
|
686
|
+
(void) ReferenceImage(texture);
|
687
|
+
|
688
|
+
fill->texture = texture;
|
689
|
+
return self;
|
690
|
+
}
|
691
|
+
|
692
|
+
/**
|
693
|
+
* Call TextureFill with the texture specified when this fill object was
|
694
|
+
* created.
|
695
|
+
*
|
696
|
+
* Ruby usage:
|
697
|
+
* - @verbatim TextureFill#fill(image) @endverbatim
|
698
|
+
*
|
699
|
+
* @param self this object
|
700
|
+
* @param image_obj the image
|
701
|
+
* @return self
|
702
|
+
*/
|
703
|
+
VALUE
|
704
|
+
TextureFill_fill(VALUE self, VALUE image_obj)
|
705
|
+
{
|
706
|
+
rm_TextureFill *fill;
|
707
|
+
Image *image;
|
708
|
+
|
709
|
+
image = rm_check_destroyed(image_obj);
|
710
|
+
Data_Get_Struct(self, rm_TextureFill, fill);
|
711
|
+
|
712
|
+
(void) TextureImage(image, fill->texture);
|
713
|
+
rm_check_image_exception(image, RetainOnError);
|
714
|
+
|
715
|
+
return self;
|
716
|
+
}
|
717
|
+
|