Capítulo 234 de 411

Chapter 234: DrawSVGPlugin.getLength()

Core Idea

Static helper returning an SVG element's total stroke length (path/rect/circle/ellipse/line/polyline/polygon).

Code Examples

function getPercentage(element) {
  return Math.floor(
    DrawSVGPlugin.getPosition(element)[1] / (DrawSVGPlugin.getLength(element) / 100)
  );
}
  • What it demonstrates: combining getLength() with getPosition() to compute how much of the stroke is currently drawn, as a percentage.

Connects To

  • DrawSVGPlugin.getPosition(): the companion method used together to compute percentage-drawn.