# NodeBox

Create visual output with Python programming code
Home Download Reference Tutorial Library Gallery About

# svg.parse()

## Syntax

    parse(str)

## Description

Returns a list of paths that are drawable with the drawpath() command. Each returned path has a few special properties not present in normal paths:

- path.closed: is set to True when the path is closed
- path.fill: the fill color of the path in the SVG file
- path.stroke: the stroke color of the path in the SVG file
- path.strokewidth: the stroke width of the path in the SVG file.

These can be used to copy color information from the original vector drawing. Read the tutorial on paths to see what you can do with the points of a path.

## Example

    svg = ximport("svg")
    data = open("flower.svg").read()
    paths = svg.parse(data)

    for path in paths:
      try:
        fill(path.fill)
      except:
        fill(random(), 0, 0)
      drawpath(path)