Thse hashes are used to map Magick constant values to the strings used in the primitives.
Apply coordinate transformations to support scaling (s), rotation ®, and translation (t). Angles are specified in radians.
# File lib/RMagick.rb, line 220 220: def affine(sx, rx, ry, sy, tx, ty) 221: primitive "affine " + sprintf("%g,%g,%g,%g,%g,%g", sx, rx, ry, sy, tx, ty) 222: end
Draw an arc.
# File lib/RMagick.rb, line 225 225: def arc(startX, startY, endX, endY, startDegrees, endDegrees) 226: primitive "arc " + sprintf("%g,%g %g,%g %g,%g", 227: startX, startY, endX, endY, startDegrees, endDegrees) 228: end
Draw a bezier curve.
# File lib/RMagick.rb, line 231 231: def bezier(*points) 232: if points.length == 0 233: Kernel.raise ArgumentError, "no points specified" 234: elsif points.length % 2 != 0 235: Kernel.raise ArgumentError, "odd number of arguments specified" 236: end 237: primitive "bezier " + points.join(',') 238: end
Draw a circle
# File lib/RMagick.rb, line 241 241: def circle(originX, originY, perimX, perimY) 242: primitive "circle " + sprintf("%g,%g %g,%g", originX, originY, perimX, perimY) 243: end
Invoke a clip-path defined by def_clip_path.
# File lib/RMagick.rb, line 246 246: def clip_path(name) 247: primitive "clip-path #{name}" 248: end
Define the clipping rule.
# File lib/RMagick.rb, line 251 251: def clip_rule(rule) 252: if ( not ["evenodd", "nonzero"].include?(rule.downcase) ) 253: Kernel.raise ArgumentError, "Unknown clipping rule #{rule}" 254: end 255: primitive "clip-rule #{rule}" 256: end
Define the clip units
# File lib/RMagick.rb, line 259 259: def clip_units(unit) 260: if ( not ["userspace", "userspaceonuse", "objectboundingbox"].include?(unit.downcase) ) 261: Kernel.raise ArgumentError, "Unknown clip unit #{unit}" 262: end 263: primitive "clip-units #{unit}" 264: end
Set color in image according to specified colorization rule. Rule is one of point, replace, floodfill, filltoborder,reset
# File lib/RMagick.rb, line 268 268: def color(x, y, method) 269: if ( not PAINT_METHOD_NAMES.has_key?(method.to_i) ) 270: Kernel.raise ArgumentError, "Unknown PaintMethod: #{method}" 271: end 272: primitive "color #{x},#{y},#{PAINT_METHOD_NAMES[method.to_i]}" 273: end
Specify EITHER the text decoration (none, underline, overline, line-through) OR the text solid background color (any color name or spec)
# File lib/RMagick.rb, line 277 277: def decorate(decoration) 278: if ( DECORATION_TYPE_NAMES.has_key?(decoration.to_i) ) 279: primitive "decorate #{DECORATION_TYPE_NAMES[decoration.to_i]}" 280: else 281: primitive "decorate #{enquote(decoration)}" 282: end 283: end
Define a clip-path. A clip-path is a sequence of primitives bracketed by
the “push clip-path
# File lib/RMagick.rb, line 290 290: def define_clip_path(name) 291: begin 292: push('defs') 293: push('clip-path', name) 294: push('graphic-context') 295: yield 296: ensure 297: pop('graphic-context') 298: pop('clip-path') 299: pop('defs') 300: end 301: end
Draw an ellipse
# File lib/RMagick.rb, line 304 304: def ellipse(originX, originY, width, height, arcStart, arcEnd) 305: primitive "ellipse " + sprintf("%g,%g %g,%g %g,%g", 306: originX, originY, width, height, arcStart, arcEnd) 307: end
Let anything through, but the only defined argument is “UTF-8”. All others are apparently ignored.
# File lib/RMagick.rb, line 311 311: def encoding(encoding) 312: primitive "encoding #{encoding}" 313: end
Specify object fill, a color name or pattern name
# File lib/RMagick.rb, line 316 316: def fill(colorspec) 317: primitive "fill #{enquote(colorspec)}" 318: end
Specify fill opacity (use “xx%” to indicate percentage)
# File lib/RMagick.rb, line 323 323: def fill_opacity(opacity) 324: primitive "fill-opacity #{opacity}" 325: end
# File lib/RMagick.rb, line 327 327: def fill_rule(rule) 328: if ( not ["evenodd", "nonzero"].include?(rule.downcase) ) 329: Kernel.raise ArgumentError, "Unknown fill rule #{rule}" 330: end 331: primitive "fill-rule #{rule}" 332: end
Specify text drawing font
# File lib/RMagick.rb, line 335 335: def font(name) 336: primitive "font #{name}" 337: end
# File lib/RMagick.rb, line 339 339: def font_family(name) 340: primitive "font-family \'#{name}\'" 341: end
# File lib/RMagick.rb, line 343 343: def font_stretch(stretch) 344: if ( not STRETCH_TYPE_NAMES.has_key?(stretch.to_i) ) 345: Kernel.raise ArgumentError, "Unknown stretch type" 346: end 347: primitive "font-stretch #{STRETCH_TYPE_NAMES[stretch.to_i]}" 348: end
# File lib/RMagick.rb, line 350 350: def font_style(style) 351: if ( not STYLE_TYPE_NAMES.has_key?(style.to_i) ) 352: Kernel.raise ArgumentError, "Unknown style type" 353: end 354: primitive "font-style #{STYLE_TYPE_NAMES[style.to_i]}" 355: end
The font weight argument can be either a font weight constant or [100,200,…,900]
# File lib/RMagick.rb, line 359 359: def font_weight(weight) 360: if ( FONT_WEIGHT_NAMES.has_key?(weight.to_i) ) 361: primitive "font-weight #{FONT_WEIGHT_NAMES[weight.to_i]}" 362: else 363: primitive "font-weight #{weight}" 364: end 365: end
Specify the text positioning gravity, one of: NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast
# File lib/RMagick.rb, line 369 369: def gravity(grav) 370: if ( not GRAVITY_NAMES.has_key?(grav.to_i) ) 371: Kernel.raise ArgumentError, "Unknown text positioning gravity" 372: end 373: primitive "gravity #{GRAVITY_NAMES[grav.to_i]}" 374: end
IM 6.5.5-8 and later
# File lib/RMagick.rb, line 377 377: def interline_spacing(space) 378: begin 379: Float(space) 380: rescue ArgumentError 381: Kernel.raise ArgumentError, "invalid value for interline_spacing" 382: rescue TypeError 383: Kernel.raise TypeError, "can't convert #{space.class} into Float" 384: end 385: primitive "interline-spacing #{space}" 386: end
IM 6.4.8-3 and later
# File lib/RMagick.rb, line 389 389: def interword_spacing(space) 390: begin 391: Float(space) 392: rescue ArgumentError 393: Kernel.raise ArgumentError, "invalid value for interword_spacing" 394: rescue TypeError 395: Kernel.raise TypeError, "can't convert #{space.class} into Float" 396: end 397: primitive "interword-spacing #{space}" 398: end
IM 6.4.8-3 and later
# File lib/RMagick.rb, line 401 401: def kerning(space) 402: begin 403: Float(space) 404: rescue ArgumentError 405: Kernel.raise ArgumentError, "invalid value for kerning" 406: rescue TypeError 407: Kernel.raise TypeError, "can't convert #{space.class} into Float" 408: end 409: primitive "kerning #{space}" 410: end
Draw a line
# File lib/RMagick.rb, line 413 413: def line(startX, startY, endX, endY) 414: primitive "line " + sprintf("%g,%g %g,%g", startX, startY, endX, endY) 415: end
Set matte (make transparent) in image according to the specified colorization rule
# File lib/RMagick.rb, line 419 419: def matte(x, y, method) 420: if ( not PAINT_METHOD_NAMES.has_key?(method.to_i) ) 421: Kernel.raise ArgumentError, "Unknown paint method" 422: end 423: primitive "matte #{x},#{y} #{PAINT_METHOD_NAMES[method.to_i]}" 424: end
Specify drawing fill and stroke opacities. If the value is a string ending with a %, the number will be multiplied by 0.01.
# File lib/RMagick.rb, line 428 428: def opacity(opacity) 429: if (Numeric === opacity) 430: if (opacity < 0 || opacity > 1.0) 431: Kernel.raise ArgumentError, "opacity must be >= 0 and <= 1.0" 432: end 433: end 434: primitive "opacity #{opacity}" 435: end
Draw using SVG-compatible path drawing commands. Note that the primitive requires that the commands be surrounded by quotes or apostrophes. Here we simply use apostrophes.
# File lib/RMagick.rb, line 440 440: def path(cmds) 441: primitive "path '" + cmds + "'" 442: end
Define a pattern. In the block, call primitive methods to draw the pattern. Reference the pattern by using its name as the argument to the ‘fill’ or ‘stroke’ methods
# File lib/RMagick.rb, line 447 447: def pattern(name, x, y, width, height) 448: begin 449: push('defs') 450: push("pattern #{name} #{x} #{y} #{width} #{height}") 451: push('graphic-context') 452: yield 453: ensure 454: pop('graphic-context') 455: pop('pattern') 456: pop('defs') 457: end 458: end
Set point to fill color.
# File lib/RMagick.rb, line 461 461: def point(x, y) 462: primitive "point #{x},#{y}" 463: end
Specify the font size in points. Yes, the primitive is “font-size” but in other places this value is called the “pointsize”. Give it both names.
# File lib/RMagick.rb, line 467 467: def pointsize(points) 468: primitive "font-size #{points}" 469: end
Draw a polygon
# File lib/RMagick.rb, line 473 473: def polygon(*points) 474: if points.length == 0 475: Kernel.raise ArgumentError, "no points specified" 476: elsif points.length % 2 != 0 477: Kernel.raise ArgumentError, "odd number of points specified" 478: end 479: primitive "polygon " + points.join(',') 480: end
Draw a polyline
# File lib/RMagick.rb, line 483 483: def polyline(*points) 484: if points.length == 0 485: Kernel.raise ArgumentError, "no points specified" 486: elsif points.length % 2 != 0 487: Kernel.raise ArgumentError, "odd number of points specified" 488: end 489: primitive "polyline " + points.join(',') 490: end
Return to the previously-saved set of whatever pop(‘graphic-context’) (the default if no arguments) pop(‘defs’) pop(‘gradient’) pop(‘pattern’)
# File lib/RMagick.rb, line 498 498: def pop(*what) 499: if what.length == 0 500: primitive "pop graphic-context" 501: else 502: # to_s allows a Symbol to be used instead of a String 503: primitive "pop " + what.map {|w| w.to_s}.join(' ') 504: end 505: end
Push the current set of drawing options. Also you can use push(‘graphic-context’) (the default if no arguments) push(‘defs’) push(‘gradient’) push(‘pattern’)
# File lib/RMagick.rb, line 512 512: def push(*what) 513: if what.length == 0 514: primitive "push graphic-context" 515: else 516: # to_s allows a Symbol to be used instead of a String 517: primitive "push " + what.map {|w| w.to_s}.join(' ') 518: end 519: end
Draw a rectangle
# File lib/RMagick.rb, line 522 522: def rectangle(upper_left_x, upper_left_y, lower_right_x, lower_right_y) 523: primitive "rectangle " + sprintf("%g,%g %g,%g", 524: upper_left_x, upper_left_y, lower_right_x, lower_right_y) 525: end
Specify coordinate space rotation. “angle” is measured in degrees
# File lib/RMagick.rb, line 528 528: def rotate(angle) 529: primitive "rotate #{angle}" 530: end
Draw a rectangle with rounded corners
# File lib/RMagick.rb, line 533 533: def roundrectangle(center_x, center_y, width, height, corner_width, corner_height) 534: primitive "roundrectangle " + sprintf("%g,%g,%g,%g,%g,%g", 535: center_x, center_y, width, height, corner_width, corner_height) 536: end
Specify scaling to be applied to coordinate space on subsequent drawing commands.
# File lib/RMagick.rb, line 539 539: def scale(x, y) 540: primitive "scale #{x},#{y}" 541: end
# File lib/RMagick.rb, line 543 543: def skewx(angle) 544: primitive "skewX #{angle}" 545: end
# File lib/RMagick.rb, line 547 547: def skewy(angle) 548: primitive "skewY #{angle}" 549: end
Specify the object stroke, a color name or pattern name.
# File lib/RMagick.rb, line 552 552: def stroke(colorspec) 553: primitive "stroke #{enquote(colorspec)}" 554: end
Specify if stroke should be antialiased or not
# File lib/RMagick.rb, line 559 559: def stroke_antialias(bool) 560: bool = bool ? '1' : '0' 561: primitive "stroke-antialias #{bool}" 562: end
Specify a stroke dash pattern
# File lib/RMagick.rb, line 565 565: def stroke_dasharray(*list) 566: if list.length == 0 567: primitive "stroke-dasharray none" 568: else 569: list.each { |x| 570: if x <= 0 then 571: Kernel.raise ArgumentError, "dash array elements must be > 0 (#{x} given)" 572: end 573: } 574: primitive "stroke-dasharray #{list.join(',')}" 575: end 576: end
Specify the initial offset in the dash pattern
# File lib/RMagick.rb, line 579 579: def stroke_dashoffset(value=0) 580: primitive "stroke-dashoffset #{value}" 581: end
# File lib/RMagick.rb, line 583 583: def stroke_linecap(value) 584: if ( not ["butt", "round", "square"].include?(value.downcase) ) 585: Kernel.raise ArgumentError, "Unknown linecap type: #{value}" 586: end 587: primitive "stroke-linecap #{value}" 588: end
# File lib/RMagick.rb, line 590 590: def stroke_linejoin(value) 591: if ( not ["round", "miter", "bevel"].include?(value.downcase) ) 592: Kernel.raise ArgumentError, "Unknown linejoin type: #{value}" 593: end 594: primitive "stroke-linejoin #{value}" 595: end
# File lib/RMagick.rb, line 597 597: def stroke_miterlimit(value) 598: if (value < 1) 599: Kernel.raise ArgumentError, "miterlimit must be >= 1" 600: end 601: primitive "stroke-miterlimit #{value}" 602: end
Specify opacity of stroke drawing color
(use "xx%" to indicate percentage)
# File lib/RMagick.rb, line 606 606: def stroke_opacity(value) 607: primitive "stroke-opacity #{value}" 608: end
Specify stroke (outline) width in pixels.
# File lib/RMagick.rb, line 611 611: def stroke_width(pixels) 612: primitive "stroke-width #{pixels}" 613: end
Draw text at position x,y. Add quotes to text that is not already quoted.
# File lib/RMagick.rb, line 616 616: def text(x, y, text) 617: if text.to_s.empty? 618: Kernel.raise ArgumentError, "missing text argument" 619: end 620: if text.length > 2 && /\A(?:\"[^\"]+\"|\'[^\']+\'|\{[^\}]+\})\z/.match(text) 621: ; # text already quoted 622: elsif !text['\'] 623: text = '\'+text+'\' 624: elsif !text['"'] 625: text = '"'+text+'"' 626: elsif !(text['{'] || text['}']) 627: text = '{'+text+'}' 628: else 629: # escape existing braces, surround with braces 630: text = '{' + text.gsub(/[}]/) { |b| '\' + b } + '}' 631: end 632: primitive "text #{x},#{y} #{text}" 633: end
Specify text alignment relative to a given point
# File lib/RMagick.rb, line 636 636: def text_align(alignment) 637: if ( not ALIGN_TYPE_NAMES.has_key?(alignment.to_i) ) 638: Kernel.raise ArgumentError, "Unknown alignment constant: #{alignment}" 639: end 640: primitive "text-align #{ALIGN_TYPE_NAMES[alignment.to_i]}" 641: end
SVG-compatible version of text_align
# File lib/RMagick.rb, line 644 644: def text_anchor(anchor) 645: if ( not ANCHOR_TYPE_NAMES.has_key?(anchor.to_i) ) 646: Kernel.raise ArgumentError, "Unknown anchor constant: #{anchor}" 647: end 648: primitive "text-anchor #{ANCHOR_TYPE_NAMES[anchor.to_i]}" 649: end
Specify if rendered text is to be antialiased.
# File lib/RMagick.rb, line 652 652: def text_antialias(boolean) 653: boolean = boolean ? '1' : '0' 654: primitive "text-antialias #{boolean}" 655: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.