class Draw < Object

Table of Contents

class methods

instance methods

drawing primitive methods

annotate attributes

class methods

new

Magick::Draw.new [ { optional parameters } ] -> draw

Description

Creates a new Draw object.

Arguments

If you plan to use the annotate method with this object you can initialize the attributes in the associated block.

Returns

A new Draw object.

Example

gc = Draw.new

instance methods

annotate

draw.annotate(img, width, height, x, y, text) [ { additional parameters } ] -> draw

Description

Annotates a image with text. The text is positioned according to the gravity attribute around the rectangle described by the x, y, width, and height arguments. If either of the width or height arguments are 0, uses the image width-x and the image height-y to compute the rectangle width and height. The attributes described in annotate attributes, below, influence the appearance and position of the text. These attributes may be set in the Draw object before calling annotate, or within annotate's optional additional parameters block.

Note: all of the annotate attributes are set-only.

Arguments

img
the image or imagelist to be annotated
width
width of the rectangle within which the text is positioned
height
height of the rectangle within which the text is positioned
x
x offset of the rectangle
y
y offset of the rectangle
text
the text

Returns

self

Example

This example is an excerpt of colors.rb. Many other examples also use annotate.

title.annotate(montage, 0,0,0,40, 'Named Colors') {
    self.font_family = 'Helvetica'
    self.fill = 'white'
    self.stroke = 'transparent'
    self.pointsize = 32
    self.font_weight = BoldWeight
    self.gravity = NorthGravity
}

Special characters

Escape a blank, quote, or apostrophe by preceding it with a backslash ("\"). To include a backslash in the text, use two consecutive backslashes. To include a '%' in the text, use '%%'. You can include information about the image by including one or more of the special character sequences shown in this table.

Special characters
Replaced by
%b file size in bytes
%c "comment" property string
%d directory in which the file resides
%e filename extension
%f original filename
%g group number
%h height
%i current filename
%k number of unique colors
%l "label" property string
%m file format
%n number of images in the sequence (for RMagick, this is always 1)
%o output filename
%p page number (for RMagick, this is always 1)
%q depth
%r A string of the form "ClasstypeColorspace," for example "DirectClassRGB". If the image's matte attribute is true, appends the word "Matte" to the end of the string.
%s scene number (always 1)
%t filename without extension
%u unique temporary filename
%w width
%x x resolution
%y y resolution
%z depth

See also

This method is also defined in the Image class.

Magick API

AnnotateImage

clone

draw.clone -> aDraw

Description

Same as dup except the frozen state of the original is propogated to the copy.

Returns

A new Draw object.

draw

draw.draw(img) -> draw

Description

Draws the list of graphic primitives on the specified image. Calling draw does not affect the list of primitives. Each time you call draw the primitives will be re-executed from the beginning.

Arguments

Either an imagelist or a image. If an imagelist, draws on the current image.

Returns

self

Example

See the other examples on this page.

Magick API

DrawImage

dup

draw.dup -> aDraw

Description

Duplicate a Draw object.

Returns

An exact copy of the receiver, including the list of drawing primitives.

See also

clone

get_multiline_type_metrics

draw.get_multiline_type_metrics([anImage,] aString) -> aTypeMetric

get_type_metrics

draw.get_type_metrics([anImage,] aString) -> aTypeMetric

Description

Returns information for a specific string if rendered on a image. The get_multiline_type_metrics method is the same as get_type_metrics, except the former returns the maximum height and width for multiple lines of text. (Text lines are separated by "\n" characters.)

The Magick++ documentation for its TypeMetric class provides this useful additional information. (I've changed it a bit to use RMagick names.)

The TypeMetric class provides the means to pass data from the Draw class's get_type_metric method to the user. It provides information regarding font metrics such as ascent, descent, text width, text height, and maximum horizontal advance. The units of these font metrics are in pixels...(T)he metrics are dependent on the current Image font (default Ghostscript's "Helvetica"), pointsize (default 12 points), and x/y resolution (default 72 DPI) settings.

The pixel units may be converted to points (the standard resolution-independent measure used by the typesetting industry) via the following equation:

size_points = (size_pixels * 72)/resolution

where resolution is in dots-per-inch (DPI). This means that at the default image resolution, there is one pixel per point.

Note that a font's pointsize is only a first-order approximation of the font height (ascender + descender) in points. The relationship between the specified pointsize and the rendered font height is determined by the font designer.

See FreeType Glyph Conventions for a detailed description of font metrics related issues.

Arguments

image (optional)
The image on which the string will be rendered. ×Magick uses the attributes of the image (font name, pointsize, etc.) to compute the metrics. If this argument is omitted, get_type_metrics substitutes a dummy image with default attributes. The string argument may not contain any of the special characters shown in this table.
string
The string to be rendered. If image is specified, the string may contain special characters that refer to the image attributes. See this table.

Returns

A Magick::TypeMetric struct. This structure has the following attributes. (The descriptions are taken from the Magick++ documentation and source code.)

Magick::TypeMetric attributes
Accessor Description
ascent Distance in pixels from the text baseline to the highest/upper grid coordinate used to place an outline point. Always a positive value.
descent Distance in pixels from the baseline to the lowest grid coordinate used to place an outline point. Always a negative value.
width Text width in pixels
height Text height in pixels
max_advance Maximum horizontal advance (advance from the beginning of a character to the beginning of the next character) in pixels.

Example

This example shows the details of a TypeMetric struct. get_type_metrics example

This example uses the width and height values returned by get_multiline_type_metrics to draw a border around the text lines. get_multiline_type_metrics example

Magick API

GetTypeMetrics, GetMultilineTypeMetrics (available in ImageMagick 6.1.5)

inspect

draw.inspect -> draw

Description

Displays the list of primitives that have been added to the draw object. This is very handy for debugging.

Example

draw.inspect »
   "stroke red
    fill transparent
    rectangle 20,20 380,180
    line 200,20 200,180
    line 20,100 380,100
    stroke transparent
    fill black"

drawing primitive methods

affine

draw.affine(sx, rx, ry, sy, tx, ty) -> draw

Description

Transforms the coordinate system by a 3x3 transformation matrix. See Coordinate system transformations in the Scalable Vector Graphics (SVG) 1.1 Specification.

Arguments

sx, sy
The amount of scaling in the x and y directions
rx, ry
The rotation in the x and y directions, in radians
tx, ty
The translation distances in the x and y directions, in pixels

Returns

self

Example

This example changes the default coordinate system to the standard Cartesian coordinate system: the x-axis points rightward and the y-axis points up.

gc.affine(1, 0, 0, -1, 0, max_y)

affine example

See also

rotate, scale, translate

arc

draw.arc(start_x, start_y, end_x, end_y, start_degrees, end_degrees) -> draw

Description

Draws an arc within a rectangle.

Arguments

start_x, start_y
one corner of the bounding rectangle
end_x, end_y
the opposite corner of the bounding rectangle
start_degrees
where to start drawing the arc
end_degrees
where the arc ends

Returns

self

Example

gc.arc(40, 50, 250, 180, 0, 270)

arc example

See also

ellipse, the SVG elliptical arc commands (A and a)

Note

The arc method is broken in all releases of ImageMagick prior to 6.0.0, and all releases of GraphicsMagick prior to 1.1. If you see a diagonal line here instead of an arc, it's broken. Either upgrade to the newest version or use one of the other methods listed above.

bezier

draw.bezier(x1, y1, cx1, cy1, cx2, cy2, x2, y2...) -> draw

Description

Draw a cubic Bezier curve.

Arguments

The arguments are pairs of points. At least 4 pairs must be specified. Each point xn, yn on the curve is associated with a control point cxn, cyn. The first point, x1, y1, is the starting point. The last point, xn, yn, is the ending point. Other point/control point pairs specify intermediate points on a polybezier curve.

Returns

self

Examples

The following examples are taken from the Paths section of the Scalable Vector Graphics (SVG) 1.1 Specification.

Example 1

gc.bezier(20,120, 20,20, 320,20, 320,120)

bezier example 1

Example 2

gc.bezier(25,125, 100,25, 400,25, 325,125)

bezier example 2

Example 3

gc.bezier(100,150, 25,50, 475,50, 400,150)

bezier example 3

Example 4

gc.bezier(20,180, 20,30, 320,330, 320,180)

bezier example 4

Example 5

gc.bezier(20,120, 95,20, 245,20, 320,120)

bezier example 5

Example 6

gc.bezier(50,150, 50,50, 200,50, 200,150, 200,250, 350,250, 350,150)

bezier example 6

circle

draw.circle(origin_x, origin_y, perim_x, perim_y) -> draw

self

Description

Draw a circle.

Arguments

origin_x, origin_y
The center of the circle.
perim_x, perim_y
A point on the perimeter of the circle.

Returns

self

Example

gc.circle(125,125, 25,125)

circle example

clip_path

draw.clip_path(pathname) -> draw

Description

Draws the clip path on the image mask. The clip path defines a clipping area, where only the contained area will be drawn upon. Areas outside of the clipping area are masked.

Before using a clip-path, you must create it using the define_clip_path method. You must precede clip_path with push and terminate the primitives that draw within the clip path with pop. For example,

gc.push
gc.clip_path('mypath')
# drawing primitives within the clip path
gc.pop
gc.draw

Also see the example below.

Arguments

The name of the clip path.

Returns

self

Example

In this example, the picture of the girl is drawn onto the canvas using a star-shaped clipping path.

clip_path example

See also

define_clip_path

clip_rule

draw.clip_rule("evenodd" or "nonzero") -> draw

Description

Specify how to determine if a point on the image is inside clipping region. See the 'fill-rule' property in the Scalable Vector Graphics (SVG) 1.1 Specification for a complete description and examples.

Arguments

Either "evenodd" or "nonzero".

Returns

self

clip_units

draw.clip_units("userSpace" or "userSpaceOnUse" or "objectSpace") -> draw

Description

Defines the coordinate space within the clipping region. See Establishing a New Clipping Path in the Scalable Vector Graphics (SVG) 1.1 Specification for a complete description and examples.

Arguments

Either "userSpace", "userSpaceOnUse", or "objectSpace".

Returns

self

color

draw.color(x, y, aPaintMethod) -> draw

Description

Set color in image according to the specified PaintMethod constant.

Arguments

A PaintMethod constant. If you use the FillToBorderMethod, assign the border color with the Draw#border_color= attribute before calling draw.

Returns

self

Example

  draw.border_color = 'black'
  draw.color(x, y, Magick::FillToBorderMethod)

See Also

matte

composite

draw.composite(x, y, width, height, composite_image, op=Magick::OverCompositeOp) -> draw

Description

Composite composite_image with the receiver image.

Arguments

x, y
The offset of composite_image relative to the receiver image.
width, height
Scale the composite_image to this size. If either value is 0, composite_image is not scaled.
composite_image
Either an imagelist or a image. If an imagelist, uses the current image.
op
A CompositeOperator constant.

Returns

self

Example 1

composite example 1

Example 2

composite example 2

See also

composite

decorate

draw.decorate(aDecorationType) -> draw

Description

Specify text decoration.

Arguments

A DecorationType constant.

Returns

self

Example

draw.decorate(Magick::LineThroughDecoration)

define_clip_path

draw.define_clip_path(aString) { block } -> draw

Description

Define a clip-path. Within block, call other drawing primitive methods (rectangle, polygon, text, etc.) to define the clip-path. The union of all the primitives (excluding the effects of rendering methods such as stroke_width, etc.) is the clip-path. After the clip-path is invoked by the clip-path method, anything drawn on the image inside the clip-path will appear. Anything drawn outside the clip-path will be hidden. (See clip_rule for a definition of how ×Magick decides what is "inside" and what is "outside" of the clip-path.)

Arguments

The name of the clip-path. This is the name that is specified in the clip_path method.

Returns

self

Example

See clip_path.

ellipse

draw.ellipse(origin_x, origin_y, width, height, arc_start, arc_end) -> draw

Description

Draw an ellipse.

Arguments

origin_x, origin_y
The center of the ellipse
width, height
The horizontal and vertical radii
arc_start
Where to start the ellipse, in degrees. 0 degrees is at 3 o'clock.
arc_end
Where to end the ellipse, in degrees

Returns

self

Example

draw.ellipse(180,125, 150,75, 0, 270)

ellipse example

See also

arc, circle, path

encoding

draw.encoding(aString) -> draw

Description

Specify the font encoding.

Arguments

See the ×Magick documentation for the -encoding option to the mogrify command

Returns

self

fill

draw.fill(aString) -> draw

Description

Specify the color or pattern with which graphical elements are filled.

Arguments

A color name or pattern name.

Returns

self

Example

  draw.fill('red')

Aliases

fill_color, fill_pattern

fill_opacity

draw.fill_opacity(aFloat or aString) -> draw

Description

Specify the fill opacity.

Arguments

A number between 0 and 1, inclusive, or a percentage represented as a string, i.e. '30%'. The argument 0.3 is the same as '30%'.

Returns

self

Example

See the example for opacity.

See also

opacity, stroke_opacity

fill_rule

draw.fill_rule("evenodd" or "nonzero") -> draw

Description

Specify how to determine if a point on the image is inside a shape. See the 'fill-rule' property in the Scalable Vector Graphics (SVG) 1.1 Specification for a complete description and examples.

Arguments

Either "evenodd" or "nonzero".

Returns

self

font

draw.font(aString) -> draw

Description

Specify the font to draw text with.

Arguments

The font name or filename. You can tag a font to specify whether it is a Postscript, Truetype, or OPTION1 font. For example, Arial.ttf is a Truetype font, ps:helvetica is Postscript, and x:fixed is OPTION1.

The font name can be a complete filename such as "/mnt/windows/windows/fonts/Arial.ttf". The font name can also be a fully qualified X font name such as "-urw-times-medium-i-normal--0-0-0-0-p-0-iso8859-13".

Returns

self

See also

font_family

font_family

draw.font_family(aString) -> draw

Description

Specify the font family.

Arguments

A font family name such as "arial" or "helvetica".

Returns

self

Example

See the example for text.

font_stretch

draw.font_stretch(aStretchType) -> draw

Description

Specify the spacing between text characters.

Arguments

A StretchType constant.

Returns

self

font_style

draw.font_style(aStyleType) -> draw

Description

Specify the font style, i.e. italic, oblique, or normal.

Arguments

A StyleType constant.

Returns

self

font_weight

draw.font_weight(aWeightType) -> draw

Description

Specify the font weight. For example, "bold" or "normal".

Arguments

A WeightType constant, or one of the numbers 100, 200, 300, 400, 500, 600, 700, 800, or 900.

Returns

self

gravity

draw.gravity(aGravityType) -> draw

Description

Specify how the text is positioned. The default is Magick::NorthWestGravity.

Arguments

A GravityType constant.

Returns

self

Example

gravity example

See also

text_align

line

draw.line(here_x, here_y, there_x, there_y) -> draw

Description

Draw a line from here to there.

Arguments

here_x, here_y
The starting point.
there_x, there_y
The ending point.

Returns

self

Example

gc.line(50,50, 50,200)
gc.line(50,200, 200,200)
gc.line(200,200, 50,50)

line example

matte

draw.matte(x,y, aPaintMethod) -> draw

Description

Make the image transparent according to the specified PaintMethod constant.

Arguments

x, y
Point in image to use, along with the PaintMethod constant, to set transparent pixels in the image.
aPaintMethod
One of the following PaintMethod constants:
PointMethod
Make the pixel at (x,y) transparent.
ReplaceMethod
Make all pixels that are the same color as the pixel at (x,y) transparent.
FloodfillMethod
Make all the pixels surrounding the pixel at (x,y) transparent, until encountering pixels that fail to match color at (x,y).
FillToBorderMethod
Make all the pixels surrounding the pixel at (x,y) transparent, until encountering pixels that match the border color. Assign the border color with the Draw#border_color= attribute before calling draw.
ResetMethod
Make the entire image transparent.

Returns

self

See also

colormatte_point, matte_replace, matte_floodfill, matte_fill_to_border, opaque, transparent

opacity

draw.opacity(opacity) -> draw

Description

Specify the fill and stroke opacities.

Arguments

Either a number between 0 and 1, or a percentage represented as a string, i.e. "25%". The string argument "25%" is the same as the numeric argument 0.25. Both the fill and stroke opacities are set to the specified value.

Returns

self

Example

This example demonstrates 4 levels of opacity.

opacity example

See also

fill_opacity, stroke_opacity

path

draw.path(aString) -> draw

Description

Draw using SVG-compatible path drawing commands. See "Paths" in the Scalable Vector Graphics (SVG) 1.1 Specification.

Arguments

A string containing SVG moveto, line, curve, arc, or closepath instructions. The string is equivalent to the d attribute in an SVG 'path' element.

Returns

self

Example

These examples are all taken from the SVG path examples.

Example 1 - Arcs

gc.path('M110,100 h-75 a75,75 0 1,0 75,-75 z')
gc.path('M97.5,87.5 v-75 a75,75 0 0,0 -75,75 z')

path example 1

Example 2 - Quadratic bezier

gc.path("M20,150 Q120,25 220,150 T420,150")

path example 2

Example 3 - Cubic bezier

gc.path("M20,120 C20,20 170,20 170,120 S320,220 320,120")

path example 3

pattern

draw.pattern(name, x, y, width, height) { pattern primitives } -> draw

Description

Define a pattern that can be used as the fill or stroke pattern.

Arguments

name
The name of the pattern. The pattern is used in a fill or stroke method by specifying its name.
x, y, width, height
Define how the pattern is tiled. The pattern rectangles start at (x + m*width, y+n*height) for the values of n and m as necessary to fill the space.
pattern primitives
The method calls that draw the pattern.

Returns

self

Example 1

pattern example 1

Example 2

pattern example 2

See also

fill, stroke

point

draw.point(x, y) -> draw

Description

Set the pixel at x,y to the fill color.

Arguments

x, y
The pixel location

Returns

self

pointsize

draw.pointsize(anInteger) -> draw

Description

Set the font size in points. The default is 12.

Arguments

See the example for text.

Returns

self

Alias

font_size

polygon

draw.polygon(x1, y1,...,xN, yN) -> draw

Description

Draw a polygon.

Arguments

The arguments are a sequence of 2 or more points. If the last point is not the same as the first, the polygon is closed by drawing a line from the last point to the first.

Returns

self

Example

This example is taken from the The 'polygon' element in the Scalable Vector Graphics (SVG) 1.1 Specification

polygon example

See also

path

polyline

draw.polyline(x1, y1,...,xN, yN) -> draw

Description

Draw a polyline. Unlike a polygon, a polyline is not automatically closed.

Arguments

A sequence of 2 or more points.

Returns

self

Example

This example is taken from the The 'polyline' element in the Scalable Vector Graphics (SVG) 1.1 Specification

polyline example

pop

draw.pop -> draw

Description

Restore the graphics context to the state it was in when push was called last.

Returns

self

See also

push

push

draw.push -> draw

Description

Save the current state of the graphics context, including the attribute settings and the current set of primitives. Use the pop primitive to restore the state.

Note: The push and pop methods are probably not as useful in RMagick as they are in C language ×Magick programs, since it is easy to create separate draw objects, each with its own set of properties and primitives.

Returns

self

See also

pop

rectangle

draw.rectangle(x1, y1, x2, y2) -> draw

Description

Draw a rectangle.

Arguments

x1, y1
The upper left hand corner of the rectangle
x2, y2
The lower right hand corner of the rectangle

Returns

self

Example

gc.rectangle(20,20, 280,180)

rectangle example

rotate

draw.rotate(degrees) -> draw

Description

Specify a rotation transformation to the coordinate space. The default is 0.

Arguments

The amount of rotation, in degrees. The angle of rotation is clockwise, so 90° is South.

Returns

self

Example

gc.rotate(45)

rotate example

See also

affine

roundrectangle

draw.roundrectangle(x1, y1, x2, y2, cw, ch) -> draw

Description

Draw a rectangle with rounded corners.

Arguments

x1, y1
The upper left hand corner of the rectangle
x2, y2
The lower right hand corner of the rectangle
cw, ch
The corner width and height

Returns

self

Example

gc.roundrectangle(20,20, 280,180, 8, 8)

roundrectangle example

scale

draw.scale(sx, sy) -> draw

Description

Define a scale transformation to the coordinate space. The default scale is (1.0, 1.0).

Arguments

sx, sy
The amount of scaling in the x and y dimensions.

Returns

self

See also

affine

skewx

draw.skewx(aFloat) -> draw

Description

Define a skew tranformation along the x-axis.

Arguments

The amount of skew, in degrees.

Returns

self

Example

gc.skewx(30)

skewx example

See also

skewy, affine, rotate

skewy

draw.skewy(aFloat) -> draw

Description

Define a skew tranformation along the y-axis.

Arguments

The amount of skew, in degrees.

Returns

self

Example

gc.skewy(30)

skewy example

See also

affine, skewx, rotate

stroke

draw.stroke(aString) -> draw

Description

Specify the stroke color or pattern.

Arguments

A color name or pattern name.

Returns

self

Aliases

stroke_color, stroke_pattern

stroke_antialias

draw.stroke_antialias(true or false) -> draw

Description

Specify if the stroke should be antialiased. The default is true.

stroke_dasharray

draw.stroke_dasharray(x1,...,xn) -> draw

Description

Describe a pattern of dashes to be used when stroking paths. The arguments are a list of pixel widths of alternating dashes and gaps.

Arguments

The first argument is the width of the first dash. The second is the width of the gap following the first dash. The third argument is another dash width, followed by another gap width, etc. If you specify an odd number of arguments, the arguments are repeated to produce an even number. All arguments must be > 0.

To produce a solid stroke, specify no arguments, i.e. stroke_dasharray()

Returns

self

Example

stroke_dasharray example

See also

stroke_dashoffset

stroke_dashoffset

draw.stroke_dashoffset(anInteger) -> draw

Description

Specify the initial distance into the dash pattern.

Arguments

The initial distance into the dash pattern. The units are pixels.

Returns

self

Example

See stroke_dasharray.

stroke_linecap

draw.stroke_linecap(aString) -> draw

Description

Specify how the line ends should be drawn.

Arguments

One of "butt", "round", or "square".

Returns

self

Example

The following example is from the Stroke Properties section of the Scalable Vector Graphics (SVG) 1.1 Specification.

stroke_linecap example

stroke_linejoin

draw.stroke_linejoin(aString) -> draw

Description

Specify how corners are drawn.

Arguments

One of "miter", "round", or "bevel".

Returns

self

Example

The following example is from the Stroke Properties section of the Scalable Vector Graphics (SVG) 1.0 Specification.

stroke_linejoin example

See also

stroke_miterlimit

stroke_miterlimit

draw.stroke_miterlimit(aFloat) -> draw

Description

Specify a constraint on the length of the "miter" formed by two lines meeting at an angle. If the angle if very sharp, the miter could be very long relative to the line thickness. The miter limit is a limit on the ratio of the miter length to the line width.

Arguments

A number >= 1. The limit on the ratio of the miter length to the line width.

Returns

self

stroke_opacity

draw.stroke_opacity(aFloat or aString) -> draw

Description

Specify the stroke opacity.

Arguments

A number between 0 and 1, inclusive, or a percentage represented as a string, i.e. '30%'. The argument 0.3 is the same as '30%'.

Returns

self

Example

draw.stroke_opacity(0.4)
draw.stroke_opacity('40%')

See also

fill_opacity, opacity

stroke_width

draw.stroke_width(anInteger) -> draw

Description

Specify the stroke width in pixels. The default is 1.

Returns

self

Example

stroke_width example

text

draw.text(x,y, text) -> draw

Description

Draw text at the location specified by (x,y). Use gravity to position text relative to (x, y). Specify the font appearance with the font, font_family, font_stretch, font_style, and font_weight methods. Specify the text attributes with the text_align, text_anchor, text_antialias, and text_undercolor methods.

Generally it is a good idea to surround the text string with quotes (""), apostrophes (''), or braces ({}). If the text string starts with a digit or contains an embedded blank, quote, or apostrophe, you must do this. ×Magick removes these characters before drawing the text. You can also escape a blank, quote, or apostrophe by preceding it with a backslash ("\"). To include a backslash in the text, use two consecutive backslashes. To include a '%' in the text, use '%%'. See the examples below.

Arguments

x, y
The text position, influenced by gravity.
text
The text.

Returns

self

Quoting examples

The text to the right of » is the text that will be drawn.

gc.text(10,10, '"Hello there!"') » Hello there!
gc.text(10,10, "'What\'s up?'") » What's up?
gc.text(10,10, %q/"What's up?"/) » What's up?
gc.text(10,10, %q/{"What's up?"}/) » "What's up?"

Example

text example

See also

annotate

text_align

draw.text_align(anAlignType) -> draw

Description

Align text relative to the starting point.

Arguments

An AlignType constant.

Returns

self

Example

text_align example

text_anchor

draw.text_anchor(anAnchorType) -> draw

Description

Align text relative to the starting point. This is the SVG 1.1 equivalent to text_align.

Arguments

One of the constants StartAnchor, MiddleAnchor, or EndAnchor.

Returns

self

text_antialias

draw.text_antialias(true or false) -> draw

Description

Specify if the text is to be antialiased.

Arguments

Either true or false. The default is true.

Returns

self

Example

The character on the left is not antialiased. The character on the right is antialiased.

text_antialias example

See also

stroke_antialias

text_undercolor

draw.undercolor(aString) -> draw

Description

The color to draw underneath text. The default is transparent.

Arguments

A color name.

Returns

self

Example

text_undercolor example

translate

draw.translate(tx, ty) -> draw

Description

Specify a translation operation on the coordinate space.

Arguments

tx, ty
The amount of translation in the x and y directions.

Returns

self

Example

gc.translate(125, 125)

translate example

See also

affine

annotate attributes

affine=

draw..affine = anAffineMatrix

Description

The transformation matrix. The default is the null transformation.

Argument

An AffineMatrix.

Returns

self

align=

draw..align = anAlignType

Description

The text alignment. The default is LeftAlign.

Argument

A AlignType constant.

Returns

self

decorate=

draw.decorate = aDecorationType

Description

The text decoration. The default is NoDecorationType.

Argument

A DecorationType constant.

Returns

self

density=

draw.density = aString

Description

The text density in the x and y directions. The default is "72x72".

Returns

self

encoding=

draw.encoding = aString

Description

The text encoding.

Argument

See the ×Magick documentation for the -encoding option to the mogrify command.

Returns

self

fill=

draw.fill = aString or aPixel

Description

The fill color. The default is "black".

Argument

May be a color name or a Pixel object.

Returns

self

font=

draw.font = aString

Description

The font name. The default is "Helvetica". See font for more information about font names.

Returns

self

font_family=

draw.font_family = aString

Description

The font family name. For example, "arial" or "helvetica".

Returns

self

font_stretch=

draw.font_stretch = aStretchType

Description

The font stretch.

Argument

A StretchType constant.

Returns

self

font_style=

draw.font_style = aStyleType

Description

The font style.

Argument

A StyleType constant.

Returns

self

font_weight=

draw.font_weight = aWeightType

Description

The font weight.

Arguments

A WeightType constant or one of the numbers 100, 200, 300, 400, 500, 600, 700, 800, or 900.

Returns

self

gravity=

draw.gravity = aGravityType

Description

Specifies how to orient text with respect to the text's origin.

Arguments

A GravityType constant.

Returns

self

pointsize=

draw.pointsize = anNumeric

Description

The font size in points. The default is 12.

Returns

self

Example

rotation=

draw.rotation = aNumeric

Description

Apply rotation to text. The default is no rotation.

Arguments

The amount of rotation in degrees.

Returns

self

stroke=

draw.stroke = aString or aPixel

Description

The stroke color. This is the color used to outline the text. The default is "black".

Arguments

A color name or Pixel object.

Returns

self

stroke_width=

draw.stroke = anInteger

Description

The stroke width in pixels. The default is 1.

Returns

self

text_antialias=

draw.text_antialias = true or false

Description

Whether the text is antialiased or not. The default is true.

Returns

self

tile=

draw.tile = anImage

Description

Tile image when filling a graphic primitive.

Arguments

An image

Returns

self

undercolor=

draw.undercolor = aString or aPixel

Description

If set, causes the text to be drawn over a box of the specified color.

Arguments

A color name or a Pixel object.

Returns

self