Marker

class svgwrite.container.Marker(insert=None, size=None, orient=None, **extra)

The marker element defines the graphics that is to be used for drawing arrowheads or polymarkers on a given path, line, polyline or polygon element.

Add Marker definitions to a defs section, preferred to the defs section of the main drawing.

example:

dwg = svgwrite.Drawing()
# create a new marker object
marker = dwg.marker(insert=(5,5), size=(10,10))

# red point as marker
marker.add(dwg.circle((5, 5), r=5, fill='red'))

# add marker to defs section of the drawing
dwg.defs.add(marker)

# create a new line object
line = dwg.add(dwg.polyline(
    [(10, 10), (50, 20), (70, 50), (100, 30)],
    stroke='black', fill='none'))

# set marker (start, mid and end markers are the same)
line.set_markers(marker)

# or set markers direct as SVG Attributes 'marker-start', 'marker-mid',
# 'marker-end' or 'marker' if all markers are the same.
line['marker'] = marker.get_funciri()
Marker.__init__(insert=None, size=None, orient=None, **extra)
Parameters:
  • insert (2-tuple) – reference point (refX, refY)
  • size (2-tuple) – (markerWidth, markerHeight)
  • orient'auto' | angle
  • extra – additional SVG attributes as keyword-arguments

SVG Attributes

  • classstring

    assigns one or more css-class-names to an element

  • stylestring

    allows per-element css-style rules to be specified directly on a given element

  • externalResourcesRequiredbool

    False: if document rendering can proceed even if external resources are unavailable else: True

  • viewBox – use svgwrite.mixins.ViewBox interface

  • preserveAspectRatio – use svgwrite.mixins.ViewBox interface

  • markerUnits'strokeWidth|userSpaceOnUse'

    Defines the coordinate system for attributes markerWidth, markerHeight and the contents of the marker.

    If markerUnits – 'strokeWidth', markerWidth, markerHeight and the contents of the marker represent values in a coordinate system which has a single unit equal the size in user units of the current stroke width in place for the graphic object referencing the marker.

    If markerUnits – 'userSpaceOnUse', markerWidth, markerHeight and the contents of the marker represent values in the current user coordinate system in place for the graphic object referencing the marker (i.e., the user coordinate system for the element referencing the marker element via a marker, marker-start, marker-mid or marker-end property).

  • refX<coordinate>insert parameter

    The x-axis coordinate of the reference point which is to be aligned exactly at the marker position. The coordinate is defined in the coordinate system after application of the viewBox and preserveAspectRatio attributes. (default = “0”)

  • refY<coordinate>insert parameter

    The y-axis coordinate of the reference point which is to be aligned exactly at the marker position. The coordinate is defined in the coordinate system after application of the viewBox and preserveAspectRatio attributes. (default = “0”)

  • markerWidth<length>size parameter

    Represents the width of the viewport into which the marker is to be fitted when it is rendered. (default = “3”)

  • markerHeight<length>size parameter

    Represents the height of the viewport into which the marker is to be fitted when it is rendered. A value of zero disables rendering of the element. (default = “3”)

  • orient'auto' | <angle>orient parameter

    Indicates how the marker is rotated. (SVG default = “0”, but for __init__() 'auto' is the default value)

Standard SVG Attributes