function findAnOverlap(p1, w1, p2, w2) {
	// swap if needed
	if(p1 > p2) {
		[p1, p2] = [p2, p1];
		[w1, w2] = [w2, w1];
	}
	let r = 0;
	if(p2 < p1 + w1) {
		r = p2 + (Math.random() * Math.min(w2, (w1 - (p2 - p1))))|0;
	}
	//console.log("overlap of A:", p1, ",", w1, " B:", p2, ",", w2 + " Res:", r);
	return r;

}
// find an overlapping point between segments: [point1, width1] and [point2, width2]
find an overlapping point between segments: [point1, width1] and [point2, width2]
find an overlapping point between segments : [ point1 width1 ] and [ point2 width2 ]
function findAnOverlap(p1, w1, p2, w2) {
	if(p1 > p2) {
		[p1, p2] = [p2, p1];
		[w1, w2] = [w2, w1];
	}
	let r = 0;
	if(p2 < p1 + w1) {
		r = p2 + (Math.random() * Math.min(w2, (w1 - (p2 - p1))))|0;
	}
	return r;
}
function findAnOverlap ( p1 , w1 , p2 , w2 ) { if ( p1 > p2 ) { [ p1 , p2 ] = [ p2 , p1 ] ; [ w1 , w2 ] = [ w2 , w1 ] ; } let r = 0 ; if ( p2 < p1 + w1 ) { r = p2 + ( Math . random ( ) * Math . min ( w2 , ( w1 - ( p2 - p1 ) ) ) ) | 0 ; } return r ; }
find an overlapping point between segments: [point1, width1] and [point2, width2]
find an overlapping point between segments : [ point1 width1 ] and [ point2 width2 ]
// swap if needed //console.log("overlap of A:", p1, ",", w1, " B:", p2, ",", w2 + " Res:", r);