首先要有一个Canvas,例如<canvas id="canvas" height="800"></canvas>
然后再在Canvas上,画东西。
如下:
var tag="canvas";
var _ANGLE = 30;
var _RADIUS = 10.0;
var _ANGLE_CROSS = 90.0;
var _DIST_CROSS = 8.0;
var _DIST_OUTER = 20.0;
//单箭头
var p0=new jsPoint(100,100);
var p1=new jsPoint(200,100);
drawLine(tag,p0,p1);
drawArrow(tag, p0, p1);
//双箭头在线内
var p2=new jsPoint(100,200);
var p3=new jsPoint(200,200);
drawLine(tag,p2,p3);
drawArrow(tag, p2, p3);
drawArrow(tag, p3, p2);
drawCrossLine(tag, p2, p3);
drawCrossLine(tag, p3, p2);
//双箭头在线外
var p4=new jsPoint(100,300);
var p5=new jsPoint(200,300);
drawLine(tag,p4,p5);
drawArrowOuter(tag, p4, p5);
drawArrowOuter(tag, p5, p4);
drawCrossLine(tag, p4, p5);
drawCrossLine(tag, p5, p4);
function draw