DIVIDE PATH
Returns an array of points evenly distributed along the path object provided.
Arguments as follows:
obj – the path object in question to be divided, [object]
num – a number that can work in two ways; as a divisor of the path length or as distance between points, [number]
divOrDist – when ‘true’ num is a divisor, when ‘false’ num is to be regarded as a distance, [boolean]
fit – when ‘true’ the distance is path fitted else the distance is exact, [boolean]
This is perhaps best illustrated.
function divideEven(obj, num, divOrDist, fit){ var pathLength = obj.length var points = [] var divs = Math.round(num) if(!divOrDist){ if(fit){ divs = Math.round(pathLength / num) } else { divs = pathLength / num } } for(var i = 0; i points.push(obj.getPoint(i / divs * pathLength)) } points.push(obj.getPoint(pathLength)) return points }
Back to Scripts