Class | Magick::Draw
In: | lib/RMagick.rb ext/RMagick/rmmain.c
Parent: | Object

### Methods

affine arc bezier circle clip_path clip_rule clip_units color decorate define_clip_path ellipse encoding fill fill_color fill_opacity fill_pattern fill_rule font font_family font_size font_stretch font_style font_weight gravity interline_spacing interword_spacing kerning line matte opacity path pattern point pointsize polygon polyline pop push rectangle rotate roundrectangle scale skewx skewy stroke stroke_antialias stroke_color stroke_dasharray stroke_dashoffset stroke_linecap stroke_linejoin stroke_miterlimit stroke_opacity stroke_pattern stroke_width text text_align text_anchor text_antialias text_undercolor translate

### Constants

ALIGN_TYPE_NAMES | = | { LeftAlign.to_i => 'left', RightAlign.to_i => 'right', CenterAlign.to_i => 'center' |  | Thse hashes are used to map Magick constant values to the strings used in the primitives.
ANCHOR_TYPE_NAMES | = | { StartAnchor.to_i => 'start', MiddleAnchor.to_i => 'middle', EndAnchor.to_i => 'end'
DECORATION_TYPE_NAMES | = | { NoDecoration.to_i => 'none', UnderlineDecoration.to_i => 'underline', OverlineDecoration.to_i => 'overline', LineThroughDecoration.to_i => 'line-through'
FONT_WEIGHT_NAMES | = | { AnyWeight.to_i => 'all', NormalWeight.to_i => 'normal', BoldWeight.to_i => 'bold', BolderWeight.to_i => 'bolder', LighterWeight.to_i => 'lighter', }.freeze
GRAVITY_NAMES | = | { NorthWestGravity.to_i => 'northwest', NorthGravity.to_i => 'north', NorthEastGravity.to_i => 'northeast', WestGravity.to_i => 'west', CenterGravity.to_i => 'center', EastGravity.to_i => 'east', SouthWestGravity.to_i => 'southwest', SouthGravity.to_i => 'south', SouthEastGravity.to_i => 'southeast'
PAINT_METHOD_NAMES | = | { PointMethod.to_i => 'point', ReplaceMethod.to_i => 'replace', FloodfillMethod.to_i => 'floodfill', FillToBorderMethod.to_i => 'filltoborder', ResetMethod.to_i => 'reset'

STRETCH_TYPE_NAMES

=

{ NormalStretch.to_i => 'normal', UltraCondensedStretch.to_i => 'ultra-condensed', ExtraCondensedStretch.to_i => 'extra-condensed', CondensedStretch.to_i => 'condensed', SemiCondensedStretch.to_i => 'semi-condensed', SemiExpandedStretch.to_i => 'semi-expanded', ExpandedStretch.to_i => 'expanded', ExtraExpandedStretch.to_i => 'extra-expanded', UltraExpandedStretch.to_i => 'ultra-expanded', AnyStretch.to_i => 'all'

STYLE_TYPE_NAMES | = | { NormalStyle.to_i => 'normal', ItalicStyle.to_i => 'italic', ObliqueStyle.to_i => 'oblique', AnyStyle.to_i => 'all'

### Public Instance methods

affine(sx, rx, ry, sy, tx, ty)

Apply coordinate transformations to support scaling (s), rotation (r), and translation (t). Angles are specified in radians.

arc(startX, startY, endX, endY, startDegrees, endDegrees)

Draw an arc.

bezier(*points)

Draw a bezier curve.

circle(originX, originY, perimX, perimY)

Draw a circle

clip_path(name)

Invoke a clip-path defined by def_clip_path.

clip_rule(rule)

Define the clipping rule.

clip_units(unit)

Define the clip units

color(x, y, method)

Set color in image according to specified colorization rule. Rule is one of point, replace, floodfill, filltoborder,reset

decorate(decoration)

Specify EITHER the text decoration (none, underline, overline, line-through) OR the text solid background color (any color name or spec)

define_clip_path(name) {|| ...}

Define a clip-path. A clip-path is a sequence of primitives bracketed by the "push clip-path <name>" and "pop clip-path" primitives. Upon advice from the IM guys, we also bracket the clip-path primitives with "push(pop) defs" and "push (pop) graphic-context".

ellipse(originX, originY, width, height, arcStart, arcEnd)

Draw an ellipse

encoding(encoding)

Let anything through, but the only defined argument is "UTF-8". All others are apparently ignored.

fill(colorspec)

Specify object fill, a color name or pattern name

fill_color(colorspec)

Alias for fill

fill_opacity(opacity)

Specify fill opacity (use "xx%" to indicate percentage)

fill_pattern(colorspec)

Alias for fill

fill_rule(rule)
font(name)

Specify text drawing font

font_family(name)
font_size(points)

Alias for pointsize

font_stretch(stretch)
font_style(style)
font_weight(weight)

The font weight argument can be either a font weight constant or [100,200,…,900]

gravity(grav)

Specify the text positioning gravity, one of: NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast

interline_spacing(space)

IM 6.5.5-8 and later

interword_spacing(space)

IM 6.4.8-3 and later

kerning(space)

IM 6.4.8-3 and later

line(startX, startY, endX, endY)

Draw a line

matte(x, y, method)

Set matte (make transparent) in image according to the specified colorization rule

opacity(opacity)

Specify drawing fill and stroke opacities. If the value is a string ending with a %, the number will be multiplied by 0.01.

path(cmds)

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.

pattern(name, x, y, width, height) {|| ...}

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

point(x, y)

Set point to fill color.

pointsize(points)

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.

polygon(*points)

Draw a polygon

polyline(*points)

Draw a polyline

pop(*what)

Return to the previously-saved set of whatever pop(‘graphic-context’) (the default if no arguments) pop(‘defs’) pop(‘gradient’) pop(‘pattern’)

push(*what)

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’)

rectangle(upper_left_x, upper_left_y, lower_right_x, lower_right_y)

Draw a rectangle

rotate(angle)

Specify coordinate space rotation. "angle" is measured in degrees

roundrectangle(center_x, center_y, width, height, corner_width, corner_height)

Draw a rectangle with rounded corners

scale(x, y)

Specify scaling to be applied to coordinate space on subsequent drawing commands.

skewx(angle)
skewy(angle)
stroke(colorspec)

Specify the object stroke, a color name or pattern name.

stroke_antialias(bool)

Specify if stroke should be antialiased or not

stroke_color(colorspec)

Alias for stroke

stroke_dasharray(*list)

Specify a stroke dash pattern

stroke_dashoffset(value=0)

Specify the initial offset in the dash pattern

stroke_linecap(value)
stroke_linejoin(value)
stroke_miterlimit(value)
stroke_opacity(value)

Specify opacity of stroke drawing color

     (use "xx%" to indicate percentage)

stroke_pattern(colorspec)

Alias for stroke

stroke_width(pixels)

Specify stroke (outline) width in pixels.

text(x, y, text)

Draw text at position x,y. Add quotes to text that is not already quoted.

text_align(alignment)

Specify text alignment relative to a given point

text_anchor(anchor)

SVG-compatible version of text_align

text_antialias(boolean)

Specify if rendered text is to be antialiased.

text_undercolor(color)

Specify color underneath text

translate(x, y)

Specify center of coordinate space to use for subsequent drawing commands.

[Validate]