Skip to main content
Ditched the non-portable, non-useful codepen to keep only the relevant code specified by the author.
Source Link
Vaillancourt
  • 16.4k
  • 17
  • 55
  • 61

https://codepen.io/ysraeljmm/pen/rrbrQJ

Function toVertex Perhaps the following function (it's JavaScript) could help you.

The first parameter is an element of type SVG, it can be a path, rect, circle, etc. The second parameter is the distance of segments. Returns an array as a javascript object, which is generally used in Phaser or matter js.

function toVertex(pathSVG, n){
  let pathLength = pathSVG.getTotalLength();
  let vtx = [];
  var i = 0;
  while(i < pathLength){
    let arr =  pathSVG.getPointAtLength(i);
    vtx.push({x:arr.x, y:arr.y});
    i+=n;
  }
  return vtx;
}

https://codepen.io/ysraeljmm/pen/rrbrQJ

Function toVertex.

The first parameter is an element of type SVG, it can be a path, rect, circle, etc. The second parameter is the distance of segments. Returns an array as a javascript object, which is generally used in Phaser or matter js.

Perhaps the following function (it's JavaScript) could help you.

The first parameter is an element of type SVG, it can be a path, rect, circle, etc. The second parameter is the distance of segments. Returns an array as a javascript object, which is generally used in Phaser or matter js.

function toVertex(pathSVG, n){
  let pathLength = pathSVG.getTotalLength();
  let vtx = [];
  var i = 0;
  while(i < pathLength){
    let arr =  pathSVG.getPointAtLength(i);
    vtx.push({x:arr.x, y:arr.y});
    i+=n;
  }
  return vtx;
}
Translated.
Source Link
Vaillancourt
  • 16.4k
  • 17
  • 55
  • 61

https://codepen.io/ysraeljmm/pen/rrbrQJ

Function toVertex.

E primer parámetro es un elemento de tipoThe first parameter is an element of type SVG, puede ser unit can be a path, rect, circle, etc. El segundo parámetro es la distancia de segmentosThe second parameter is the distance of segments. Devuelve un arreglo como objeto deReturns an array as a javascript object, que generalmente se utiliza enwhich is generally used in Phaser oor matter js.

https://codepen.io/ysraeljmm/pen/rrbrQJ

Function toVertex.

E primer parámetro es un elemento de tipo SVG, puede ser un path, rect, circle, etc. El segundo parámetro es la distancia de segmentos. Devuelve un arreglo como objeto de javascript, que generalmente se utiliza en Phaser o matter js.

https://codepen.io/ysraeljmm/pen/rrbrQJ

Function toVertex.

The first parameter is an element of type SVG, it can be a path, rect, circle, etc. The second parameter is the distance of segments. Returns an array as a javascript object, which is generally used in Phaser or matter js.

Source Link

https://codepen.io/ysraeljmm/pen/rrbrQJ

Function toVertex.

E primer parámetro es un elemento de tipo SVG, puede ser un path, rect, circle, etc. El segundo parámetro es la distancia de segmentos. Devuelve un arreglo como objeto de javascript, que generalmente se utiliza en Phaser o matter js.