I am facing error with adding a color to a line in a path using javascript in creative experience

I am unable to measure the length of the line and unable to mention it properly ? that i end and i origin 


​​​​​​​

// Assume DSMath is properly included and initialized

var vecLine = new DSMath.Vector3D(iEnd.x-iOrigin.x,iEnd.y-iOrigin.y)

var normVal = vecLine.norm();

var vecLineNormalized = DSMath.Vector3D.normalize(vecLine);

if(normVal <= this.dashLength){

var line = rm.createLine(iOrigin,iEnd,options);

}

else{

var nbSegments = normVal / this.dashLength;

var prevPos = new DSMath.Point();

prevPos.copy(iOrigin);

 

for(var i = 1;i< nbSegments;i++){

var normalized = new DSMath.Point();

normalized.copy(vecLineNormalized);

var mul = i* this.dashLength;

var pos = normalized.multiplyScalar(mul);

var newPos = DSMath.Point.add(iOrigin,Pos);

if(i % 2 ==1)

{

var line = rm.createLine(prevPos,newPos,options);

}

prevPos.copy(newPos);

if(iDrawLastSegment){

var line = rm.createLine(prevPos, iEnd, options);

}

}

};