为什么 matter.js 中需要这个字符?

Why is this character required in matter.js?

我正在尝试将 matter.js 移植到另一种语言。 Javascript 不是我最强的语言。

这个函数应该将一个字符串解析为一个特定的对象:

 * @method fromPath
 * @param {string} path
 * @param {body} body
 * @return {vertices} vertices
 */
Vertices.fromPath = function(path, body) {
    var pathPattern = /L?\s*([\-\d\.e]+)[\s,]*([\-\d\.e]+)*/ig,
        points = [];

    path.replace(pathPattern, function(match, x, y) {
        points.push({ x: parseFloat(x), y: parseFloat(y) });
    });

    return Vertices.create(points, body);
};

稍后,将调用此函数,其中将以下字符串传递给 Vertices.fromPath:

vertices: Vertices.fromPath('L 0 0 L ' + width + ' 0 L ' + width + ' ' + height + ' L 0 ' + height)

其中 widthheight 是数字。 L 字符的用途是什么?我认为该方法应该将逗号或 space 分隔的 x,y 对分成数字,所以我无法弄清楚 L 字符的相关性。

谁能教教我?

L 是一个 "Line To" 命令。请参考 SVG 路径语法 (MDN, spec),matter.js 可以接受它作为路径规范。