var offset=this.textOffset, x=0, y=0; var slope=this.calculate.slope(this.control, this.end); if(Math.abs(slope)>=1){ x=this.end.x+this.calculate.dx(this.control, this.end, offset); if(this.control.y>this.end.y) y=this.end.y-offset; else y=this.end.y+offset+this.textYOffset; } else if(slope==0){ x=this.end.x+offset; y=this.end.y+this.textYOffset; } else { if(this.start.x>this.end.x){ x=this.end.x-offset; this.textAlign="end"; } else { x=this.end.x+offset; this.textAlign="start"; } if(this.start.y<this.end.y) y=this.end.y+this.calculate.dy(this.control, this.end, offset)+this.textYOffset; else y=this.end.y+this.calculate.dy(this.control, this.end, -offset); } this.textPosition={ x:x, y:y };