def retSVGAttrsFromStroke(stroke):
    """Returns SVG attributes as a dictionary from a Stroke() object."""
    r = {'stroke-width': '{:.3f}'.format(stroke.width), 'stroke': str(
        stroke.colour), 'stroke-opacity': '{:.3f}'.format(stroke.opacity)}
    if stroke.coding:
        r['stroke-dasharray'] = '{:d},{:d}'.format(stroke.coding[0], stroke
            .coding[1])
    return r
