如题,似乎接口都是画实线的,虚线,点画线怎么画呢。
解决方案 »
- 请教div渐入渐出效果
- js 怎样准确验证网址
- 求助 在线等
- JS获取图片大小问题!
- 关于 弹出窗口的问题
- 怎样在 cells 里面的一个事件中自动获得 cells 是表格里面的第几行第几个 cell 呢?
- 高手帮忙:框架(含2个页面)出现,怎么实现根据一个页面中的text值调用另一页面中的函数?
- radio不可以得到form1.Gender.value嗎?undefined了
- 请问,一个难题!!!
- 前两天看见ibm机器的随机光盘里有一个html文件,点击里面的连接可以直接调用“计划任务”和“磁盘整理”,感到很好奇想知道是怎么实现的!!!!!!!!!!!!!!!!!!!!!!!!!
- dojo上传文件出错问题
- 求高手js 修改代码
总不能我一小段画,一小段不画吧
if (ctx && ctx.lineTo){
ctx.dottedLine = dottedLine;
} else {
window.dottedLine = dottedLine;
}
function dottedLine(x, y, x2, y2, dotArray, ctx){
var context = ctx || this,
dashCount = dotArray.length,
dx = (x2 - x), dy = (y2 - y),
xSlope = dx > dy,
slope = (xSlope) ? dy / dx : dx / dy;
if(slope > 9999) {
slope = 9999;
}
else if(slope < -9999) {
slope = -9999;
}
var distRemaining = Math.sqrt(dx * dx + dy * dy);
var dashIndex = 0, draw = true;
while(distRemaining >= 0.1 && dashIndex < 10000) {
var dashLength = dotArray[dashIndex++ % dashCount];
if(dashLength === 0) {
dashLength = 0.001;
}
if(dashLength > distRemaining) {
dashLength = distRemaining;
}
var step = Math.sqrt(dashLength * dashLength / (1 + slope * slope));
if(xSlope) {
x += dx < 0 && dy < 0 ? step * -1 : step;
y += dx < 0 && dy < 0 ? slope * step * -1 : slope * step;
}
else {
x += dx < 0 && dy < 0 ? slope * step * -1 : slope * step;
y += dx < 0 && dy < 0 ? step * -1 : step;
}
context[draw ? 'lineTo' : 'moveTo'](x, y);
distRemaining -= dashLength;
draw = !draw;
}
context.moveTo(x2, y2);
}