# `wand.drawing` — Drawings

The module provides some vector drawing functions.

Added in version 0.3.0.

wand.drawing.CLIP_PATH_UNITS = ('undefined_path_units', 'user_space', 'user_space_on_use', 'object_bounding_box')

  (`collections.abc.Sequence`) The list of clip path units

  - `'undefined_path_units'`

  - `'user_space'`

  - `'user_space_on_use'`

  - `'object_bounding_box'`

class wand.drawing.Drawing(drawing=None)

  Drawing object. It maintains several vector drawing instructions and can get drawn into zero or more `Image` objects by calling it.

  For example, the following code draws a diagonal line to the `image`:

      with Drawing() as draw:
          draw.line((0, 0), image.size)
          draw(image)

  Parameters:

    drawing (`Drawing`) – an optional drawing object to clone. use `clone()` method rather than this parameter

  Added in version 0.3.0.

  affine(matrix)

    Adjusts the current affine transformation matrix with the specified affine transformation matrix. Note that the current affine transform is adjusted rather than replaced.

                                          | sx  rx  0 |
        | x', y', 1 |  =  | x, y, 1 |  *  | ry  sy  0 |
                                          | tx  ty  1 |

    Parameters:

      matrix (`collections.abc.Sequence`) – a list of `Real` to define affine matrix `[sx, rx, ry, sy, tx, ty]`

    Added in version 0.4.0.

  alpha(x=None, y=None, paint_method='undefined')

    Paints on the image’s opacity channel in order to set effected pixels to transparent.

    > To influence the opacity of pixels. The available methods are:

    - `'undefined'`

    - `'point'`

    - `'replace'`

    - `'floodfill'`

    - `'filltoborder'`

    - `'reset'`

    Note

    This method replaces `matte()` in ImageMagick version 7. An `AttributeError` will be raised if attempting to call on a library without `DrawAlpha` support.

    Added in version 0.5.0.

  arc(start, end, degree)

    Draws a arc using the current `stroke_color`, `stroke_width`, and `fill_color`.

    Parameters:

      - start (`Sequence`) – (`Real`, `numbers.Real`) pair which represents starting x and y of the arc

      - end (`Sequence`) – (`Real`, `numbers.Real`) pair which represents ending x and y of the arc

      - degree (`Sequence`) – (`Real`, `numbers.Real`) pair which represents starting degree, and ending degree

    Added in version 0.4.0.

  bezier(points=None)

    Draws a bezier curve through a set of points on the image, using the specified array of coordinates.

    At least four points should be given to complete a bezier path. The first & forth point being the start & end point, and the second & third point controlling the direction & curve.

    Example bezier on `image`

        with Drawing() as draw:
            points = [(40,10), # Start point
                      (20,50), # First control
                      (90,10), # Second control
                      (70,40)] # End point
            draw.stroke_color = Color('#000')
            draw.fill_color = Color('#fff')
            draw.bezier(points)
            draw.draw(image)

    Parameters:

      points (`list`) – list of x,y tuples

    Added in version 0.4.0.

  property border_color

    (`Color`) the current border color. It also can be set. This attribute controls the behavior of `color()` during `'filltoborder'` operation.

    Added in version 0.4.0.

  c_clear_exception = <_FuncPtr object>

    (`ctypes.CFUNCTYPE`) The `ctypes` function that clears an exception of the `resource`.

    Note

    It is an abstract attribute that has to be implemented in the subclass.

  c_destroy_resource = <_FuncPtr object>

    (`ctypes.CFUNCTYPE`) The `ctypes` function that destroys the `resource`.

    Note

    It is an abstract attribute that has to be implemented in the subclass.

  c_get_exception = <_FuncPtr object>

    (`ctypes.CFUNCTYPE`) The `ctypes` function that gets an exception from the `resource`.

    Note

    It is an abstract attribute that has to be implemented in the subclass.

  c_is_resource = <_FuncPtr object>

    (`ctypes.CFUNCTYPE`) The `ctypes` predicate function that returns whether the given pointer (that contains a resource data usually) is a valid resource.

    Note

    It is an abstract attribute that has to be implemented in the subclass.

  circle(origin, perimeter)

    Draws a circle from `origin` to `perimeter`

    Parameters:

      - origin (`collections.abc.Sequence`) – (`Real`, `numbers.Real`) pair which represents origin x and y of circle

      - perimeter (`collections.abc.Sequence`) – (`Real`, `numbers.Real`) pair which represents perimeter x and y of circle

    Added in version 0.4.0.

  property clip_path

    (`basestring`) The current clip path. It also can be set.

    Added in version 0.4.0.

  property clip_rule

    (`basestring`) The current clip rule. It also can be set. It’s a string value from `FILL_RULE_TYPES` list.

    Added in version 0.4.0.

  property clip_units

    (`basestring`) The current clip units. It also can be set. It’s a string value from `CLIP_PATH_UNITS` list.

    Added in version 0.4.0.

  clone()

    Copies a drawing object.

    Returns:

      a duplication

    Return type:

      `Drawing`

  color(x=0.0, y=0.0, paint_method='undefined')

    Draws a color on the image using current fill color, starting at specified position & method.

    Available methods in `wand.drawing.PAINT_METHOD_TYPES`:

    - `'undefined'`

    - `'point'`

    - `'replace'`

    - `'floodfill'`

    - `'filltoborder'`

    - `'reset'`

    Added in version 0.4.0.

  comment(message=None)

    Adds a comment to the vector stream.

    Parameters:

      message (`basestring`) – the comment to set.

    Added in version 0.4.0.

  composite(operator, left, top, width, height, image)

    Composites an image onto the current image, using the specified composition operator, specified position, and at the specified size.

    Parameters:

      - operator – the operator that affects how the composite is applied to the image. available values can be found in the `COMPOSITE_OPERATORS` list

      - type – `COMPOSITE_OPERATORS`

      - left (`numbers.Real`) – the column offset of the composited drawing source

      - top (`numbers.Real`) – the row offset of the composited drawing source

      - width (`numbers.Real`) – the total columns to include in the composited source

      - height (`numbers.Real`) – the total rows to include in the composited source

    Added in version 0.4.0.

  draw(image)

    Renders the current drawing into the `image`. You can simply call `Drawing` instance rather than calling this method. That means the following code which calls `Drawing` object itself:

        drawing(image)

    is equivalent to the following code which calls `draw()` method:

        drawing.draw(image)

    Parameters:

      image (`BaseImage`) – the image to be drawn

  ellipse(origin, radius, rotation=None)

    Draws a ellipse at `origin` with independent x & y `radius`. Ellipse can be partial by setting start & end `rotation`.

    Parameters:

      - origin (`collections.abc.Sequence`) – (`Real`, `numbers.Real`) pair which represents origin x and y of circle

      - radius (`collections.abc.Sequence`) – (`Real`, `numbers.Real`) pair which represents radius x and radius y of circle

      - rotation (`collections.abc.Sequence`) – (`Real`, `numbers.Real`) pair which represents start and end of ellipse. Default (0,360)

    Added in version 0.4.0.

  property fill_color

    (`Color`) The current color to fill. It also can be set.

  property fill_opacity

    (`Real`) The current fill opacity. It also can be set.

    Added in version 0.4.0.

  property fill_rule

    (`basestring`) The current fill rule. It can also be set. It’s a string value from `FILL_RULE_TYPES` list.

    Added in version 0.4.0.

  property font

    (`basestring`) The current font name. It also can be set.

  property font_family

    (`basestring`) The current font family. It also can be set.

    Added in version 0.4.0.

  property font_resolution

    (`Sequence`) The current font resolution. It also can be set.

    Added in version 0.4.0.

  property font_size

    (`numbers.Real`) The font size. It also can be set.

  property font_stretch

    (`basestring`) The current font stretch variation. It also can be set, but will only apply if the font-family or encoder supports the stretch type.

    Added in version 0.4.0.

  property font_style

    (`basestring`) The current font style. It also can be set, but will only apply if the font-family supports the style.

    Added in version 0.4.0.

  property font_weight

    (`Integral`) The current font weight. It also can be set.

    Added in version 0.4.0.

  get_font_metrics(image, text, multiline=False)

    Queries font metrics by cloning the `image`, and rendering the `text` with the font properties defined on `Drawing`.

    This is useful for determining the size of the rendered text. Set `multiline` to `True` if the given `text` contains line-breaks.

    The return value is an instance of `FontMetrics` which has the attributes of the text’s rendered size, max horizontal advance, and distance of ascent & descent from the baseline.

    Parameters:

      - image (`BaseImage`) – the image to be drawn

      - text (`basestring`) – the text string for get font metrics.

      - multiline (boolean) – text is multiline or not

    Returns:

      `FontMetrics`

    Added in version 0.3.0.

  property gravity

    (`basestring`) The text placement gravity used when annotating with text. It’s a string from `GRAVITY_TYPES` list. It also can be set.

  line(start, end)

    Draws a line `start` to `end`.

    Parameters:

      - start (`collections.abc.Sequence`) – (`Integral`, `numbers.Integral`) pair which represents starting x and y of the line

      - end (`collections.abc.Sequence`) – (`Integral`, `numbers.Integral`) pair which represents ending x and y of the line

  matte(x=0.0, y=0.0, paint_method='undefined')

    Paints on the image’s opacity channel in order to set effected pixels to transparent.

    > To influence the opacity of pixels. The available methods are:

    - `'undefined'`

    - `'point'`

    - `'replace'`

    - `'floodfill'`

    - `'filltoborder'`

    - `'reset'`

    Note

    This method has been replace by `alpha()` in ImageMagick version 7. An `AttributeError` will be raised if attempting to call on a library without `DrawMatte` support.

    Added in version 0.4.0.

  property opacity

    (`Real`) returns the opacity used when drawing with the fill or stroke color or texture. Fully opaque is 1.0. This method only affects vector graphics, and is experimental. To set the opacity of a drawing, use `Drawing.fill_opacity` & `Drawing.stroke_opacity`

    Added in version 0.4.0.

  path_close()

    Adds a path element to the current path which closes the current subpath by drawing a straight line from the current point to the current subpath’s most recent starting point.

    Added in version 0.4.0.

  path_curve(to=None, controls=None, smooth=False, relative=False)

    Draws a cubic Bezier curve from the current point to given `to` (x,y) coordinate using `controls` points at the beginning and the end of the curve. If `smooth` is set to True, only one `controls` is expected and the previous control is used, else two pair of coordinates are expected to define the control points. The `to` coordinate then becomes the new current point.

    Parameters:

      - to (`collections.abc.Sequence`) – (`Real`, `numbers.Real`) pair which represents coordinates to draw to

      - controls (`collections.abc.Sequence`) – (`Real`, `numbers.Real`) coordinate to used to influence curve

      - smooth (`bool`) – `bool` assume last defined control coordinate

      - relative (`bool`) – treat given coordinates as relative to current point

    Added in version 0.4.0.

  path_curve_to_quadratic_bezier(to=None, control=None, smooth=False, relative=False)

    Draws a quadratic Bezier curve from the current point to given `to` coordinate. The control point is assumed to be the reflection of the control point on the previous command if `smooth` is True, else a pair of `control` coordinates must be given. Each coordinates can be relative, or absolute, to the current point by setting the `relative` flag. The `to` coordinate then becomes the new current point, and the `control` coordinate will be assumed when called again when `smooth` is set to true.

    Parameters:

      - to (`collections.abc.Sequence`) – (`Real`, `numbers.Real`) pair which represents coordinates to draw to

      - control (`collections.abc.Sequence`) – (`Real`, `numbers.Real`) coordinate to used to influence curve

      - smooth (`bool`) – assume last defined control coordinate

      - relative (`bool`) – treat given coordinates as relative to current point

    Added in version 0.4.0.

  path_elliptic_arc(to=None, radius=None, rotation=0.0, large_arc=False, clockwise=False, relative=False)

    Draws an elliptical arc from the current point to given `to` coordinates. The `to` coordinates can be relative, or absolute, to the current point by setting the `relative` flag. The size and orientation of the ellipse are defined by two radii (rx, ry) in `radius` and an `rotation` parameters, which indicates how the ellipse as a whole is rotated relative to the current coordinate system. The center of the ellipse is calculated automagically to satisfy the constraints imposed by the other parameters. `large_arc` and `clockwise` contribute to the automatic calculations and help determine how the arc is drawn. If `large_arc` is True then draw the larger of the available arcs. If `clockwise` is true, then draw the arc matching a clock-wise rotation.

    Parameters:

      - to (`collections.abc.Sequence`) – (`Real`, `numbers.Real`) pair which represents coordinates to draw to

      - radius (`collections.abc.Sequence`) – (`Real`, `numbers.Real`) pair which represents the radii of the ellipse to draw

      - rotate (`Real`) – degree to rotate ellipse on x-axis

      - large_arc (`bool`) – draw largest available arc

      - clockwise (`bool`) – draw arc path clockwise from start to target

      - relative (`bool`) – treat given coordinates as relative to current point

    Added in version 0.4.0.

  path_finish()

    Terminates the current path.

    Added in version 0.4.0.

  path_horizontal_line(x=None, relative=False)

    Draws a horizontal line path from the current point to the target point. Given `x` parameter can be relative, or absolute, to the current point by setting the `relative` flag. The target point then becomes the new current point.

    Parameters:

      - x (`Real`) – `Real` x-axis point to draw to.

      - relative (`bool`) – `bool` treat given point as relative to current point

    Added in version 0.4.0.

  path_line(to=None, relative=False)

    Draws a line path from the current point to the given `to` coordinate. The `to` coordinates can be relative, or absolute, to the current point by setting the `relative` flag. The coordinate then becomes the new current point.

    Parameters:

      - to (`collections.abc.Sequence`) – (`Real`, `numbers.Real`) pair which represents coordinates to draw to.

      - relative (`bool`) – `bool` treat given coordinates as relative to current point

    Added in version 0.4.0.

  path_move(to=None, relative=False)

    Starts a new sub-path at the given coordinates. Given `to` parameter can be relative, or absolute, by setting the `relative` flag.

    Parameters:

      - to (`collections.abc.Sequence`) – (`Real`, `numbers.Real`) pair which represents coordinates to draw to.

      - relative (`bool`) – `bool` treat given coordinates as relative to current point

    Added in version 0.4.0.

  path_start()

    Declares the start of a path drawing list which is terminated by a matching `path_finish()` command. All other path_* commands must be enclosed between a `path_start()` and a `path_finish()` command. This is because path drawing commands are subordinate commands and they do not function by themselves.

    Added in version 0.4.0.

  path_vertical_line(y=None, relative=False)

    Draws a vertical line path from the current point to the target point. Given `y` parameter can be relative, or absolute, to the current point by setting the `relative` flag. The target point then becomes the new current point.

    Parameters:

      - y (`Real`) – `Real` y-axis point to draw to.

      - relative (`bool`) – `bool` treat given point as relative to current point

    Added in version 0.4.0.

  point(x, y)

    Draws a point at given `x` and `y`

    Parameters:

      - x (`Real`) – `Real` x of point

      - y (`Real`) – `Real` y of point

    Added in version 0.4.0.

  polygon(points=None)

    Draws a polygon using the current `stroke_color`, `stroke_width`, and `fill_color`, using the specified array of coordinates.

    Example polygon on `image`

        with Drawing() as draw:
            points = [(40,10), (20,50), (90,10), (70,40)]
            draw.polygon(points)
            draw.draw(image)

    Parameters:

      points (`list`) – list of x,y tuples

    Added in version 0.4.0.

  polyline(points=None)

    Draws a polyline using the current `stroke_color`, `stroke_width`, and `fill_color`, using the specified array of coordinates.

    Identical to `polygon`, but without closed stroke line.

    Parameters:

      points (`list`) – list of x,y tuples

    Added in version 0.4.0.

  pop()

    Pop destroys the current tip of the drawing context stack, and restores the parent style context. See `push()` method for an example.

    Note

    Popping the graphical context stack will not erase, or alter, any previously executed drawing commands.

    Returns:

      success of pop operation.

    Return type:

      `bool`

    Added in version 0.4.0.

  pop_clip_path()

    Terminates a clip path definition.

    Added in version 0.4.0.

  pop_defs()

    Terminates a definition list.

    Added in version 0.4.0.

  pop_pattern()

    Terminates a pattern definition.

    Added in version 0.4.0.

  push()

    Grows the current drawing context stack by one, and inherits the previous style attributes. Use `Drawing.pop` to return to restore previous style attributes.

    This is useful for drawing shapes with different styles without repeatedly setting the similar `fill_color` & `stroke_color` properties.

    For example:

        with Drawing() as ctx:
            ctx.fill_color = Color('GREEN')
            ctx.stroke_color = Color('ORANGE')
            ctx.push()
            ctx.fill_color = Color('RED')
            ctx.text(x1, y1, 'this is RED with ORANGE outline')
            ctx.push()
            ctx.stroke_color = Color('BLACK')
            ctx.text(x2, y2, 'this is RED with BLACK outline')
            ctx.pop()
            ctx.pop()
            ctx.text(x3, y3, 'this is GREEN with ORANGE outline')

    Which translate to the following MVG:

        push graphic-context
            fill "GREEN"
            stroke "ORANGE"
            push graphic-context
                fill "RED"
                text x1,y1 "this is RED with ORANGE outline"
                push graphic-context
                    stroke "BLACK"
                    text x2,y2 "this is RED with BLACK outline"
                pop graphic-context
            pop graphic-context
            text x3,y3 "this is GREEN with ORANGE outline"
        pop graphic-context

    Note

    Pushing graphical context does not reset any previously drawn artifacts.

    Returns:

      success of push operation.

    Return type:

      `bool`

    Added in version 0.4.0.

  push_clip_path(clip_mask_id)

    Starts a clip path definition which is comprised of any number of drawing commands and terminated by a `Drawing.pop_clip_path` command.

    Parameters:

      clip_mask_id (`basestring`) – string identifier to associate with the clip path.

    Added in version 0.4.0.

  push_defs()

    Indicates that commands up to a terminating `Drawing.pop_defs` command create named elements (e.g. clip-paths, textures, etc.) which may safely be processed earlier for the sake of efficiency.

    Added in version 0.4.0.

  push_pattern(pattern_id, left, top, width, height)

    Indicates that subsequent commands up to a `Drawing.pop_pattern` command comprise the definition of a named pattern. The pattern space is assigned top left corner coordinates, a width and height, and becomes its own drawing space. Anything which can be drawn may be used in a pattern definition. Named patterns may be used as stroke or brush definitions.

    Parameters:

      - pattern_id (`basestring`) – a unique identifier for the pattern.

      - left (`numbers.Real`) – x ordinate of top left corner.

      - top (`numbers.Real`) – y ordinate of top left corner.

      - width (`numbers.Real`) – width of pattern space.

      - height (`numbers.Real`) – height of pattern space.

    Returns:

      success of push operation

    Return type:

      `bool`

    Added in version 0.4.0.

  rectangle(left=None, top=None, right=None, bottom=None, width=None, height=None, radius=None, xradius=None, yradius=None)

    Draws a rectangle using the current `stroke_color`, `stroke_width`, and `fill_color`.

        +--------------------------------------------------+
        |              ^                         ^         |
        |              |                         |         |
        |             top                        |         |
        |              |                         |         |
        |              v                         |         |
        | <-- left --> +-------------------+  bottom       |
        |              |             ^     |     |         |
        |              | <-- width --|---> |     |         |
        |              |           height  |     |         |
        |              |             |     |     |         |
        |              |             v     |     |         |
        |              +-------------------+     v         |
        | <--------------- right ---------->               |
        +--------------------------------------------------+

    Parameters:

      - left (`numbers.Real`) – x-offset of the rectangle to draw

      - top (`numbers.Real`) – y-offset of the rectangle to draw

      - right (`numbers.Real`) – second x-offset of the rectangle to draw. this parameter and `width` parameter are exclusive each other

      - bottom (`numbers.Real`) – second y-offset of the rectangle to draw. this parameter and `height` parameter are exclusive each other

      - width (`numbers.Real`) – the `width` of the rectangle to draw. this parameter and `right` parameter are exclusive each other

      - height (`numbers.Real`) – the `height` of the rectangle to draw. this parameter and `bottom` parameter are exclusive each other

      - radius (`numbers.Real`) – the corner rounding. this is a short-cut for setting both `xradius`, and `yradius`

      - xradius (`numbers.Real`) – the `xradius` corner in horizontal direction.

      - yradius (`numbers.Real`) – the `yradius` corner in vertical direction.

    Added in version 0.3.6.

    Changed in version 0.4.0: Radius keywords added to create rounded rectangle.

  rotate(degree=0.0)

    Applies the specified rotation to the current coordinate space.

    Parameters:

      degree (`Real`) – degree to rotate

    Added in version 0.4.0.

  scale(x=1.0, y=1.0)

    Adjusts the scaling factor to apply in the horizontal and vertical directions to the current coordinate space.

    Parameters:

      - x (`Real`) – Horizontal scale factor. Default 1.0

      - y (`Real`) – Vertical scale factor. Default 1.0

    Added in version 0.4.0.

  set_fill_pattern_url(url)

    Sets the URL to use as a fill pattern for filling objects. Only local URLs (“#identifier”) are supported at this time. These local URLs are normally created by defining a named fill pattern with Drawing.push_pattern & Drawing.pop_pattern.

    Parameters:

      url (`basestring`) – URL to use to obtain fill pattern.

    Added in version 0.4.0.

  set_stroke_pattern_url(url)

    Sets the pattern used for stroking object outlines. Only local URLs (“#identifier”) are supported at this time. These local URLs are normally created by defining a named stroke pattern with Drawing.push_pattern & Drawing.pop_pattern.

    Parameters:

      url (`basestring`) – URL to use to obtain stroke pattern.

    Added in version 0.4.0.

  skew(x=None, y=None)

    Skews the current coordinate system in the horizontal direction if `x` is given, and vertical direction if `y` is given.

    Parameters:

      - x (`Real`) – Skew horizontal direction

      - y (`Real`) – Skew vertical direction

    Added in version 0.4.0.

  property stroke_antialias

    (`bool`) Controls whether stroked outlines are antialiased. Stroked outlines are antialiased by default. When antialiasing is disabled stroked pixels are thresholded to determine if the stroke color or underlying canvas color should be used.

    It also can be set.

    Added in version 0.4.0.

  property stroke_color

    (`Color`) The current color of stroke. It also can be set.

    Added in version 0.3.3.

  property stroke_dash_array

    (`Sequence`) - (`numbers.Real`) An array representing the pattern of dashes & gaps used to stroke paths. It also can be set.

    Added in version 0.4.0.

  property stroke_dash_offset

    (`numbers.Real`) The stroke dash offset. It also can be set.

    Added in version 0.4.0.

  property stroke_line_cap

    (`basestring`) The stroke line cap. It also can be set.

    Added in version 0.4.0.

  property stroke_line_join

    (`basestring`) The stroke line join. It also can be set.

    Added in version 0.4.0.

  property stroke_miter_limit

    (`Integral`) The current miter limit. It also can be set.

    Added in version 0.4.0.

  property stroke_opacity

    (`Real`) The current stroke opacity. It also can be set.

    Added in version 0.4.0.

  property stroke_width

    (`numbers.Real`) The stroke width. It also can be set.

    Added in version 0.3.3.

  text(x, y, body)

    Writes a text `body` into (`x`, `y`).

    Parameters:

      - x (`numbers.Integral`) – the left offset where to start writing a text

      - y (`numbers.Integral`) – the baseline where to start writing text

      - body (`basestring`) – the body string to write

  property text_alignment

    (`basestring`) The current text alignment setting. It’s a string value from `TEXT_ALIGN_TYPES` list. It also can be set.

  property text_antialias

    (`bool`) The boolean value which represents whether antialiasing is used for text rendering. It also can be set to `True` or `False` to switch the setting.

  property text_decoration

    (`basestring`) The text decoration setting, a string from `TEXT_DECORATION_TYPES` list. It also can be set.

  property text_direction

    (`basestring`) The text direction setting. a string from `TEXT_DIRECTION_TYPES` list. It also can be set.

  property text_encoding

    (`basestring`) The internally used text encoding setting. Although it also can be set, but it’s not encouraged.

  property text_interline_spacing

    (`numbers.Real`) The setting of the text line spacing. It also can be set.

  property text_interword_spacing

    (`numbers.Real`) The setting of the word spacing. It also can be set.

  property text_kerning

    (`numbers.Real`) The setting of the text kerning. It also can be set.

  property text_under_color

    (`Color`) The color of a background rectangle to place under text annotations. It also can be set.

  translate(x=0.0, y=0.0)

    Applies a translation to the current coordinate system which moves the coordinate system origin to the specified coordinate.

    Parameters:

      - x (`Real`) – Skew horizontal direction

      - y (`Real`) – Skew vertical direction

    Added in version 0.4.0.

  property vector_graphics

    (`basestring`) The XML text of the Vector Graphics. It also can be set. The drawing-wand XML is experimental, and subject to change.

    Setting this property to None will reset all vector graphic properties to the default state.

    Added in version 0.4.0.

  viewbox(left, top, right, bottom)

    Viewbox sets the overall canvas size to be recorded with the drawing vector data. Usually this will be specified using the same size as the canvas image. When the vector data is saved to SVG or MVG formats, the viewbox is use to specify the size of the canvas image that a viewer will render the vector data on.

    Parameters:

      - left (`Integral`) – the left most point of the viewbox.

      - top (`Integral`) – the top most point of the viewbox.

      - right (`Integral`) – the right most point of the viewbox.

      - bottom (`Integral`) – the bottom most point of the viewbox.

    Added in version 0.4.0.

wand.drawing.FILL_RULE_TYPES = ('undefined', 'evenodd', 'nonzero')

  (`collections.abc.Sequence`) The list of fill-rule types.

  - `'undefined'`

  - `'evenodd'`

  - `'nonzero'`

wand.drawing.FONT_METRICS_ATTRIBUTES = ('character_width', 'character_height', 'ascender', 'descender', 'text_width', 'text_height', 'maximum_horizontal_advance', 'x1', 'y1', 'x2', 'y2', 'x', 'y')

  (`collections.abc.Sequence`) The attribute names of font metrics.

class wand.drawing.FontMetrics(character_width, character_height, ascender, descender, text_width, text_height, maximum_horizontal_advance, x1, y1, x2, y2, x, y)

  The tuple subtype which consists of font metrics data.

  Pixel values can be converted to points by the following:

  \[points = \frac{pixels \ast 72}{resolution}\]
  character_width

    (`numbers.Real`) The horizontal value of the `x` in pixels.

  character_height

    (`numbers.Real`) The vertical value of the `x` in pixels.

  ascender

    (`numbers.Real`) The largest distance from the text baseline to the highest point above the x-height. This value should always be positive.

  descender

    (`numbers.Real`) The farthest distance from the text baseline to the lowest point below the x-height. This value should always be negative.

  text_width

    (`numbers.Real`) The full width of the text.

  text_height

    (`numbers.Real`) The full height of the text.

  maximum_horizontal_advance

    (`numbers.Real`) The largest distance from the start of one character to the start of the following character.

  x1

    (`numbers.Real`) The horizontal value of the bounding box’s starting corner.

  y1

    (`numbers.Real`) The vertical value of the bounding box’s starting corner.

  x2

    (`numbers.Real`) The horizontal value of the bounding box’s ending corner.

  y2

    (`numbers.Real`) The vertical value of the bounding box’s ending corner.

  x

    (`numbers.Real`) The horizontal value of the origin.

  y

    (`numbers.Real`) The vertical value of the origin.

  Note

  When using `get_font_metrics()`, the returned attributes `x1`, `y1`, `x2`, `y2`, `x` and `y` can be ignored as they are used for internal FreeType rendering, and have no meaningful context.

  Added in version 0.3.0.

  Changed in version 0.6.8: Created sub-class of the namedtuple to improve auto-documentation.

  size()

    Short-cut method for the width & height of the rendered text.

    Returns:

      (width, height)

    Added in version 0.6.8.

wand.drawing.GRAVITY_TYPES = ('forget', 'north_west', 'north', 'north_east', 'west', 'center', 'east', 'south_west', 'south', 'south_east', 'static')

  (`collections.abc.Sequence`) The list of text gravity types.

  - `'forget'`

  - `'north_west'`

  - `'north'`

  - `'north_east'`

  - `'west'`

  - `'center'`

  - `'east'`

  - `'south_west'`

  - `'south'`

  - `'south_east'`

  - `'static'`

wand.drawing.LINE_CAP_TYPES = ('undefined', 'butt', 'round', 'square')

  (`collections.abc.Sequence`) The list of LineCap types

  - `'undefined;`

  - `'butt'`

  - `'round'`

  - `'square'`

wand.drawing.LINE_JOIN_TYPES = ('undefined', 'miter', 'round', 'bevel')

  (`collections.abc.Sequence`) The list of LineJoin types

  - `'undefined'`

  - `'miter'`

  - `'round'`

  - `'bevel'`

wand.drawing.PAINT_METHOD_TYPES = ('undefined', 'point', 'replace', 'floodfill', 'filltoborder', 'reset')

  (`collections.abc.Sequence`) The list of paint method types.

  - `'undefined'`

  - `'point'`

  - `'replace'`

  - `'floodfill'`

  - `'filltoborder'`

  - `'reset'`

wand.drawing.STRETCH_TYPES = ('undefined', 'normal', 'ultra_condensed', 'extra_condensed', 'condensed', 'semi_condensed', 'semi_expanded', 'expanded', 'extra_expanded', 'ultra_expanded', 'any')

  (`collections.abc.Sequence`) The list of stretch types for fonts

  - `'undefined;`

  - `'normal'`

  - `'ultra_condensed'`

  - `'extra_condensed'`

  - `'condensed'`

  - `'semi_condensed'`

  - `'semi_expanded'`

  - `'expanded'`

  - `'extra_expanded'`

  - `'ultra_expanded'`

  - `'any'`

wand.drawing.STYLE_TYPES = ('undefined', 'normal', 'italic', 'oblique', 'any')

  (`collections.abc.Sequence`) The list of style types for fonts

  - `'undefined;`

  - `'normal'`

  - `'italic'`

  - `'oblique'`

  - `'any'`

wand.drawing.TEXT_ALIGN_TYPES = ('undefined', 'left', 'center', 'right')

  (`collections.abc.Sequence`) The list of text align types.

  - `'undefined'`

  - `'left'`

  - `'center'`

  - `'right'`

wand.drawing.TEXT_DECORATION_TYPES = ('undefined', 'no', 'underline', 'overline', 'line_through')

  (`collections.abc.Sequence`) The list of text decoration types.

  - `'undefined'`

  - `'no'`

  - `'underline'`

  - `'overline'`

  - `'line_through'`

wand.drawing.TEXT_DIRECTION_TYPES = ('undefined', 'right_to_left', 'left_to_right')

  (`collections.abc.Sequence`) The list of text direction types.

  - `'undefined'`

  - `'right_to_left'`

  - `'left_to_right'`