Raphael js - gettotalLength () and getBBox.width
The answer to this question is best illustrated when we try to draw a square path on one side intentionally skipped out of the path.
Suppose we want to draw a square of one custom block by size, and one of its sides is not included in the path attribute (
). So we get
r.path('M0 0L1 0L1 1L0 1Z')
r.path(M0 0 1 0 1 1 0 1)
. Here we have clearly not drawn the last side of the square.
We expect the path, getTotalLength to return 3, but it will return 4. This is because the pen has to close the path from the last waypoint to the first waypoint (job
). Even if you do not specify
at the end of the path attribute
, the pen will move from its last point in the path to the first point in the black stroke path. So the total path length is 3 sides of the black ink square and one side of the white ink square, so it returns 4. The same goes for rows.
source to share