Var XO = 0Var YO = 0Var ox = -1Var = -1
Var rad = math.pi / 180var maxy = 400VAR color = "red"
Function Print (STR) {document.write (STR);} Function Orgy (Y) {Return Maxy-y} Function Outplot (X, Y, W, H) {Print (' span> '); } function plot (x, y) {OUTPLOT (X, Y, 1, 1) IF (OX> = 0 || OY> = 0) {Showline (OX, OY, X-OX, Y-OY)} ox = x io = y} Function Showline (X, Y, W, H) {IF (W <0) {x = w w = math.abs (w)} IF (h <0) {y = h h = Math.abs (h)} if (w <1) w = 1 IF (h <1) h = 1 OUTPLOT (X, Y, Math.Round (W), Math.Round (H))} Function Lineto (X , Y) {Line (XO, YO, X, Y)} Function Sign (N) {IF (n> 0) Return 1 IF (n <0) Return -1 Return N} Function Line (x1, y1, x2, Y2) {x2 = math.Round (x2) y2 = math.Round (Y2) XO = x2 yo = y2 y1 = orgy (y1) y2 = orgy (y2) var str = "" "" VAR i = 0 var x = x1 VAR Y = Y1 DX = Math.abs (x2-x1) DY = math.abs (Y2-Y1) S1 = SIGN (X2-X1) S2 = SIGN (Y2-Y) IF (DX == 0 || DY = = 0) {Showline (x1, y1, x2-x1, y2-y1) return} if (dx> dy) {TEMP = DX DX = DY DY = Temp key = 1} else key = 0 E = 2 * DY-DX for (i = 0; i
Function MoveTo (x, y) {o = io = -1; XO = math.Round (x); yo = math.Round (Y);} / Round Function CIR (X, Y, R) {Moveto (x r, y); for (i = 0; i <= 360; i = 5) {lineto (r * math.cos (i * rad) x, r * math.sin (i * rad) Y) }} // Curved Function ARC (X, Y, R, A1, A2) {MoveTo (r * Math.cos (A1 * RAD) X, R * Math.sin (A1 * RAD) Y); For (i = a1; i <= a2; i ) {lineto (r * math.cos (i * rad) x, r * math.sin (i * rad) y)}} // sector Function Pei ( X, Y, R, A1, A2) {MoveTo (X, Y); for (var i = a1; i <= a2; i ) {lineto (r * math.cos (i * rad) x, r * Math.sin (i * rad) y);} LINETO (x, y);} // pop up fan-shaped Function Poppei (X, Y, R, A1, A2) {dx = r * Math.cos ((A1 ) A2-A1) / 2) * RAD) / 10DY = R * Math.SIN ((A1 (A2-A1) / 2) * rad) / 10X = DXY = DYMOVETO (X, Y) for (var i = A1; I <= a2; i ) {lineto (r * math.cos (i * rad) x, r * math.sin (i * rad) y)} lineto (x, y)}
// Rectangular Function Rect (X, Y, W, H) {Moveto (X, Y); LINETO (X W, Y); LINETO (X W, Y H); LINETO (X, Y H) LINETO (X, Y);
// / 准 function zhunxing (x, y) {var ox = xovar = yovar ket = colorColor = "# 000000" Line (x-5, y, x 6, y) line (x, y-6, x, Y 5) Print (' ' x ', ' y '] span> ') color = ocolorxo = oxyo =} // Labor Function Biaozhustr (x, y, s) {return' ' S ' span> '} Function Biaozhu (x, y, s, t) {var ox = xovar OY = YOVAR OCOLOR = ColorPoint = "p01.gif" if (t == 1) {print (Biaozhustr (x-5, y 6, "· s)} = f (t == 2) {Print BIAOZHUSTR (XO X * Math.cos (Y * RAD) -10, YO X * Math.SIN (Y * RAD), S))} color = ocolorXo = oxyo =} script> head>
JavaScript drawing td> tr> If you need to provide graphical information on the web, It is usually made into a picture, but the overhead on the network is too big. what else can we do? Here to provide a set of JavaScript functions to solve this problem. Although it is simple, it is still more than enough for the drawing point. td> tr> table>