rmagick 3.2.0 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rmagick might be problematic. Click here for more details.

Files changed (420) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +63 -0
  3. data/.devcontainer/Dockerfile +14 -0
  4. data/.devcontainer/ImageMagick6/devcontainer.json +11 -0
  5. data/.devcontainer/devcontainer.json +11 -0
  6. data/.devcontainer/setup-repo.sh +10 -0
  7. data/.devcontainer/setup-user.sh +45 -0
  8. data/.editorconfig +3 -0
  9. data/.github/ISSUE_TEMPLATE.md +17 -0
  10. data/.github/workflows/ci.yml +79 -0
  11. data/.gitignore +3 -1
  12. data/.rspec +1 -0
  13. data/.rubocop.yml +24 -0
  14. data/.rubocop_todo.yml +151 -297
  15. data/.yardopts +5 -0
  16. data/CHANGELOG.md +233 -0
  17. data/CODE_OF_CONDUCT.md +122 -7
  18. data/CONTRIBUTING.md +14 -10
  19. data/README.md +326 -0
  20. data/Rakefile +16 -22
  21. data/before_install_linux.sh +22 -28
  22. data/before_install_osx.sh +57 -2
  23. data/ext/RMagick/extconf.rb +149 -105
  24. data/ext/RMagick/rmagick.c +77 -104
  25. data/ext/RMagick/rmagick.h +121 -103
  26. data/ext/RMagick/rmdraw.c +364 -436
  27. data/ext/RMagick/rmenum.c +106 -114
  28. data/ext/RMagick/rmfill.c +149 -70
  29. data/ext/RMagick/rmilist.c +225 -367
  30. data/ext/RMagick/rmimage.c +4751 -4405
  31. data/ext/RMagick/rminfo.c +574 -787
  32. data/ext/RMagick/rmkinfo.c +51 -121
  33. data/ext/RMagick/rmmain.c +454 -286
  34. data/ext/RMagick/rmmontage.c +64 -130
  35. data/ext/RMagick/rmpixel.c +488 -437
  36. data/ext/RMagick/rmstruct.c +83 -96
  37. data/ext/RMagick/rmutil.c +302 -214
  38. data/lib/rmagick/version.rb +1 -1
  39. data/lib/rmagick_internal.rb +138 -93
  40. data/lib/rvg/clippath.rb +2 -1
  41. data/lib/rvg/container.rb +10 -5
  42. data/lib/rvg/describable.rb +1 -1
  43. data/lib/rvg/embellishable.rb +5 -4
  44. data/lib/rvg/misc.rb +15 -12
  45. data/lib/rvg/paint.rb +2 -1
  46. data/lib/rvg/pathdata.rb +12 -11
  47. data/lib/rvg/rvg.rb +12 -8
  48. data/lib/rvg/stylable.rb +9 -7
  49. data/lib/rvg/text.rb +11 -6
  50. data/lib/rvg/transformable.rb +3 -2
  51. data/lib/rvg/units.rb +1 -1
  52. data/rmagick.gemspec +10 -11
  53. metadata +52 -423
  54. data/.appveyor.yml +0 -45
  55. data/.circleci/config.yml +0 -56
  56. data/.ruby-version +0 -1
  57. data/.simplecov +0 -27
  58. data/.travis.yml +0 -62
  59. data/Doxyfile +0 -1514
  60. data/README.textile +0 -259
  61. data/benchmarks/memory/README.md +0 -50
  62. data/benchmarks/memory/image_new.rb +0 -8
  63. data/benchmarks/memory/rmagick.gnuplot +0 -16
  64. data/doc/.cvsignore +0 -1
  65. data/doc/comtasks.html +0 -287
  66. data/doc/constants.html +0 -1581
  67. data/doc/css/doc.css +0 -299
  68. data/doc/css/popup.css +0 -34
  69. data/doc/css/ref.css +0 -67
  70. data/doc/draw.html +0 -3272
  71. data/doc/ex/InitialCoords.rb +0 -22
  72. data/doc/ex/NewCoordSys.rb +0 -30
  73. data/doc/ex/OrigCoordSys.rb +0 -16
  74. data/doc/ex/PreserveAspectRatio.rb +0 -204
  75. data/doc/ex/RotateScale.rb +0 -36
  76. data/doc/ex/Skew.rb +0 -38
  77. data/doc/ex/Use01.rb +0 -15
  78. data/doc/ex/Use02.rb +0 -20
  79. data/doc/ex/Use03.rb +0 -16
  80. data/doc/ex/ViewBox.rb +0 -31
  81. data/doc/ex/adaptive_threshold.rb +0 -9
  82. data/doc/ex/add_noise.rb +0 -16
  83. data/doc/ex/affine.rb +0 -48
  84. data/doc/ex/affine_transform.rb +0 -20
  85. data/doc/ex/arc.rb +0 -49
  86. data/doc/ex/arcpath.rb +0 -32
  87. data/doc/ex/arcs01.rb +0 -28
  88. data/doc/ex/arcs02.rb +0 -59
  89. data/doc/ex/average.rb +0 -15
  90. data/doc/ex/axes.rb +0 -64
  91. data/doc/ex/baseline_shift01.rb +0 -17
  92. data/doc/ex/bilevel_channel.rb +0 -8
  93. data/doc/ex/blur_image.rb +0 -12
  94. data/doc/ex/border.rb +0 -10
  95. data/doc/ex/bounding_box.rb +0 -42
  96. data/doc/ex/cbezier1.rb +0 -41
  97. data/doc/ex/cbezier2.rb +0 -41
  98. data/doc/ex/cbezier3.rb +0 -41
  99. data/doc/ex/cbezier4.rb +0 -42
  100. data/doc/ex/cbezier5.rb +0 -42
  101. data/doc/ex/cbezier6.rb +0 -53
  102. data/doc/ex/channel.rb +0 -25
  103. data/doc/ex/charcoal.rb +0 -12
  104. data/doc/ex/chop.rb +0 -29
  105. data/doc/ex/circle.rb +0 -33
  106. data/doc/ex/circle01.rb +0 -16
  107. data/doc/ex/clip_path.rb +0 -60
  108. data/doc/ex/coalesce.rb +0 -57
  109. data/doc/ex/color_fill_to_border.rb +0 -29
  110. data/doc/ex/color_floodfill.rb +0 -28
  111. data/doc/ex/color_histogram.rb +0 -47
  112. data/doc/ex/color_reset.rb +0 -11
  113. data/doc/ex/colorize.rb +0 -16
  114. data/doc/ex/colors.rb +0 -64
  115. data/doc/ex/compose_mask.rb +0 -22
  116. data/doc/ex/composite.rb +0 -133
  117. data/doc/ex/composite_layers.rb +0 -52
  118. data/doc/ex/composite_tiled.rb +0 -21
  119. data/doc/ex/contrast.rb +0 -36
  120. data/doc/ex/crop.rb +0 -31
  121. data/doc/ex/crop_with_gravity.rb +0 -42
  122. data/doc/ex/cubic01.rb +0 -43
  123. data/doc/ex/cubic02.rb +0 -91
  124. data/doc/ex/cycle_colormap.rb +0 -21
  125. data/doc/ex/dissolve.rb +0 -12
  126. data/doc/ex/drawcomp.rb +0 -41
  127. data/doc/ex/drop_shadow.rb +0 -60
  128. data/doc/ex/edge.rb +0 -11
  129. data/doc/ex/ellipse.rb +0 -45
  130. data/doc/ex/ellipse01.rb +0 -21
  131. data/doc/ex/emboss.rb +0 -11
  132. data/doc/ex/enhance.rb +0 -28
  133. data/doc/ex/equalize.rb +0 -11
  134. data/doc/ex/evenodd.rb +0 -42
  135. data/doc/ex/fill_pattern.rb +0 -23
  136. data/doc/ex/flatten_images.rb +0 -36
  137. data/doc/ex/flip.rb +0 -11
  138. data/doc/ex/flop.rb +0 -11
  139. data/doc/ex/font_styles.rb +0 -32
  140. data/doc/ex/fonts.rb +0 -16
  141. data/doc/ex/frame.rb +0 -12
  142. data/doc/ex/gaussian_blur.rb +0 -11
  143. data/doc/ex/get_multiline_type_metrics.rb +0 -41
  144. data/doc/ex/get_pixels.rb +0 -45
  145. data/doc/ex/get_type_metrics.rb +0 -142
  146. data/doc/ex/gradientfill.rb +0 -27
  147. data/doc/ex/grav.rb +0 -45
  148. data/doc/ex/gravity.rb +0 -78
  149. data/doc/ex/group.rb +0 -26
  150. data/doc/ex/hatchfill.rb +0 -27
  151. data/doc/ex/image.rb +0 -44
  152. data/doc/ex/images/Apple.miff +0 -0
  153. data/doc/ex/images/Ballerina.jpg +0 -0
  154. data/doc/ex/images/Ballerina3.jpg +0 -0
  155. data/doc/ex/images/Button_0.gif +0 -0
  156. data/doc/ex/images/Button_1.gif +0 -0
  157. data/doc/ex/images/Button_2.gif +0 -0
  158. data/doc/ex/images/Button_3.gif +0 -0
  159. data/doc/ex/images/Button_4.gif +0 -0
  160. data/doc/ex/images/Button_5.gif +0 -0
  161. data/doc/ex/images/Button_6.gif +0 -0
  162. data/doc/ex/images/Button_7.gif +0 -0
  163. data/doc/ex/images/Button_8.gif +0 -0
  164. data/doc/ex/images/Button_9.gif +0 -0
  165. data/doc/ex/images/Button_A.gif +0 -0
  166. data/doc/ex/images/Button_B.gif +0 -0
  167. data/doc/ex/images/Button_C.gif +0 -0
  168. data/doc/ex/images/Button_D.gif +0 -0
  169. data/doc/ex/images/Button_E.gif +0 -0
  170. data/doc/ex/images/Button_F.gif +0 -0
  171. data/doc/ex/images/Button_G.gif +0 -0
  172. data/doc/ex/images/Button_H.gif +0 -0
  173. data/doc/ex/images/Button_I.gif +0 -0
  174. data/doc/ex/images/Button_J.gif +0 -0
  175. data/doc/ex/images/Button_K.gif +0 -0
  176. data/doc/ex/images/Button_L.gif +0 -0
  177. data/doc/ex/images/Button_M.gif +0 -0
  178. data/doc/ex/images/Button_N.gif +0 -0
  179. data/doc/ex/images/Button_O.gif +0 -0
  180. data/doc/ex/images/Button_P.gif +0 -0
  181. data/doc/ex/images/Button_Q.gif +0 -0
  182. data/doc/ex/images/Button_R.gif +0 -0
  183. data/doc/ex/images/Button_S.gif +0 -0
  184. data/doc/ex/images/Button_T.gif +0 -0
  185. data/doc/ex/images/Button_U.gif +0 -0
  186. data/doc/ex/images/Button_V.gif +0 -0
  187. data/doc/ex/images/Button_W.gif +0 -0
  188. data/doc/ex/images/Button_X.gif +0 -0
  189. data/doc/ex/images/Button_Y.gif +0 -0
  190. data/doc/ex/images/Button_Z.gif +0 -0
  191. data/doc/ex/images/Cheetah.jpg +0 -0
  192. data/doc/ex/images/Coffee.png +0 -0
  193. data/doc/ex/images/Flower_Hat.jpg +0 -0
  194. data/doc/ex/images/Gold_Statue.jpg +0 -0
  195. data/doc/ex/images/Hot_Air_Balloons.jpg +0 -0
  196. data/doc/ex/images/Hot_Air_Balloons_H.jpg +0 -0
  197. data/doc/ex/images/Leaf.miff +0 -0
  198. data/doc/ex/images/No.png +0 -0
  199. data/doc/ex/images/Polynesia.jpg +0 -0
  200. data/doc/ex/images/Red_Rocks.jpg +0 -0
  201. data/doc/ex/images/Rocks_On_Beach.miff +0 -0
  202. data/doc/ex/images/Shorts.jpg +0 -0
  203. data/doc/ex/images/Snake.png +0 -0
  204. data/doc/ex/images/Violin.jpg +0 -0
  205. data/doc/ex/images/Yellow_Rose.miff +0 -0
  206. data/doc/ex/images/big-duck.gif +0 -0
  207. data/doc/ex/images/duck.gif +0 -0
  208. data/doc/ex/images/duck0.gif +0 -0
  209. data/doc/ex/images/duck1.gif +0 -0
  210. data/doc/ex/images/duck10.gif +0 -0
  211. data/doc/ex/images/duck11.gif +0 -0
  212. data/doc/ex/images/duck12.gif +0 -0
  213. data/doc/ex/images/duck13.gif +0 -0
  214. data/doc/ex/images/duck14.gif +0 -0
  215. data/doc/ex/images/duck15.gif +0 -0
  216. data/doc/ex/images/duck2.gif +0 -0
  217. data/doc/ex/images/duck3.gif +0 -0
  218. data/doc/ex/images/duck4.gif +0 -0
  219. data/doc/ex/images/duck5.gif +0 -0
  220. data/doc/ex/images/duck6.gif +0 -0
  221. data/doc/ex/images/duck7.gif +0 -0
  222. data/doc/ex/images/duck8.gif +0 -0
  223. data/doc/ex/images/duck9.gif +0 -0
  224. data/doc/ex/images/graydient230x6.gif +0 -0
  225. data/doc/ex/images/image_with_profile.jpg +0 -0
  226. data/doc/ex/images/logo400x83.gif +0 -0
  227. data/doc/ex/images/model.miff +0 -0
  228. data/doc/ex/images/notimplemented.gif +0 -0
  229. data/doc/ex/images/smile.miff +0 -0
  230. data/doc/ex/images/spin.gif +0 -0
  231. data/doc/ex/implode.rb +0 -34
  232. data/doc/ex/level.rb +0 -11
  233. data/doc/ex/level_colors.rb +0 -11
  234. data/doc/ex/line.rb +0 -41
  235. data/doc/ex/line01.rb +0 -21
  236. data/doc/ex/mask.rb +0 -35
  237. data/doc/ex/matte_fill_to_border.rb +0 -39
  238. data/doc/ex/matte_floodfill.rb +0 -32
  239. data/doc/ex/matte_replace.rb +0 -39
  240. data/doc/ex/median_filter.rb +0 -28
  241. data/doc/ex/modulate.rb +0 -11
  242. data/doc/ex/mono.rb +0 -23
  243. data/doc/ex/morph.rb +0 -25
  244. data/doc/ex/mosaic.rb +0 -37
  245. data/doc/ex/motion_blur.rb +0 -11
  246. data/doc/ex/negate.rb +0 -11
  247. data/doc/ex/negate_channel.rb +0 -9
  248. data/doc/ex/nested_rvg.rb +0 -21
  249. data/doc/ex/nonzero.rb +0 -42
  250. data/doc/ex/normalize.rb +0 -11
  251. data/doc/ex/oil_paint.rb +0 -11
  252. data/doc/ex/opacity.rb +0 -37
  253. data/doc/ex/ordered_dither.rb +0 -11
  254. data/doc/ex/path.rb +0 -63
  255. data/doc/ex/pattern1.rb +0 -25
  256. data/doc/ex/pattern2.rb +0 -26
  257. data/doc/ex/polaroid.rb +0 -26
  258. data/doc/ex/polygon.rb +0 -23
  259. data/doc/ex/polygon01.rb +0 -21
  260. data/doc/ex/polyline.rb +0 -22
  261. data/doc/ex/polyline01.rb +0 -21
  262. data/doc/ex/posterize.rb +0 -8
  263. data/doc/ex/preview.rb +0 -8
  264. data/doc/ex/qbezierpath.rb +0 -52
  265. data/doc/ex/quad01.rb +0 -34
  266. data/doc/ex/quantize-m.rb +0 -25
  267. data/doc/ex/radial_blur.rb +0 -9
  268. data/doc/ex/raise.rb +0 -8
  269. data/doc/ex/random_threshold_channel.rb +0 -13
  270. data/doc/ex/rect01.rb +0 -14
  271. data/doc/ex/rect02.rb +0 -20
  272. data/doc/ex/rectangle.rb +0 -34
  273. data/doc/ex/reduce_noise.rb +0 -28
  274. data/doc/ex/remap.rb +0 -11
  275. data/doc/ex/remap_images.rb +0 -19
  276. data/doc/ex/resize_to_fill.rb +0 -8
  277. data/doc/ex/resize_to_fit.rb +0 -8
  278. data/doc/ex/roll.rb +0 -9
  279. data/doc/ex/rotate.rb +0 -44
  280. data/doc/ex/rotate_f.rb +0 -14
  281. data/doc/ex/roundrect.rb +0 -33
  282. data/doc/ex/rubyname.rb +0 -30
  283. data/doc/ex/rvg_clippath.rb +0 -12
  284. data/doc/ex/rvg_linecap.rb +0 -42
  285. data/doc/ex/rvg_linejoin.rb +0 -40
  286. data/doc/ex/rvg_opacity.rb +0 -18
  287. data/doc/ex/rvg_pattern.rb +0 -26
  288. data/doc/ex/rvg_stroke_dasharray.rb +0 -11
  289. data/doc/ex/segment.rb +0 -11
  290. data/doc/ex/sepiatone.rb +0 -7
  291. data/doc/ex/shade.rb +0 -11
  292. data/doc/ex/shadow.rb +0 -30
  293. data/doc/ex/shave.rb +0 -15
  294. data/doc/ex/shear.rb +0 -10
  295. data/doc/ex/sketch.rb +0 -17
  296. data/doc/ex/skewx.rb +0 -51
  297. data/doc/ex/skewy.rb +0 -47
  298. data/doc/ex/smile.rb +0 -126
  299. data/doc/ex/solarize.rb +0 -11
  300. data/doc/ex/sparse_color.rb +0 -55
  301. data/doc/ex/splice.rb +0 -8
  302. data/doc/ex/spread.rb +0 -11
  303. data/doc/ex/stegano.rb +0 -54
  304. data/doc/ex/stroke_dasharray.rb +0 -42
  305. data/doc/ex/stroke_fill.rb +0 -10
  306. data/doc/ex/stroke_linecap.rb +0 -44
  307. data/doc/ex/stroke_linejoin.rb +0 -48
  308. data/doc/ex/stroke_width.rb +0 -49
  309. data/doc/ex/swirl.rb +0 -17
  310. data/doc/ex/text.rb +0 -37
  311. data/doc/ex/text01.rb +0 -16
  312. data/doc/ex/text_align.rb +0 -36
  313. data/doc/ex/text_antialias.rb +0 -37
  314. data/doc/ex/text_styles.rb +0 -19
  315. data/doc/ex/text_undercolor.rb +0 -28
  316. data/doc/ex/texture_fill_to_border.rb +0 -34
  317. data/doc/ex/texture_floodfill.rb +0 -32
  318. data/doc/ex/texturefill.rb +0 -24
  319. data/doc/ex/threshold.rb +0 -13
  320. data/doc/ex/to_blob.rb +0 -13
  321. data/doc/ex/translate.rb +0 -39
  322. data/doc/ex/transparent.rb +0 -38
  323. data/doc/ex/transpose.rb +0 -9
  324. data/doc/ex/transverse.rb +0 -9
  325. data/doc/ex/tref01.rb +0 -24
  326. data/doc/ex/triangle01.rb +0 -15
  327. data/doc/ex/trim.rb +0 -23
  328. data/doc/ex/tspan01.rb +0 -17
  329. data/doc/ex/tspan02.rb +0 -17
  330. data/doc/ex/tspan03.rb +0 -19
  331. data/doc/ex/unsharp_mask.rb +0 -28
  332. data/doc/ex/viewex.rb +0 -33
  333. data/doc/ex/vignette.rb +0 -12
  334. data/doc/ex/watermark.rb +0 -27
  335. data/doc/ex/wave.rb +0 -9
  336. data/doc/ex/wet_floor.rb +0 -58
  337. data/doc/ex/writing_mode01.rb +0 -26
  338. data/doc/ex/writing_mode02.rb +0 -26
  339. data/doc/ilist.html +0 -2056
  340. data/doc/image1.html +0 -4680
  341. data/doc/image2.html +0 -3665
  342. data/doc/image3.html +0 -4522
  343. data/doc/imageattrs.html +0 -1638
  344. data/doc/imusage.html +0 -514
  345. data/doc/index.html +0 -416
  346. data/doc/info.html +0 -1499
  347. data/doc/magick.html +0 -570
  348. data/doc/optequiv.html +0 -2435
  349. data/doc/rvg.html +0 -975
  350. data/doc/rvgclip.html +0 -248
  351. data/doc/rvggroup.html +0 -305
  352. data/doc/rvgimage.html +0 -289
  353. data/doc/rvgpattern.html +0 -475
  354. data/doc/rvgshape.html +0 -406
  355. data/doc/rvgstyle.html +0 -270
  356. data/doc/rvgtext.html +0 -465
  357. data/doc/rvgtspan.html +0 -238
  358. data/doc/rvgtut.html +0 -530
  359. data/doc/rvguse.html +0 -145
  360. data/doc/rvgxform.html +0 -294
  361. data/doc/scripts/doc.js +0 -22
  362. data/doc/scripts/stripeTables.js +0 -23
  363. data/doc/struct.html +0 -1339
  364. data/doc/usage.html +0 -1621
  365. data/examples/constitute.rb +0 -7
  366. data/examples/crop_with_gravity.rb +0 -42
  367. data/examples/demo.rb +0 -323
  368. data/examples/describe.rb +0 -41
  369. data/examples/find_similar_region.rb +0 -34
  370. data/examples/histogram.rb +0 -312
  371. data/examples/identify.rb +0 -174
  372. data/examples/image_opacity.rb +0 -28
  373. data/examples/import_export.rb +0 -31
  374. data/examples/pattern_fill.rb +0 -37
  375. data/examples/rotating_text.rb +0 -45
  376. data/examples/spinner.rb +0 -49
  377. data/examples/thumbnail.rb +0 -64
  378. data/examples/vignette.rb +0 -78
  379. data/lib/obsolete.rb +0 -66
  380. data/spec/rmagick/ImageList1_spec.rb +0 -24
  381. data/spec/rmagick/draw_spec.rb +0 -155
  382. data/spec/rmagick/image/blue_shift_spec.rb +0 -14
  383. data/spec/rmagick/image/channel_entropy_spec.rb +0 -9
  384. data/spec/rmagick/image/composite_spec.rb +0 -72
  385. data/spec/rmagick/image/constitute_spec.rb +0 -13
  386. data/spec/rmagick/image/dispatch_spec.rb +0 -16
  387. data/spec/rmagick/image/from_blob_spec.rb +0 -12
  388. data/spec/rmagick/image/ping_spec.rb +0 -12
  389. data/spec/rmagick/image/properties_spec.rb +0 -27
  390. data/spec/rmagick/image/read_spec.rb +0 -28
  391. data/spec/spec_helper.rb +0 -10
  392. data/spec/support/issue_200/app.rb +0 -8
  393. data/test/Draw.rb +0 -351
  394. data/test/Enum.rb +0 -228
  395. data/test/Fill.rb +0 -93
  396. data/test/Image1.rb +0 -627
  397. data/test/Image2.rb +0 -1426
  398. data/test/Image3.rb +0 -1091
  399. data/test/ImageList1.rb +0 -858
  400. data/test/ImageList2.rb +0 -406
  401. data/test/Image_attributes.rb +0 -666
  402. data/test/Import_Export.rb +0 -115
  403. data/test/Info.rb +0 -444
  404. data/test/KernelInfo.rb +0 -67
  405. data/test/Magick.rb +0 -311
  406. data/test/Pixel.rb +0 -285
  407. data/test/PolaroidOptions.rb +0 -23
  408. data/test/Preview.rb +0 -26
  409. data/test/Struct.rb +0 -45
  410. data/test/appearance/Montage.rb +0 -26
  411. data/test/appearance/appearance_assertion.rb +0 -13
  412. data/test/appearance/expected/montage_border_color.jpg +0 -0
  413. data/test/cmyk.icm +0 -0
  414. data/test/lib/Obsolete.rb +0 -30
  415. data/test/lib/internal/Draw.rb +0 -823
  416. data/test/lib/internal/Geometry.rb +0 -98
  417. data/test/lib/internal/Magick.rb +0 -40
  418. data/test/srgb.icm +0 -0
  419. data/test/test_all_basic.rb +0 -49
  420. data/test/tmpnam_test.rb +0 -50
data/ext/RMagick/rmdraw.c CHANGED
@@ -18,19 +18,19 @@ static void destroy_Draw(void *);
18
18
  static VALUE new_DrawOptions(void);
19
19
 
20
20
  /** Method that gets type metrics */
21
- typedef MagickBooleanType (get_type_metrics_func_t)(Image *, const DrawInfo *, TypeMetric *);
21
+ #if defined(IMAGEMAGICK_7)
22
+ typedef MagickBooleanType (get_type_metrics_func_t)(Image *, const DrawInfo *, TypeMetric *, ExceptionInfo *);
23
+ #else
24
+ typedef MagickBooleanType (get_type_metrics_func_t)(Image *, const DrawInfo *, TypeMetric *);
25
+ #endif
22
26
  static VALUE get_type_metrics(int, VALUE *, VALUE, get_type_metrics_func_t);
23
27
 
24
28
 
25
29
  /**
26
- * Set the affine matrix from an Magick::AffineMatrix.
30
+ * Set the affine matrix from an {Magick::AffineMatrix}.
27
31
  *
28
- * Ruby usage:
29
- * - @verbatim Draw#affine= @endverbatim
30
- *
31
- * @param self this object
32
- * @param matrix the affine matrix to set
33
- * @return matrix
32
+ * @param matrix [Magick::AffineMatrix] the affine matrix
33
+ * @return [Magick::AffineMatrix] the given matrix
34
34
  */
35
35
  VALUE
36
36
  Draw_affine_eq(VALUE self, VALUE matrix)
@@ -45,14 +45,10 @@ Draw_affine_eq(VALUE self, VALUE matrix)
45
45
 
46
46
 
47
47
  /**
48
- * Set the text alignment.
49
- *
50
- * Ruby usage:
51
- * - @verbatim Draw#align= @endverbatim
48
+ * Set the text alignment from an {Magick::AlignType}.
52
49
  *
53
- * @param self this object
54
- * @param align the alignment
55
- * @return align
50
+ * @param align [Magick::AlignType] the text alignment
51
+ * @return [Magick::AlignType] the given align
56
52
  */
57
53
  VALUE
58
54
  Draw_align_eq(VALUE self, VALUE align)
@@ -67,14 +63,10 @@ Draw_align_eq(VALUE self, VALUE align)
67
63
 
68
64
 
69
65
  /**
70
- * Decorate attribute writer.
71
- *
72
- * Ruby usage:
73
- * - @verbatim Draw#decorate= @endverbatim
66
+ * Set text decorate from an {Magick::DecorationType}.
74
67
  *
75
- * @param self this object
76
- * @param decorate the decorate
77
- * @return decorate
68
+ * @param decorate [Magick::DecorationType] the decorate type
69
+ * @return [Magick::DecorationType] the given decorate
78
70
  */
79
71
  VALUE
80
72
  Draw_decorate_eq(VALUE self, VALUE decorate)
@@ -89,14 +81,10 @@ Draw_decorate_eq(VALUE self, VALUE decorate)
89
81
 
90
82
 
91
83
  /**
92
- * Density attribute writer.
84
+ * Set density.
93
85
  *
94
- * Ruby usage:
95
- * - @verbatim Draw#density= @endverbatim
96
- *
97
- * @param self this object
98
- * @param density the density
99
- * @return density
86
+ * @param density [String] the density
87
+ * @return [String] the given density
100
88
  */
101
89
  VALUE
102
90
  Draw_density_eq(VALUE self, VALUE density)
@@ -105,21 +93,17 @@ Draw_density_eq(VALUE self, VALUE density)
105
93
 
106
94
  rb_check_frozen(self);
107
95
  Data_Get_Struct(self, Draw, draw);
108
- magick_clone_string(&draw->info->density, StringValuePtr(density));
96
+ magick_clone_string(&draw->info->density, StringValueCStr(density));
109
97
 
110
98
  return density;
111
99
  }
112
100
 
113
101
 
114
102
  /**
115
- * Encoding attribute writer.
116
- *
117
- * Ruby usage:
118
- * - @verbatim Draw#encoding= @endverbatim
103
+ * Set text encoding.
119
104
  *
120
- * @param self this object
121
- * @param encoding the encoding
122
- * @return encoding
105
+ * @param encoding [String] the encoding name
106
+ * @return [String] the given encoding name
123
107
  */
124
108
  VALUE
125
109
  Draw_encoding_eq(VALUE self, VALUE encoding)
@@ -128,21 +112,17 @@ Draw_encoding_eq(VALUE self, VALUE encoding)
128
112
 
129
113
  rb_check_frozen(self);
130
114
  Data_Get_Struct(self, Draw, draw);
131
- magick_clone_string(&draw->info->encoding, StringValuePtr(encoding));
115
+ magick_clone_string(&draw->info->encoding, StringValueCStr(encoding));
132
116
 
133
117
  return encoding;
134
118
  }
135
119
 
136
120
 
137
121
  /**
138
- * Fill attribute writer.
139
- *
140
- * Ruby usage:
141
- * - @verbatim Draw#fill= @endverbatim
122
+ * Set fill color.
142
123
  *
143
- * @param self this object
144
- * @param fill the fill
145
- * @return fill
124
+ * @param fill [Magick::Pixel, String] the fill color
125
+ * @return [Magick::Pixel, String] the given fill color
146
126
  */
147
127
  VALUE
148
128
  Draw_fill_eq(VALUE self, VALUE fill)
@@ -159,20 +139,16 @@ Draw_fill_eq(VALUE self, VALUE fill)
159
139
  /**
160
140
  * Accept an image as a fill pattern.
161
141
  *
162
- * Ruby usage:
163
- * - @verbatim Draw#fill_pattern= @endverbatim
164
- *
165
- * @param self this object
166
- * @param pattern the fill pattern
167
- * @return pattern
168
- * @see Draw_stroke_pattern_eq
169
- * @see Draw_tile_eq
142
+ * @param pattern [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
143
+ * imagelist, uses the current image.
144
+ * @return [Magick::Image] the given pattern image
145
+ * @see #stroke_pattern=
146
+ * @see #tile=
170
147
  */
171
148
  VALUE
172
149
  Draw_fill_pattern_eq(VALUE self, VALUE pattern)
173
150
  {
174
151
  Draw *draw;
175
- Image *image;
176
152
 
177
153
  rb_check_frozen(self);
178
154
  Data_Get_Struct(self, Draw, draw);
@@ -186,6 +162,8 @@ Draw_fill_pattern_eq(VALUE self, VALUE pattern)
186
162
 
187
163
  if (!NIL_P(pattern))
188
164
  {
165
+ Image *image;
166
+
189
167
  pattern = rm_cur_image(pattern);
190
168
  image = rm_check_destroyed(pattern);
191
169
  // Do not trace creation
@@ -197,14 +175,10 @@ Draw_fill_pattern_eq(VALUE self, VALUE pattern)
197
175
 
198
176
 
199
177
  /**
200
- * Font attribute writer.
201
- *
202
- * Ruby usage:
203
- * - @verbatim Draw#font= @endverbatim
178
+ * Set the font name.
204
179
  *
205
- * @param self this object
206
- * @param font the font
207
- * @return font
180
+ * @param font [String] the font name
181
+ * @return [String] the given font name
208
182
  */
209
183
  VALUE
210
184
  Draw_font_eq(VALUE self, VALUE font)
@@ -213,21 +187,17 @@ Draw_font_eq(VALUE self, VALUE font)
213
187
 
214
188
  rb_check_frozen(self);
215
189
  Data_Get_Struct(self, Draw, draw);
216
- magick_clone_string(&draw->info->font, StringValuePtr(font));
190
+ magick_clone_string(&draw->info->font, StringValueCStr(font));
217
191
 
218
192
  return font;
219
193
  }
220
194
 
221
195
 
222
196
  /**
223
- * Font family attribute writer.
224
- *
225
- * Ruby usage:
226
- * - @verbatim Draw#family= @endverbatim
197
+ * Set the font family name.
227
198
  *
228
- * @param self this object
229
- * @param family the family
230
- * @return family
199
+ * @param family [String] the font family name
200
+ * @return [String] the given family name
231
201
  */
232
202
  VALUE
233
203
  Draw_font_family_eq(VALUE self, VALUE family)
@@ -236,21 +206,17 @@ Draw_font_family_eq(VALUE self, VALUE family)
236
206
 
237
207
  rb_check_frozen(self);
238
208
  Data_Get_Struct(self, Draw, draw);
239
- magick_clone_string(&draw->info->family, StringValuePtr(family));
209
+ magick_clone_string(&draw->info->family, StringValueCStr(family));
240
210
 
241
211
  return family;
242
212
  }
243
213
 
244
214
 
245
215
  /**
246
- * Font_stretch attribute writer.
216
+ * Set the stretch as spacing between text characters.
247
217
  *
248
- * Ruby usage:
249
- * - @verbatim Draw#font_stretch= @endverbatim
250
- *
251
- * @param self this object
252
- * @param stretch the font_stretch
253
- * @return stretch
218
+ * @param stretch [Magick::StretchType] the stretch type
219
+ * @return [Magick::StretchType] the given stretch type
254
220
  */
255
221
  VALUE
256
222
  Draw_font_stretch_eq(VALUE self, VALUE stretch)
@@ -265,14 +231,10 @@ Draw_font_stretch_eq(VALUE self, VALUE stretch)
265
231
 
266
232
 
267
233
  /**
268
- * Font_style attribute writer.
234
+ * Set font style.
269
235
  *
270
- * Ruby usage:
271
- * - @verbatim Draw#font_style= @endverbatim
272
- *
273
- * @param self this object
274
- * @param style the font_style
275
- * @return style
236
+ * @param style [Magick::StyleType] the font style
237
+ * @return [Magick::StyleType] the given font style
276
238
  */
277
239
  VALUE
278
240
  Draw_font_style_eq(VALUE self, VALUE style)
@@ -287,18 +249,11 @@ Draw_font_style_eq(VALUE self, VALUE style)
287
249
 
288
250
 
289
251
  /**
290
- * Font_weight attribute writer.
291
- *
292
- * Ruby usage:
293
- * - @verbatim Draw#font_weight= @endverbatim
252
+ * Set font weight.
294
253
  *
295
- * Notes:
296
- * - The font weight can be one of the font weight constants or a number
297
- * between 100 and 900
298
- *
299
- * @param self this object
300
- * @param weight the font_weight
301
- * @return weight
254
+ * @param weight [Magick::WeightType, Numeric] the font weight
255
+ * @return [Magick::WeightType, Numeric] the given font weight
256
+ * @note The font weight can be one of the font weight constants or a number between 100 and 900
302
257
  */
303
258
  VALUE
304
259
  Draw_font_weight_eq(VALUE self, VALUE weight)
@@ -314,7 +269,7 @@ Draw_font_weight_eq(VALUE self, VALUE weight)
314
269
  w = FIX2INT(weight);
315
270
  if (w < 100 || w > 900)
316
271
  {
317
- rb_raise(rb_eArgError, "invalid font weight (%ld given)", w);
272
+ rb_raise(rb_eArgError, "invalid font weight (%"RMIuSIZE" given)", w);
318
273
  }
319
274
  draw->info->weight = w;
320
275
  }
@@ -351,27 +306,21 @@ Draw_font_weight_eq(VALUE self, VALUE weight)
351
306
 
352
307
 
353
308
  /**
354
- * Gravity attribute writer.
355
- *
356
- * Ruby usage:
357
- * - @verbatim Draw#gravity= @endverbatim
358
- *
359
- * Notes:
360
- * - From Magick++'s Image.h header file:
361
- * Gravity affects text placement in bounding area according to rules:
362
- * - NorthWestGravity text bottom-left corner placed at top-left
363
- * - NorthGravity text bottom-center placed at top-center
364
- * - NorthEastGravity text bottom-right corner placed at top-right
365
- * - WestGravity text left-center placed at left-center
366
- * - CenterGravity text center placed at center
367
- * - EastGravity text right-center placed at right-center
368
- * - SouthWestGravity text top-left placed at bottom-left
369
- * - SouthGravity text top-center placed at bottom-center
370
- * - SouthEastGravity text top-right placed at bottom-right
371
- *
372
- * @param self this object
373
- * @param grav the gravity
374
- * @return grav
309
+ * Set gravity to draw text.
310
+ * Gravity affects text placement in bounding area according to rules:
311
+ *
312
+ * - +NorthWestGravity+ - text bottom-left corner placed at top-left
313
+ * - +NorthGravity+ - text bottom-center placed at top-center
314
+ * - +NorthEastGravity+ - text bottom-right corner placed at top-right
315
+ * - +WestGravity+ - text left-center placed at left-center
316
+ * - +CenterGravity+ - text center placed at center
317
+ * - +EastGravity+ - text right-center placed at right-center
318
+ * - +SouthWestGravity+ - text top-left placed at bottom-left
319
+ * - +SouthGravity+ - text top-center placed at bottom-center
320
+ * - +SouthEastGravity+ - text top-right placed at bottom-right
321
+ *
322
+ * @param grav [Magick::GravityType] this gravity type
323
+ * @return [Magick::GravityType] the given gravity type
375
324
  */
376
325
  VALUE
377
326
  Draw_gravity_eq(VALUE self, VALUE grav)
@@ -387,17 +336,10 @@ Draw_gravity_eq(VALUE self, VALUE grav)
387
336
 
388
337
 
389
338
  /**
390
- * Space between two letters.
339
+ * Set kerning as spacing between two letters.
391
340
  *
392
- * Ruby usage:
393
- * - @verbatim Draw#gravity=float @endverbatim
394
- *
395
- * Notes:
396
- * - New for ImageMagick 6.4.7-8
397
- *
398
- * @param self this object
399
- * @param kerning the kerning
400
- * @return kerning
341
+ * @param kerning [Float] the kerning
342
+ * @return [Float] the given kerning
401
343
  */
402
344
  VALUE
403
345
  Draw_kerning_eq(VALUE self, VALUE kerning)
@@ -412,17 +354,10 @@ Draw_kerning_eq(VALUE self, VALUE kerning)
412
354
 
413
355
 
414
356
  /**
415
- * Space between two lines.
416
- *
417
- * Ruby usage:
418
- * - @verbatim Draw#interline_spacing= @endverbatim
357
+ * Set spacing between two lines.
419
358
  *
420
- * Notes:
421
- * - New for ImageMagick 6.5.5-8
422
- *
423
- * @param self this object
424
- * @param spacing the spacing
425
- * @return spacing
359
+ * @param spacing [Float] the spacing
360
+ * @return [Float] the given spacing
426
361
  */
427
362
  VALUE
428
363
  Draw_interline_spacing_eq(VALUE self, VALUE spacing)
@@ -437,17 +372,10 @@ Draw_interline_spacing_eq(VALUE self, VALUE spacing)
437
372
 
438
373
 
439
374
  /**
440
- * Space between two words.
441
- *
442
- * Ruby usage:
443
- * - @verbatim Draw#interword_spacing= @endverbatim
444
- *
445
- * Notes:
446
- * - New for ImageMagick 6.4.8-0
375
+ * Set spacing between two words.
447
376
  *
448
- * @param self this object
449
- * @param spacing the spacing
450
- * @return spacing
377
+ * @param spacing [Float] the spacing
378
+ * @return [Float] the given spacing
451
379
  */
452
380
  VALUE
453
381
  Draw_interword_spacing_eq(VALUE self, VALUE spacing)
@@ -477,13 +405,14 @@ static VALUE
477
405
  image_to_str(Image *image)
478
406
  {
479
407
  VALUE dimg = Qnil;
480
- unsigned char *blob;
481
- size_t length;
482
- Info *info;
483
- ExceptionInfo *exception;
484
408
 
485
409
  if (image)
486
410
  {
411
+ unsigned char *blob;
412
+ size_t length;
413
+ Info *info;
414
+ ExceptionInfo *exception;
415
+
487
416
  info = CloneImageInfo(NULL);
488
417
  exception = AcquireExceptionInfo();
489
418
  blob = ImageToBlob(info, image, &length, exception);
@@ -516,11 +445,12 @@ static
516
445
  Image *str_to_image(VALUE str)
517
446
  {
518
447
  Image *image = NULL;
519
- Info *info;
520
- ExceptionInfo *exception;
521
448
 
522
449
  if (str != Qnil)
523
450
  {
451
+ Info *info;
452
+ ExceptionInfo *exception;
453
+
524
454
  info = CloneImageInfo(NULL);
525
455
  exception = AcquireExceptionInfo();
526
456
  image = BlobToImage(info, RSTRING_PTR(str), RSTRING_LEN(str), exception);
@@ -534,21 +464,16 @@ Image *str_to_image(VALUE str)
534
464
 
535
465
 
536
466
  /**
537
- * Custom marshal for Draw objects.
467
+ * Dump custom marshal for Draw objects.
538
468
  *
539
- * Ruby usage:
540
- * - @verbatim Draw#marshal_dump @endverbatim
469
+ * - Instead of trying to replicate Ruby's support for cross-system
470
+ * marshalling, exploit it. Convert the Draw fields to Ruby objects and
471
+ * store them in a hash. Let Ruby marshal the hash.
472
+ * - Commented out code that dumps/loads fields that are used internally by
473
+ * ImageMagick and shouldn't be marshaled. I left the code as placeholders
474
+ * so I'll know which fields have been deliberately omitted.
541
475
  *
542
- * Notes:
543
- * - Instead of trying to replicate Ruby's support for cross-system
544
- * marshalling, exploit it. Convert the Draw fields to Ruby objects and
545
- * store them in a hash. Let Ruby marshal the hash.
546
- * - Commented out code that dumps/loads fields that are used internally by
547
- * ImageMagick and shouldn't be marshaled. I left the code as placeholders
548
- * so I'll know which fields have been deliberately omitted.
549
- *
550
- * @param self this object
551
- * @return the marshalled object (as a Ruby hash)
476
+ * @return [Hash] the marshalled object
552
477
  * @todo Handle gradients when christy gets the new gradient support added (23Dec08)
553
478
  */
554
479
  VALUE
@@ -608,7 +533,11 @@ Draw_marshal_dump(VALUE self)
608
533
  // rb_hash_aset(ddraw, CSTR2SYM("clip_mask"), MAGICK_STRING_TO_OBJ(draw->info->clip_mask)); internal
609
534
  // rb_hash_aset(ddraw, CSTR2SYM("bounds"), Import_SegmentInfo(&draw->info->bounds)); internal
610
535
  rb_hash_aset(ddraw, CSTR2SYM("clip_units"), INT2FIX(draw->info->clip_units));
536
+ #if defined(IMAGEMAGICK_7)
537
+ rb_hash_aset(ddraw, CSTR2SYM("alpha"), QUANTUM2NUM(draw->info->alpha));
538
+ #else
611
539
  rb_hash_aset(ddraw, CSTR2SYM("opacity"), QUANTUM2NUM(draw->info->opacity));
540
+ #endif
612
541
  // rb_hash_aset(ddraw, CSTR2SYM("render"), draw->info->render ? Qtrue : Qfalse); internal
613
542
  // rb_hash_aset(ddraw, CSTR2SYM("element_reference"), Qnil); // not used yet
614
543
  // rb_hash_aset(ddraw, CSTR2SYM("debug"), draw->info->debug ? Qtrue : Qfalse);
@@ -624,17 +553,10 @@ Draw_marshal_dump(VALUE self)
624
553
 
625
554
 
626
555
  /**
627
- * Support Marsal.load.
628
- *
629
- * Ruby usage:
630
- * - @verbatim Draw#marshal_load @endverbatim
631
- *
632
- * Notes:
633
- * - On entry all fields are all-bits-0
556
+ * Load the marshalled object
634
557
  *
635
- * @param self this object
636
- * @param ddraw the marshalled object
637
- * @return self, once marshalled
558
+ * @param ddraw [Hash] the marshalled object
559
+ * @return [Magick::Draw] self, once marshalled
638
560
  */
639
561
  VALUE
640
562
  Draw_marshal_load(VALUE self, VALUE ddraw)
@@ -643,7 +565,15 @@ Draw_marshal_load(VALUE self, VALUE ddraw)
643
565
  VALUE val;
644
566
 
645
567
  Data_Get_Struct(self, Draw, draw);
568
+
569
+ if (draw->info == NULL)
570
+ {
571
+ ImageInfo *image_info;
646
572
 
573
+ image_info = CloneImageInfo(NULL);
574
+ draw->info = CloneDrawInfo(image_info, (DrawInfo *) NULL);
575
+ DestroyImageInfo(image_info);
576
+ }
647
577
  OBJ_TO_MAGICK_STRING(draw->info->geometry, rb_hash_aref(ddraw, CSTR2SYM("geometry")));
648
578
 
649
579
  //val = rb_hash_aref(ddraw, CSTR2SYM("viewbox"));
@@ -681,7 +611,11 @@ Draw_marshal_load(VALUE self, VALUE ddraw)
681
611
  Color_to_PixelColor(&draw->info->undercolor, val);
682
612
 
683
613
  draw->info->clip_units = FIX2INT(rb_hash_aref(ddraw, CSTR2SYM("clip_units")));
614
+ #if defined(IMAGEMAGICK_7)
615
+ draw->info->alpha = NUM2QUANTUM(rb_hash_aref(ddraw, CSTR2SYM("alpha")));
616
+ #else
684
617
  draw->info->opacity = NUM2QUANTUM(rb_hash_aref(ddraw, CSTR2SYM("opacity")));
618
+ #endif
685
619
  draw->info->kerning = NUM2DBL(rb_hash_aref(ddraw, CSTR2SYM("kerning")));
686
620
  draw->info->interword_spacing = NUM2DBL(rb_hash_aref(ddraw, CSTR2SYM("interword_spacing")));
687
621
 
@@ -694,14 +628,10 @@ Draw_marshal_load(VALUE self, VALUE ddraw)
694
628
 
695
629
 
696
630
  /**
697
- * Pointsize attribute writer.
631
+ * Set point size to draw text.
698
632
  *
699
- * Ruby usage:
700
- * - @verbatim Draw#pointsize= @endverbatim
701
- *
702
- * @param self this object
703
- * @param pointsize the pointsize
704
- * @return pointsize
633
+ * @param pointsize [Float] the pointsize
634
+ * @return [Float] the given pointsize
705
635
  */
706
636
  VALUE
707
637
  Draw_pointsize_eq(VALUE self, VALUE pointsize)
@@ -716,19 +646,10 @@ Draw_pointsize_eq(VALUE self, VALUE pointsize)
716
646
 
717
647
 
718
648
  /**
719
- * Set rotation attribute value.
720
- *
721
- * Ruby usage:
722
- * - @verbatim Magick::Draw#rotation= @endverbatim
649
+ * Set rotation. The argument should be in degrees.
723
650
  *
724
- * Notes:
725
- * - Argument should be in degrees
726
- * - Taken from Magick++'s Magick::Image::annotate method.
727
- * Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002
728
- *
729
- * @param self this object
730
- * @param deg the number of degrees
731
- * @return deg
651
+ * @param deg [Float] the number of degrees
652
+ * @return [Float] the given degrees
732
653
  */
733
654
  VALUE
734
655
  Draw_rotation_eq(VALUE self, VALUE deg)
@@ -743,24 +664,19 @@ Draw_rotation_eq(VALUE self, VALUE deg)
743
664
  degrees = NUM2DBL(deg);
744
665
  if (fabs(degrees) > DBL_EPSILON)
745
666
  {
746
- affine.sx=1.0;
747
- affine.rx=0.0;
748
- affine.ry=0.0;
749
- affine.sy=1.0;
750
- affine.tx=0.0;
751
- affine.ty=0.0;
752
-
753
- current = draw->info->affine;
754
- affine.sx=cos(DegreesToRadians(fmod(degrees,360.0)));
755
- affine.rx=sin(DegreesToRadians(fmod(degrees,360.0)));
756
- affine.ry=(-sin(DegreesToRadians(fmod(degrees,360.0))));
757
- affine.sy=cos(DegreesToRadians(fmod(degrees,360.0)));
758
-
759
- draw->info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
760
- draw->info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
761
- draw->info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
762
- draw->info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
763
- draw->info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
667
+ current = draw->info->affine;
668
+ affine.sx = cos(DegreesToRadians(fmod(degrees, 360.0)));
669
+ affine.rx = sin(DegreesToRadians(fmod(degrees, 360.0)));
670
+ affine.tx = 0.0;
671
+ affine.ry = (-sin(DegreesToRadians(fmod(degrees, 360.0))));
672
+ affine.sy = cos(DegreesToRadians(fmod(degrees, 360.0)));
673
+ affine.ty = 0.0;
674
+
675
+ draw->info->affine.sx = current.sx*affine.sx+current.ry*affine.rx;
676
+ draw->info->affine.rx = current.rx*affine.sx+current.sy*affine.rx;
677
+ draw->info->affine.ry = current.sx*affine.ry+current.ry*affine.sy;
678
+ draw->info->affine.sy = current.rx*affine.ry+current.sy*affine.sy;
679
+ draw->info->affine.tx = current.sx*affine.tx+current.ry*affine.ty+current.tx;
764
680
  }
765
681
 
766
682
  return deg;
@@ -768,14 +684,10 @@ Draw_rotation_eq(VALUE self, VALUE deg)
768
684
 
769
685
 
770
686
  /**
771
- * Stroke attribute writer.
687
+ * Set stroke.
772
688
  *
773
- * Ruby usage:
774
- * - @verbatim Draw#stroke= @endverbatim
775
- *
776
- * @param self this object
777
- * @param stroke the stroke
778
- * @return stroke
689
+ * @param stroke [Magick::Pixel, String] the stroke
690
+ * @return [Magick::Pixel, String] the given stroke
779
691
  */
780
692
  VALUE
781
693
  Draw_stroke_eq(VALUE self, VALUE stroke)
@@ -792,19 +704,15 @@ Draw_stroke_eq(VALUE self, VALUE stroke)
792
704
  /**
793
705
  * Accept an image as a stroke pattern.
794
706
  *
795
- * Ruby usage:
796
- * - @verbatim Draw#stroke_pattern= @endverbatim
797
- *
798
- * @param self this object
799
- * @param pattern the pattern
800
- * @return pattern
801
- * @see Draw_fill_pattern_eq
707
+ * @param pattern [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
708
+ * imagelist, uses the current image.
709
+ * @return [Magick::Image] the given pattern
710
+ * @see #fill_pattern
802
711
  */
803
712
  VALUE
804
713
  Draw_stroke_pattern_eq(VALUE self, VALUE pattern)
805
714
  {
806
715
  Draw *draw;
807
- Image *image;
808
716
 
809
717
  rb_check_frozen(self);
810
718
  Data_Get_Struct(self, Draw, draw);
@@ -818,6 +726,8 @@ Draw_stroke_pattern_eq(VALUE self, VALUE pattern)
818
726
 
819
727
  if (!NIL_P(pattern))
820
728
  {
729
+ Image *image;
730
+
821
731
  // DestroyDrawInfo destroys the clone
822
732
  pattern = rm_cur_image(pattern);
823
733
  image = rm_check_destroyed(pattern);
@@ -830,14 +740,10 @@ Draw_stroke_pattern_eq(VALUE self, VALUE pattern)
830
740
 
831
741
 
832
742
  /**
833
- * Stroke_width attribute writer.
834
- *
835
- * Ruby usage:
836
- * - @verbatim Draw#stroke_width= @endverbatim
743
+ * Set stroke width.
837
744
  *
838
- * @param self this object
839
- * @param stroke_width the stroke_width
840
- * @return stroke_width
745
+ * @param stroke_width [Float] the stroke width
746
+ * @return [Float] the given stroke width
841
747
  */
842
748
  VALUE
843
749
  Draw_stroke_width_eq(VALUE self, VALUE stroke_width)
@@ -852,14 +758,10 @@ Draw_stroke_width_eq(VALUE self, VALUE stroke_width)
852
758
 
853
759
 
854
760
  /**
855
- * Text_antialias attribute writer.
761
+ * Set whether to enable text antialias.
856
762
  *
857
- * Ruby usage:
858
- * - @verbatim Draw#text_antialias= @endverbatim
859
- *
860
- * @param self this object
861
- * @param text_antialias the text_antialias
862
- * @return text_antialias
763
+ * @param text_antialias [Boolean] true if enable text antialias
764
+ * @return [Boolean] the given value
863
765
  */
864
766
  VALUE
865
767
  Draw_text_antialias_eq(VALUE self, VALUE text_antialias)
@@ -874,14 +776,10 @@ Draw_text_antialias_eq(VALUE self, VALUE text_antialias)
874
776
 
875
777
 
876
778
  /**
877
- * Tile attribute writer.
878
- *
879
- * Ruby usage:
880
- * - @verbatim Draw#tile= @endverbatim
779
+ * Accept an image as a fill pattern. This is alias of {Draw#fill_pattern=}.
881
780
  *
882
- * @param self this object
883
- * @param image the image to tile
884
- * @return image
781
+ * @param image [Magick::Image] the image to tile
782
+ * @return [Magick::Image] the given image
885
783
  */
886
784
  VALUE
887
785
  Draw_tile_eq(VALUE self, VALUE image)
@@ -891,14 +789,10 @@ Draw_tile_eq(VALUE self, VALUE image)
891
789
 
892
790
 
893
791
  /**
894
- * Undercolor attribute writer.
895
- *
896
- * Ruby usage:
897
- * - @verbatim Draw#undercolor= @endverbatim
792
+ * Set undercolor.
898
793
  *
899
- * @param self this object
900
- * @param undercolor the undercolor
901
- * @return undercolor
794
+ * @param undercolor [Magick::Pixel, String] the undercolor
795
+ * @return [Magick::Pixel, String] the given undercolor
902
796
  */
903
797
  VALUE
904
798
  Draw_undercolor_eq(VALUE self, VALUE undercolor)
@@ -915,21 +809,17 @@ Draw_undercolor_eq(VALUE self, VALUE undercolor)
915
809
  /**
916
810
  * Annotates an image with text.
917
811
  *
918
- * Ruby usage:
919
- * - @verbatim Draw#annotate(img, w, h, x, y, text) <{optional parms}> @endverbatim
920
- *
921
- * Notes:
922
- * - Additional Draw attribute methods may be called in the optional block,
923
- * which is executed in the context of an Draw object.
924
- *
925
- * @param self this object
926
- * @param image_arg the image
927
- * @param width_arg the width
928
- * @param height_arg the height
929
- * @param x_arg x position
930
- * @param y_arg y position
931
- * @param text the annotation text
932
- * @return self
812
+ * - Additional Draw attribute methods may be called in the optional block,
813
+ * which is executed in the context of an Draw object.
814
+ *
815
+ * @param image_arg [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
816
+ * imagelist, uses the current image.
817
+ * @param width_arg [Numeric] the width
818
+ * @param height_arg [Numeric] the height
819
+ * @param x_arg [Numeric] x position
820
+ * @param y_arg [Numeric] y position
821
+ * @param text [String] the annotation text
822
+ * @return [Magick::Draw] self
933
823
  */
934
824
  VALUE Draw_annotate(
935
825
  VALUE self,
@@ -946,6 +836,10 @@ VALUE Draw_annotate(
946
836
  long x, y;
947
837
  AffineMatrix keep;
948
838
  char geometry_str[100];
839
+ char *embed_text;
840
+ #if defined(IMAGEMAGICK_7)
841
+ ExceptionInfo *exception;
842
+ #endif
949
843
 
950
844
  // Save the affine matrix in case it is modified by
951
845
  // Draw#rotation=
@@ -959,13 +853,39 @@ VALUE Draw_annotate(
959
853
  // allowing the app a chance to modify the object's attributes
960
854
  if (rb_block_given_p())
961
855
  {
962
- (void)rb_obj_instance_eval(0, NULL, self);
856
+ if (rb_proc_arity(rb_block_proc()) == 0)
857
+ {
858
+ // Run the block in self's context
859
+ rb_warn("passing a block without an image argument is deprecated");
860
+ rb_obj_instance_eval(0, NULL, self);
861
+ }
862
+ else
863
+ {
864
+ rb_yield(self);
865
+ }
963
866
  }
964
867
 
965
868
  // Translate & store in Draw structure
966
- draw->info->text = InterpretImageProperties(NULL, image, StringValuePtr(text));
869
+ embed_text = StringValueCStr(text);
870
+ #if defined(IMAGEMAGICK_7)
871
+ exception = AcquireExceptionInfo();
872
+ draw->info->text = InterpretImageProperties(NULL, image, embed_text, exception);
873
+ if (rm_should_raise_exception(exception, RetainExceptionRetention))
874
+ {
875
+ if (draw->info->text)
876
+ {
877
+ magick_free(draw->info->text);
878
+ }
879
+ rm_raise_exception(exception);
880
+ }
881
+ #else
882
+ draw->info->text = InterpretImageProperties(NULL, image, embed_text);
883
+ #endif
967
884
  if (!draw->info->text)
968
885
  {
886
+ #if defined(IMAGEMAGICK_7)
887
+ DestroyExceptionInfo(exception);
888
+ #endif
969
889
  rb_raise(rb_eArgError, "no text");
970
890
  }
971
891
 
@@ -978,24 +898,33 @@ VALUE Draw_annotate(
978
898
 
979
899
  if (width == 0 && height == 0)
980
900
  {
981
- sprintf(geometry_str, "%+ld%+ld", x, y);
901
+ snprintf(geometry_str, sizeof(geometry_str), "%+ld%+ld", x, y);
982
902
  }
983
903
 
984
904
  // WxH is non-zero
985
905
  else
986
906
  {
987
- sprintf(geometry_str, "%lux%lu%+ld%+ld", width, height, x, y);
907
+ snprintf(geometry_str, sizeof(geometry_str), "%lux%lu%+ld%+ld", width, height, x, y);
988
908
  }
989
909
 
990
910
  magick_clone_string(&draw->info->geometry, geometry_str);
991
911
 
992
- (void) AnnotateImage(image, draw->info);
912
+ #if defined(IMAGEMAGICK_7)
913
+ AnnotateImage(image, draw->info, exception);
914
+ #else
915
+ AnnotateImage(image, draw->info);
916
+ #endif
993
917
 
994
918
  magick_free(draw->info->text);
995
919
  draw->info->text = NULL;
996
920
  draw->info->affine = keep;
997
921
 
922
+ #if defined(IMAGEMAGICK_7)
923
+ CHECK_EXCEPTION();
924
+ DestroyExceptionInfo(exception);
925
+ #else
998
926
  rm_check_image_exception(image, RetainOnError);
927
+ #endif
999
928
 
1000
929
  return self;
1001
930
  }
@@ -1004,13 +933,7 @@ VALUE Draw_annotate(
1004
933
  /**
1005
934
  * Clones this object.
1006
935
  *
1007
- * Ruby usage:
1008
- * - @verbatim Draw#clone @endverbatim
1009
- *
1010
- * @param self this object
1011
- * @return the clone
1012
- * @see Draw_dup
1013
- * @see Draw_init_copy
936
+ * @return [Magick::Draw] the cloned object
1014
937
  */
1015
938
  VALUE
1016
939
  Draw_clone(VALUE self)
@@ -1030,21 +953,28 @@ Draw_clone(VALUE self)
1030
953
 
1031
954
 
1032
955
  /**
1033
- * Implement the "image" drawing primitive.
1034
- *
1035
- * Ruby usage:
1036
- * - @verbatim Draw#composite(x,y,width,height,img) @endverbatim
1037
- * - @verbatim Draw#composite(x,y,width,height,img,operator) @endverbatim
1038
- *
1039
- * Notes:
1040
- * - Default operator is overComposite
1041
- * - The "img" argument can be either an ImageList object or an Image
956
+ * Draw the image.
957
+ *
958
+ * @overload composite(x, y, width, height, image)
959
+ * @param x [Float] x position
960
+ * @param y [Float] y position
961
+ * @param width [Float] the width
962
+ * @param height [Float] the height
963
+ * @param image [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
964
+ * imagelist, uses the current image.
965
+ *
966
+ * @overload composite(x, y, width, height, image, operator = Magick::OverCompositeOp)
967
+ * - The "image" argument can be either an ImageList object or an Image
1042
968
  * argument.
1043
- *
1044
- * @param argc number of input arguments
1045
- * @param argv array of input arguments
1046
- * @param self this object
1047
- * @return self
969
+ * @param x [Float] x position
970
+ * @param y [Float] y position
971
+ * @param width [Float] the width
972
+ * @param height [Float] the height
973
+ * @param image [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
974
+ * imagelist, uses the current image.
975
+ * @param operator [Magick::CompositeOperator] the operator
976
+ *
977
+ * @return [Magick::Draw] self
1048
978
  */
1049
979
  VALUE
1050
980
  Draw_composite(int argc, VALUE *argv, VALUE self)
@@ -1089,22 +1019,22 @@ Draw_composite(int argc, VALUE *argv, VALUE self)
1089
1019
  Data_Get_Struct(self, Draw, draw);
1090
1020
 
1091
1021
  // Create a temp copy of the composite image
1092
- rm_write_temp_image(comp_img, name);
1022
+ rm_write_temp_image(comp_img, name, sizeof(name));
1093
1023
 
1094
1024
  // Add the temp filename to the filename array.
1095
1025
  // Use Magick storage since we need to keep the list around
1096
1026
  // until destroy_Draw is called.
1097
- tmpfile_name = magick_malloc(sizeof(struct TmpFile_Name)+strlen(name));
1027
+ tmpfile_name = magick_malloc(sizeof(struct TmpFile_Name) + rm_strnlen_s(name, sizeof(name)));
1098
1028
  strcpy(tmpfile_name->name, name);
1099
1029
  tmpfile_name->next = draw->tmpfile_ary;
1100
1030
  draw->tmpfile_ary = tmpfile_name;
1101
1031
 
1102
1032
  // Form the drawing primitive
1103
- (void) snprintf(primitive, sizeof(primitive), "image %s %g,%g,%g,%g '%s'", op, x, y, width, height, name);
1033
+ snprintf(primitive, sizeof(primitive), "image %s %g,%g,%g,%g '%s'", op, x, y, width, height, name);
1104
1034
 
1105
1035
 
1106
1036
  // Send "primitive" to self.
1107
- (void) rb_funcall(self, rb_intern("primitive"), 1, rb_str_new2(primitive));
1037
+ rb_funcall(self, rb_intern("primitive"), 1, rb_str_new2(primitive));
1108
1038
 
1109
1039
  RB_GC_GUARD(image);
1110
1040
 
@@ -1115,18 +1045,18 @@ Draw_composite(int argc, VALUE *argv, VALUE self)
1115
1045
  /**
1116
1046
  * Execute the stored drawing primitives on the current image.
1117
1047
  *
1118
- * Ruby usage:
1119
- * - @verbatim Draw#draw(i) @endverbatim
1120
- *
1121
- * @param self this object
1122
- * @param image_arg the image argument
1123
- * @return self
1048
+ * @param image_arg [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
1049
+ * imagelist, uses the current image.
1050
+ * @return [Magick::Draw] self
1124
1051
  */
1125
1052
  VALUE
1126
1053
  Draw_draw(VALUE self, VALUE image_arg)
1127
1054
  {
1128
1055
  Draw *draw;
1129
1056
  Image *image;
1057
+ #if defined(IMAGEMAGICK_7)
1058
+ ExceptionInfo *exception;
1059
+ #endif
1130
1060
 
1131
1061
  image_arg = rm_cur_image(image_arg);
1132
1062
  image = rm_check_frozen(image_arg);
@@ -1138,31 +1068,35 @@ Draw_draw(VALUE self, VALUE image_arg)
1138
1068
  }
1139
1069
 
1140
1070
  // Point the DrawInfo structure at the current set of primitives.
1141
- magick_clone_string(&(draw->info->primitive), StringValuePtr(draw->primitives));
1071
+ magick_clone_string(&(draw->info->primitive), StringValueCStr(draw->primitives));
1142
1072
 
1143
- (void) DrawImage(image, draw->info);
1144
- rm_check_image_exception(image, RetainOnError);
1073
+ #if defined(IMAGEMAGICK_7)
1074
+ exception = AcquireExceptionInfo();
1075
+ DrawImage(image, draw->info, exception);
1076
+ #else
1077
+ DrawImage(image, draw->info);
1078
+ #endif
1145
1079
 
1146
1080
  magick_free(draw->info->primitive);
1147
1081
  draw->info->primitive = NULL;
1148
1082
 
1083
+ #if defined(IMAGEMAGICK_7)
1084
+ CHECK_EXCEPTION();
1085
+ DestroyExceptionInfo(exception);
1086
+ #else
1087
+ rm_check_image_exception(image, RetainOnError);
1088
+ #endif
1089
+
1149
1090
  return self;
1150
1091
  }
1151
1092
 
1152
1093
 
1153
1094
  /**
1154
- * Copy a Draw object.
1155
- *
1156
- * Ruby usage:
1157
- * - @verbatim Draw#dup @endverbatim
1095
+ * Duplicate a Draw object.
1158
1096
  *
1159
- * Notes:
1160
- * - Constructs a new Draw object, then calls initialize_copy.
1097
+ * - Constructs a new Draw object, then calls initialize_copy.
1161
1098
  *
1162
- * @param self this object
1163
- * @return the duplicate
1164
- * @see Draw_clone
1165
- * @see Draw_init_copy
1099
+ * @return [Magick::Draw] the duplicated object
1166
1100
  */
1167
1101
  VALUE
1168
1102
  Draw_dup(VALUE self)
@@ -1173,11 +1107,6 @@ Draw_dup(VALUE self)
1173
1107
  draw = ALLOC(Draw);
1174
1108
  memset(draw, 0, sizeof(Draw));
1175
1109
  dup = Data_Wrap_Struct(CLASS_OF(self), mark_Draw, destroy_Draw, draw);
1176
- if (rb_obj_tainted(self))
1177
- {
1178
- (void)rb_obj_taint(dup);
1179
- }
1180
-
1181
1110
  RB_GC_GUARD(dup);
1182
1111
 
1183
1112
  return rb_funcall(dup, rm_ID_initialize_copy, 1, self);
@@ -1187,19 +1116,19 @@ Draw_dup(VALUE self)
1187
1116
  /**
1188
1117
  * Returns measurements for a given font and text string.
1189
1118
  *
1190
- * Ruby usage:
1191
- * - @verbatim Draw#get_type_metrics(text) @endverbatim
1192
- * - @verbatim Draw#get_type_metrics(image, text) @endverbatim
1119
+ * - If the image argument has been omitted, use a dummy image, but make sure
1120
+ * the text has none of the special characters that refer to image
1121
+ * attributes.
1193
1122
  *
1194
- * Notes:
1195
- * - If the image argument has been omitted, use a dummy image, but make sure
1196
- * the text has none of the special characters that refer to image
1197
- * attributes.
1123
+ * @overload get_type_metrics(text)
1124
+ * @param text [String] The string to be rendered.
1198
1125
  *
1199
- * @param argc number of input arguments
1200
- * @param argv array of input arguments
1201
- * @param self this object
1202
- * @return the duplicate
1126
+ * @overload get_type_metrics(image, text)
1127
+ * @param image [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
1128
+ * imagelist, uses the current image.
1129
+ * @param text [String] The string to be rendered.
1130
+ *
1131
+ * @return [Magick::TypeMetric] The information for a specific string if rendered on a image.
1203
1132
  */
1204
1133
  VALUE
1205
1134
  Draw_get_type_metrics(
@@ -1214,19 +1143,19 @@ Draw_get_type_metrics(
1214
1143
  /**
1215
1144
  * Returns measurements for a given font and text string.
1216
1145
  *
1217
- * Ruby usage:
1218
- * - @verbatim Draw#get_multiline_type_metrics(text) @endverbatim
1219
- * - @verbatim Draw#get_multiline_type_metrics(image, text) @endverbatim
1146
+ * - If the image argument has been omitted, use a dummy image, but make sure
1147
+ * the text has none of the special characters that refer to image
1148
+ * attributes.
1220
1149
  *
1221
- * Notes:
1222
- * - If the image argument has been omitted, use a dummy image, but make sure
1223
- * the text has none of the special characters that refer to image
1224
- * attributes.
1150
+ * @overload get_multiline_type_metrics(text)
1151
+ * @param text [String] The string to be rendered.
1225
1152
  *
1226
- * @param argc number of input arguments
1227
- * @param argv array of input arguments
1228
- * @param self this object
1229
- * @return the duplicate
1153
+ * @overload Draw#get_multiline_type_metrics(image, text)
1154
+ * @param image [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
1155
+ * imagelist, uses the current image.
1156
+ * @param text [String] The string to be rendered.
1157
+ *
1158
+ * @return [Magick::TypeMetric] The information for a specific string if rendered on a image.
1230
1159
  */
1231
1160
  VALUE
1232
1161
  Draw_get_multiline_type_metrics(
@@ -1241,14 +1170,8 @@ Draw_get_multiline_type_metrics(
1241
1170
  /**
1242
1171
  * Initialize clone, dup methods.
1243
1172
  *
1244
- * Ruby usage:
1245
- * - @verbatim Draw#initialize_copy @endverbatim
1246
- *
1247
- * @param self this object
1248
1173
  * @param orig the original object
1249
- * @return self
1250
- * @see Draw_clone
1251
- * @see Draw_dup
1174
+ * @return [Magick::Draw] self
1252
1175
  */
1253
1176
  VALUE Draw_init_copy(VALUE self, VALUE orig)
1254
1177
  {
@@ -1275,11 +1198,7 @@ VALUE Draw_init_copy(VALUE self, VALUE orig)
1275
1198
  /**
1276
1199
  * Initialize Draw object.
1277
1200
  *
1278
- * Ruby usage:
1279
- * - @verbatim Draw#initialize <{ info initializers }> @endverbatim
1280
- *
1281
- * @param self this object
1282
- * @return self
1201
+ * @return [Magick::Draw] self
1283
1202
  */
1284
1203
  VALUE
1285
1204
  Draw_initialize(VALUE self)
@@ -1303,12 +1222,8 @@ Draw_initialize(VALUE self)
1303
1222
  /**
1304
1223
  * Display the primitives.
1305
1224
  *
1306
- * Ruby usage:
1307
- * - @verbatim Draw#inspect @endverbatim
1308
- *
1309
- * @param self this object
1310
- * @return the draw primitives or the Ruby string "(no primitives defined)" if
1311
- * they are not defined
1225
+ * @return [String] the draw primitives or the Ruby string "(no primitives defined)"
1226
+ * if they are not defined
1312
1227
  */
1313
1228
  VALUE
1314
1229
  Draw_inspect(VALUE self)
@@ -1323,13 +1238,7 @@ Draw_inspect(VALUE self)
1323
1238
  /**
1324
1239
  * Create a new Draw object.
1325
1240
  *
1326
- * Ruby usage:
1327
- * - @verbatim Draw.new @endverbatim
1328
- * - @verbatim Draw.allocate @endverbatim
1329
- *
1330
- * @param class the Ruby Draw class
1331
- * @return a new Draw object
1332
- * @throw ImageMagickError if no memory
1241
+ * @return [Magick::Draw] a new Draw object
1333
1242
  */
1334
1243
  VALUE Draw_alloc(VALUE class)
1335
1244
  {
@@ -1349,12 +1258,8 @@ VALUE Draw_alloc(VALUE class)
1349
1258
  /**
1350
1259
  * Add a drawing primitive to the list of primitives in the Draw object.
1351
1260
  *
1352
- * Ruby usage:
1353
- * - @verbatim Draw#primitive @endverbatim
1354
- *
1355
- * @param self this object
1356
- * @param primitive the primitive to add
1357
- * @return self
1261
+ * @param primitive [String] the primitive to add
1262
+ * @return [Magick::Draw] self
1358
1263
  */
1359
1264
  VALUE
1360
1265
  Draw_primitive(VALUE self, VALUE primitive)
@@ -1408,17 +1313,18 @@ static void
1408
1313
  destroy_Draw(void *drawptr)
1409
1314
  {
1410
1315
  Draw *draw = (Draw *)drawptr;
1411
- struct TmpFile_Name *tmpfile_name;
1412
1316
 
1413
1317
  if (draw->info)
1414
1318
  {
1415
- (void) DestroyDrawInfo(draw->info);
1319
+ DestroyDrawInfo(draw->info);
1416
1320
  draw->info = NULL;
1417
1321
  }
1418
1322
 
1419
1323
  // Erase any temporary image files.
1420
1324
  while (draw->tmpfile_ary)
1421
1325
  {
1326
+ struct TmpFile_Name *tmpfile_name;
1327
+
1422
1328
  tmpfile_name = draw->tmpfile_ary;
1423
1329
  draw->tmpfile_ary = draw->tmpfile_ary->next;
1424
1330
  rm_delete_temp_image(tmpfile_name->name);
@@ -1446,16 +1352,10 @@ new_DrawOptions(void)
1446
1352
  /**
1447
1353
  * Create a DrawOptions object.
1448
1354
  *
1449
- * Ruby usage:
1450
- * - @verbatim DrawOptions#allocate @endverbatim
1451
- * - @verbatim DrawOptions#new @endverbatim
1355
+ * - The DrawOptions class is the same as the Draw class except is has only
1356
+ * the attribute writer functions
1452
1357
  *
1453
- * Notes:
1454
- * - The DrawOptions class is the same as the Draw class except is has only
1455
- * the attribute writer functions
1456
- *
1457
- * @param class the Ruby DrawOptions class
1458
- * @return a new DrawOptions object
1358
+ * @return [Magick::Image::DrawOptions] a new DrawOptions object
1459
1359
  */
1460
1360
  VALUE
1461
1361
  DrawOptions_alloc(VALUE class)
@@ -1476,11 +1376,7 @@ DrawOptions_alloc(VALUE class)
1476
1376
  /**
1477
1377
  * Initialize a DrawOptions object.
1478
1378
  *
1479
- * Ruby usage:
1480
- * - @verbatim DrawOptions#initialize @endverbatim
1481
- *
1482
- * @param self this object
1483
- * @return self
1379
+ * @return [Magick::Image::DrawOptions] self
1484
1380
  */
1485
1381
  VALUE
1486
1382
  DrawOptions_initialize(VALUE self)
@@ -1498,8 +1394,16 @@ DrawOptions_initialize(VALUE self)
1498
1394
 
1499
1395
  if (rb_block_given_p())
1500
1396
  {
1501
- // Run the block in self's context
1502
- (void) rb_obj_instance_eval(0, NULL, self);
1397
+ if (rb_proc_arity(rb_block_proc()) == 0)
1398
+ {
1399
+ // Run the block in self's context
1400
+ rb_warn("passing a block without an image argument is deprecated");
1401
+ rb_obj_instance_eval(0, NULL, self);
1402
+ }
1403
+ else
1404
+ {
1405
+ rb_yield(self);
1406
+ }
1503
1407
  }
1504
1408
 
1505
1409
  return self;
@@ -1507,18 +1411,12 @@ DrawOptions_initialize(VALUE self)
1507
1411
 
1508
1412
 
1509
1413
  /**
1510
- * Allocate a new Magick::PolaroidOptions object.
1414
+ * Allocate a new Magick::Image::PolaroidOptions object.
1511
1415
  *
1512
- * Ruby usage:
1513
- * - @verbatim Magick::PolaroidOptions#allocate @endverbatim
1514
- * - @verbatim Magick::PolaroidOptions#new @endverbatim
1416
+ * - Internally a PolaroidOptions object is the same as a Draw object. The
1417
+ * methods are implemented by Draw methods in rmdraw.c.
1515
1418
  *
1516
- * Notes:
1517
- * - Internally a PolaroidOptions object is the same as a Draw object. The
1518
- * methods are implemented by Draw methods in rmdraw.c.
1519
- *
1520
- * @param class the Ruby PoloradoidOptions class
1521
- * @return a new DrawOptions object
1419
+ * @return [Magick::Image::PolaroidOptions] a new PolaroidOptions object
1522
1420
  */
1523
1421
  VALUE
1524
1422
  PolaroidOptions_alloc(VALUE class)
@@ -1532,8 +1430,8 @@ PolaroidOptions_alloc(VALUE class)
1532
1430
  draw = ALLOC(Draw);
1533
1431
  memset(draw, 0, sizeof(*draw));
1534
1432
 
1535
- draw->info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
1536
- (void)(void) DestroyImageInfo(image_info);
1433
+ draw->info = CloneDrawInfo(image_info, (DrawInfo *) NULL);
1434
+ (void) DestroyImageInfo(image_info);
1537
1435
 
1538
1436
  polaroid_obj = Data_Wrap_Struct(class, NULL, destroy_Draw, draw);
1539
1437
 
@@ -1544,13 +1442,11 @@ PolaroidOptions_alloc(VALUE class)
1544
1442
 
1545
1443
 
1546
1444
  /**
1547
- * Yield to an optional block.
1445
+ * Initialize a PolaroidOptions object.
1548
1446
  *
1549
- * Ruby usage:
1550
- * - @verbatim Magick::PolaroidOptions#initialize @endverbatim
1551
- *
1552
- * @param self this object
1553
- * @return self
1447
+ * @yield [self]
1448
+ * @yieldparam self [Magick::Image::PolaroidOptions] self
1449
+ * @return [Magick::Image::PolaroidOptions] self
1554
1450
  */
1555
1451
  VALUE
1556
1452
  PolaroidOptions_initialize(VALUE self)
@@ -1562,17 +1458,26 @@ PolaroidOptions_initialize(VALUE self)
1562
1458
  Data_Get_Struct(self, Draw, draw);
1563
1459
 
1564
1460
  exception = AcquireExceptionInfo();
1565
- (void) QueryColorCompliance("gray75", AllCompliance, &draw->shadow_color, exception);
1566
- CHECK_EXCEPTION()
1567
- (void) QueryColorCompliance("#dfdfdf", AllCompliance, &draw->info->border_color, exception);
1568
- CHECK_EXCEPTION()
1461
+ QueryColorCompliance("gray75", AllCompliance, &draw->shadow_color, exception);
1462
+ CHECK_EXCEPTION();
1463
+ QueryColorCompliance("#dfdfdf", AllCompliance, &draw->info->border_color, exception);
1464
+ CHECK_EXCEPTION();
1569
1465
  DestroyExceptionInfo(exception);
1570
1466
 
1571
1467
  if (rb_block_given_p())
1572
1468
  {
1573
- // Run the block in self's context
1574
- (void) rb_obj_instance_eval(0, NULL, self);
1469
+ if (rb_proc_arity(rb_block_proc()) == 0)
1470
+ {
1471
+ // Run the block in self's context
1472
+ rb_warn("passing a block without an image argument is deprecated");
1473
+ rb_obj_instance_eval(0, NULL, self);
1474
+ }
1475
+ else
1476
+ {
1477
+ rb_yield(self);
1478
+ }
1575
1479
  }
1480
+
1576
1481
  return self;
1577
1482
  }
1578
1483
 
@@ -1594,12 +1499,8 @@ rm_polaroid_new(void)
1594
1499
  /**
1595
1500
  * Set the shadow color attribute.
1596
1501
  *
1597
- * Ruby usage:
1598
- * - @verbatim PolaroidOptions#shadow_color= @endverbatim
1599
- *
1600
- * @param self this object
1601
- * @param shadow the shadow color
1602
- * @return shadow
1502
+ * @param shadow [Magick::Pixel, String] the shadow color
1503
+ * @return [Magick::Pixel, String] the given shadow color
1603
1504
  */
1604
1505
  VALUE
1605
1506
  PolaroidOptions_shadow_color_eq(VALUE self, VALUE shadow)
@@ -1614,14 +1515,10 @@ PolaroidOptions_shadow_color_eq(VALUE self, VALUE shadow)
1614
1515
 
1615
1516
 
1616
1517
  /**
1617
- * Set the border color attribute.
1618
- *
1619
- * Ruby usage:
1620
- * - @verbatim PolaroidOptions#border_color= @endverbatim
1518
+ * Set the border color.
1621
1519
  *
1622
- * @param self this object
1623
- * @param border the border color
1624
- * @return border
1520
+ * @param border [Magick::Pixel, String] the border color
1521
+ * @return [Magick::Pixel, String] the given border color
1625
1522
  */
1626
1523
  VALUE
1627
1524
  PolaroidOptions_border_color_eq(VALUE self, VALUE border)
@@ -1648,11 +1545,11 @@ get_dummy_tm_img(VALUE klass)
1648
1545
  {
1649
1546
  #define DUMMY_IMG_CLASS_VAR "@@_dummy_img_"
1650
1547
  VALUE dummy_img = 0;
1651
- Info *info;
1652
- Image *image;
1653
1548
 
1654
1549
  if (rb_cvar_defined(klass, rb_intern(DUMMY_IMG_CLASS_VAR)) != Qtrue)
1655
1550
  {
1551
+ Info *info;
1552
+ Image *image;
1656
1553
 
1657
1554
  info = CloneImageInfo(NULL);
1658
1555
  if (!info)
@@ -1660,7 +1557,7 @@ get_dummy_tm_img(VALUE klass)
1660
1557
  rb_raise(rb_eNoMemError, "not enough memory to continue");
1661
1558
  }
1662
1559
  image = rm_acquire_image(info);
1663
- (void) DestroyImageInfo(info);
1560
+ DestroyImageInfo(info);
1664
1561
 
1665
1562
  if (!image)
1666
1563
  {
@@ -1708,6 +1605,9 @@ get_type_metrics(
1708
1605
  char *text = NULL;
1709
1606
  long text_l;
1710
1607
  unsigned int okay;
1608
+ #if defined(IMAGEMAGICK_7)
1609
+ ExceptionInfo *exception;
1610
+ #endif
1711
1611
 
1712
1612
  switch (argc)
1713
1613
  {
@@ -1731,25 +1631,53 @@ get_type_metrics(
1731
1631
  }
1732
1632
 
1733
1633
  Data_Get_Struct(self, Draw, draw);
1634
+ #if defined(IMAGEMAGICK_7)
1635
+ exception = AcquireExceptionInfo();
1636
+ draw->info->text = InterpretImageProperties(NULL, image, text, exception);
1637
+ if (rm_should_raise_exception(exception, RetainExceptionRetention))
1638
+ {
1639
+ if (draw->info->text)
1640
+ {
1641
+ magick_free(draw->info->text);
1642
+ }
1643
+ rm_raise_exception(exception);
1644
+ }
1645
+ #else
1734
1646
  draw->info->text = InterpretImageProperties(NULL, image, text);
1647
+ #endif
1735
1648
  if (!draw->info->text)
1736
1649
  {
1650
+ #if defined(IMAGEMAGICK_7)
1651
+ DestroyExceptionInfo(exception);
1652
+ #endif
1737
1653
  rb_raise(rb_eArgError, "no text to measure");
1738
1654
  }
1739
1655
 
1656
+ #if defined(IMAGEMAGICK_7)
1657
+ okay = (*getter)(image, draw->info, &metrics, exception);
1658
+ #else
1740
1659
  okay = (*getter)(image, draw->info, &metrics);
1660
+ #endif
1741
1661
 
1742
1662
  magick_free(draw->info->text);
1743
1663
  draw->info->text = NULL;
1744
1664
 
1745
1665
  if (!okay)
1746
1666
  {
1667
+ #if defined(IMAGEMAGICK_7)
1668
+ CHECK_EXCEPTION();
1669
+ DestroyExceptionInfo(exception);
1670
+ #else
1747
1671
  rm_check_image_exception(image, RetainOnError);
1672
+ #endif
1748
1673
 
1749
1674
  // Shouldn't get here...
1750
1675
  rb_raise(rb_eRuntimeError, "Can't measure text. Are the fonts installed? "
1751
1676
  "Is the FreeType library installed?");
1752
1677
  }
1678
+ #if defined(IMAGEMAGICK_7)
1679
+ DestroyExceptionInfo(exception);
1680
+ #endif
1753
1681
 
1754
1682
  RB_GC_GUARD(t);
1755
1683