Patches

JSON to Shape

JSON to Shape

Takes a JSON with the following structure and commands to create a shape object:

{
  "path" : [
    // Array of Commands to build the shape
  ]
}

The commands accepted in the array are the following:

moveTo: Move the current point to (x, y) and begin a new subpath.

{
  "type" : "moveTo"
  "point" : {
    "x" : 0,
    "y" : 0
  }
}

lineTo: Append a straight line segment from the current point to (x, y) in shape and move the current point to (x, y).

{
  "type" : "lineTo"
  "point" : {
    "x" : 0,
    "y" : 0
  }
}

curveTo: Append a cubic bézier curve from the current point to “curveTo(x,y)” with control points “curveFrom(x, y)” and “point(x, y)” in “shape” and move the current point to “(x, y)”.

{
  "type" : "curveTo",
  "curveFrom" : {
    "x" : 0,
    "y" : 0
  },
  "point" : {
    "x" : 0,
    "y" : 0
  },
  "curveTo" : {
    "x" : 0,
    "y" : 0
  }
}

JSON to Shape

  • JSON
  • Coordinate Space
  • Shape
  • Error

JSON

A JSON Object that follows the path structure.

Coordinate Space

A width and height value that will act as a scale multiplier for every x,y component on the shape.

Shape

A shape object.

Error

A string with an explanation of an error, if there was an error with the path structure.