目录
当前位置: 首页 > 文档资料 > Snap.svg 英文文档 >

Snap.format(token, json)

优质
小牛编辑
137浏览
2023-12-01

Replaces construction of type {<name>} to the corresponding argument

Parameters

  1. tokenstringstring to format
  2. jsonobjectobject which properties are used as areplacement

Returns: string formatted string

Usage

// this draws a rectangular shape equivalent to "M10,20h40v50h-40z"
paper.path(Snap.format("M{x},{y}h{dim.width}v{dim.height}h{dim['negative width']}z", {
x: 10,
y: 20,
dim: {
width: 40,
height: 50,
"negative width": -40
}
}));