<html>
<head >
<title>jQuery Autocomplete Plugin</title>
<script type="text/javascript">
function GetPolyDotsByTwoPoints(startPoint,endPoint,pType){
var betweenPolyDots=[];
switch (pType)
{
case 1:
m=GetMiddlePoint(startPoint.x,endPoint.x);
betweenPolyDots.push({x:m,y:startPoint.y});
betweenPolyDots.push({x:m,y:endPoint.y});
break;
case 2:
m=GetMiddlePoint(startPoint.x,endPoint.x);
betweenPolyDots.push({x:m,y:startPoint.y});
betweenPolyDots.push({x:m,y:endPoint.y-20});
betweenPolyDots.push({x:endPoint.x,y:endPoint.y-20});
break;
case 3:
mx=GetMiddlePoint(startPoint.x,endPoint.x); my=GetMiddlePoint(startPoint.y,endPoint.y);
betweenPolyDots.push({x:mx,y:startPoint.y});
betweenPolyDots.push({x:mx,y:my});
betweenPolyDots.push({x:endPoint.x,y:my});
break;
case 4:
betweenPolyDots.push({x:endPoint.x+20,y:startPoint.y});
betweenPolyDots.push({x:endPoint.x+20,y:endPoint.y});
break;
case 5:
mx=GetMiddlePoint(startPoint.x,endPoint.x); my=GetMiddlePoint(startPoint.y,endPoint.y);
betweenPolyDots.push({x:startPoint.x,y:my});
betweenPolyDots.push({x:mx,y:my});
betweenPolyDots.push({x:mx,y:endPoint.y});
break;
case 6:
betweenPolyDots.push({x:startPoint.x,y:endPoint.y-20});
betweenPolyDots.push({x:endPoint.x,y:endPoint.y-20});
break;
case 7:
m=GetMiddlePoint(startPoint.y,endPoint.y);
betweenPolyDots.push({x:startPoint.x,y:m});
betweenPolyDots.push({x:endPoint.x,y:m});
break;
case 8:
m=GetMiddlePoint(startPoint.y,endPoint.y);
betweenPolyDots.push({x:startPoint.x,y:m});
betweenPolyDots.push({x:endPoint.x+20,y:m});
betweenPolyDots.push({x:endPoint.x+20,y:endPoint.y});
break;
case 9:
betweenPolyDots.push({x:startPoint.x-20,y:startPoint.y});
betweenPolyDots.push({x:startPoint.x-20,y:endPoint.y});
break;
case 10:
betweenPolyDots.push({x:startPoint.x-20,y:startPoint.y});
betweenPolyDots.push({x:startPoint.x-20,y:endPoint.y-20});
betweenPolyDots.push({x:endPoint.x,y:endPoint.y-20});
break;
case 11:
m=GetMiddlePoint(startPoint.y,endPoint.y);
betweenPolyDots.push({x:startPoint.x-20,y:startPoint.y});
betweenPolyDots.push({x:startPoint.x-20,y:m});
betweenPolyDots.push({x:endPoint.x,y:m});
break;
case 12:
m=GetMiddlePoint(startPoint.y,endPoint.y);
betweenPolyDots.push({x:startPoint.x-20,y:startPoint.y});
betweenPolyDots.push({x:startPoint.x-20,y:m});
betweenPolyDots.push({x:endPoint.x+20,y:m});
betweenPolyDots.push({x:endPoint.x+20,y:endPoint.y});
break;
case 13:
m=GetMiddlePoint(startPoint.x,endPoint.x);
betweenPolyDots.push({x:startPoint.x,y:startPoint.y+20});
betweenPolyDots.push({x:m,y:startPoint.y+20});
betweenPolyDots.push({x:m,y:endPoint.y});
break;
case 14:
m=GetMiddlePoint(startPoint.x,endPoint.x);
betweenPolyDots.push({x:startPoint.x,y:startPoint.y+20});
betweenPolyDots.push({x:m,y:startPoint.y+20});
betweenPolyDots.push({x:m,y:endPoint.y-20});
betweenPolyDots.push({x:endPoint.x,y:endPoint.y-20});
break;
case 15:
betweenPolyDots.push({x:startPoint.x,y:startPoint.y+20});
betweenPolyDots.push({x:endPoint.x,y:startPoint.y+20});
break;
case 16:
betweenPolyDots.push({x:startPoint.x,y:startPoint.y+20});
betweenPolyDots.push({x:endPoint.x+20,y:startPoint.y+20});
betweenPolyDots.push({x:endPoint.x+20,y:endPoint.y});
break;
case 17: //1
m=GetMiddlePoint(startPoint.x,endPoint.x);
betweenPolyDots.push({x:m,y:startPoint.y});
betweenPolyDots.push({x:m,y:endPoint.y});
break;
case 18: //3
mx=GetMiddlePoint(startPoint.x,endPoint.x); my=GetMiddlePoint(startPoint.y,endPoint.y);
betweenPolyDots.push({x:mx,y:startPoint.y});
betweenPolyDots.push({x:mx,y:my});
betweenPolyDots.push({x:endPoint.x,y:my});
break;
case 19:
m=GetMiddlePoint(startPoint.x,endPoint.x);
betweenPolyDots.push({x:startPoint.x+20,y:startPoint.y});
betweenPolyDots.push({x:startPoint.x+20,y:endPoint.y+20});
betweenPolyDots.push({x:endPoint.x,y:endPoint.y+20});
break;
case 20:
betweenPolyDots.push({x:endPoint.x+20,y:startPoint.y});
betweenPolyDots.push({x:endPoint.x+20,y:endPoint.y});
break;
case 21:
m=GetMiddlePoint(startPoint.x,endPoint.x);
betweenPolyDots.push({x:startPoint.x,y:startPoint.y-20});
betweenPolyDots.push({x:m,y:startPoint.y-20});
betweenPolyDots.push({x:m,y:endPoint.y});
break;
case 22:
betweenPolyDots.push({x:startPoint.x,y:startPoint.y-20});
betweenPolyDots.push({x:endPoint.x,y:startPoint.y-20});
break;
case 23:
m=GetMiddlePoint(startPoint.x,endPoint.x);
betweenPolyDots.push({x:startPoint.x,y:startPoint.y-20});
betweenPolyDots.push({x:m,y:startPoint.y-20});
betweenPolyDots.push({x:m,y:endPoint.y+20});
betweenPolyDots.push({x:endPoint.x,y:endPoint.y+20});
break;
case 24:
betweenPolyDots.push({x:startPoint.x,y:startPoint.y-20});
betweenPolyDots.push({x:endPoint.x+20,y:startPoint.y-20});
betweenPolyDots.push({x:endPoint.x+20,y:endPoint.y});
break;
case 25:
betweenPolyDots.push({x:startPoint.x-20,y:startPoint.y});
betweenPolyDots.push({x:startPoint.x-20,y:endPoint.y});
break;
case 26:
m=GetMiddlePoint(startPoint.y,endPoint.y);
betweenPolyDots.push({x:startPoint.x-20,y:startPoint.y});
betweenPolyDots.push({x:startPoint.x-20,y:m});
betweenPolyDots.push({x:endPoint.x,y:m});
break;
case 27:
betweenPolyDots.push({x:startPoint.x-20,y:startPoint.y});
betweenPolyDots.push({x:startPoint.x-20,y:endPoint.y+20});
betweenPolyDots.push({x:endPoint.x,y:endPoint.y+20});
break;
case 28:
m=GetMiddlePoint(startPoint.y,endPoint.y);
betweenPolyDots.push({x:startPoint.x-20,y:startPoint.y});
betweenPolyDots.push({x:startPoint.x-20,y:m});
betweenPolyDots.push({x:endPoint.x+20,y:m});
betweenPolyDots.push({x:endPoint.x+20,y:endPoint.y});
break;
case 29:
mx=GetMiddlePoint(startPoint.x,endPoint.x); my=GetMiddlePoint(startPoint.y,endPoint.y);
betweenPolyDots.push({x:startPoint.x,y:my});
betweenPolyDots.push({x:mx,y:my});
betweenPolyDots.push({x:mx,y:endPoint.y});
break;
case 30:
m=GetMiddlePoint(startPoint.y,endPoint.y);
betweenPolyDots.push({x:startPoint.x,y:m});
betweenPolyDots.push({x:endPoint.x,y:m});
break;
case 31:
betweenPolyDots.push({x:startPoint.x,y:endPoint.y+20});
betweenPolyDots.push({x:endPoint.x,y:endPoint.y+20});
break;
case 32:
m=GetMiddlePoint(startPoint.y,endPoint.y);
betweenPolyDots.push({x:startPoint.x,y:m});
betweenPolyDots.push({x:endPoint.x+20,y:m});
betweenPolyDots.push({x:endPoint.x+20,y:endPoint.y});
break;
}
return betweenPolyDots;
}
function GetPolyDots(){
var startPoint={x:200,y:100};
var endPoint={x:400,y:400};
var polyDot=GetPolyDotsByTwoPoints(startPoint,endPoint,polyType.LuRd_DR);
var polysValue=""
for (var i=0;i<polyDot.length;i++){
polysValue=polysValue+polyDot[i].x+","+polyDot[i].y+" ";
}
alert(polysValue);
}
//============================================
var polyType={
LdRu_RL:1, LdRu_RU:2, LdRu_RD:3, LdRu_RR:4,
LdRu_UL:5, LdRu_UU:6, LdRu_UD:7, LdRu_UR:8,
LdRu_LL:9, LdRu_LU:10, LdRu_LD:11, LdRu_LR:12,
LdRu_DL:13, LdRu_DU:14, LdRu_DD:15, LdRu_DR:16,
LuRd_RL:17, LuRd_RU:18, LuRd_RD:19, LuRd_RR:20,
LuRd_UL:21, LuRd_UU:22, LuRd_UD:23, LuRd_UR:24,
LuRd_LL:25, LuRd_LU:26, LuRd_LD:27, LuRd_LR:28,
LuRd_DL:29, LuRd_DU:30, LuRd_DD:31, LuRd_DR:32
};
function GetMiddlePoint(point1,point2){
return Math.ceil((point1+point2)/2);
}
</script>
</head>
<body>
<br>
<input type="button" id="btn" Value="计算" οnclick="GetPolyDots();">
<br><br>
<br>
LdRu_RL:1, LdRu_RU:2, LdRu_RD:3, LdRu_RR:4,<br>
LdRu_UL:5, LdRu_UU:6, LdRu_UD:7, LdRu_UR:8,<br>
LdRu_LL:9, LdRu_LU:10, LdRu_LD:11, LdRu_LR:12,<br>
LdRu_DL:13, LdRu_DU:14, LdRu_DD:15, LdRu_DR:16,<br>
LuRd_RL:17, LuRd_RU:18, LuRd_RD:19, LuRd_RR:20,<br>
LuRd_UL:21, LuRd_UU:22, LuRd_UD:23, LuRd_UR:24,<br>
LuRd_LL:25, LuRd_LU:26, LuRd_LD:27, LuRd_LR:28,<br>
LuRd_DL:29, LuRd_DU:30, LuRd_DD:31, LuRd_DR:32<br>
</body>
</html>