If you need to provide graphical information on the web page ......

xiaoxiao2021-03-06  100

JavaScript drawing </ title> <meta http-equiv = "content-type" content = "text / html; charSet = GB2312> <script language =" javascript "> IE4 =! Navigator.appversion.Charat (0) <"4" || navigator.appname == "netscape")</p> <p>Var XO = 0Var YO = 0Var ox = -1Var = -1</p> <p>Var rad = math.pi / 180var maxy = 400VAR color = "red"</p> <p>Function Print (STR) {document.write (STR);} Function Orgy (Y) {Return Maxy-y} Function Outplot (X, Y, W, H) {Print ('<span style = "Position: absolute; Left : ' x '; Top: ' y '; Height: ' h '; width: ' w '; font-size: 1px; Background-Color: ' Color ' "> </ 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 <dx; i ) {px = 0 py = 0 Plot (x, y) while (e> = 0) {IF (key == 1) {x = S1 PX = S1} else {y = S2 PY = S2} E = E-2 * DX} if (key == 1) y = S2 else X = S1 E = E 2 * DY}}</p> <p>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)}</p> <p>// 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);</p> <p>// / 准 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 ('<span style = "Position: absolute; font-size: 10pt; Left:' (x 5) '; Top:' Orgy (Y 5) ';"> ' x ', ' y '] </ span> ') color = ocolorxo = oxyo =} // Labor Function Biaozhustr (x, y, s) {return' <span style = "Position: absolute; font- Size: 10pt; Left: ' x '; Top: ' Orgy (Y) '; "> ' 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> <body> <table border = "0" width = "100%"> <Tr> <TD width = "100%" style = "font-size: 18pt; color: # ff0000" class = "t1"> JavaScript drawing </ td> </ tr> <tr> <TD width = "100%" style = "font-size: 12pt; color: # 008000" class = "t2"> 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></p> <p><script> if (ie4) {</p> <p>// Basic Graphic Color = "Maroon" CIR (50, 40, 20) ARC (100, 40, 20, 60, 120, 300) RECT (200, 20, 40, 40)</p> <p>// Pacing chart color = "# ff0000" VAR JD = New Array (203, 232, 277, 223, 271, 250, 273, 280) MoveTo (30, JD [0] -40) BIAOZHU (XO, Yo, JD [0]) for (i = 1; I <jd. Length; i ) {lineto (i * 30 30, jd [i] -40) BIAOZHU (XO, YO, JD [I], 1)} color = "# c0c0" line (30, 140, i * 30 30, 140) Line (30, 140, 30, 260) // Pie Chart Color = "# 00ff00" VAR GC = New Array (150, 120, 200, 180, 180) VAR S = 0VAR M = 0VAR n = 0for (i = 0; i <gc.length; i ) {s = GC [i] IF (GC [i]> m) {m = GC [i] n = i}} var k = S / 360VAR mm = 0VAR a = 0for (i = 0; i <gc.length; i ) {b = math.Round ((GC [i] mm) / k) IF (i == N) Poppei (600, 150, 100, a, b) elsepe (600, 150, 100, a, b) BIAOZHU (60, A (BA) / 2,math.round (GC [I]/s*100 ) "%", 2)mm = mm gc [i] a = b}</p> <p>// Cross label Moveto (280, 20) Zhunxing (XO, YO)</p> <p>} else {document.write ("<p> </ p> <table bgcolor = # ff0000> <tr> <td> <font color = # fff00> Sorry! Your browser cannot support certain features of this page, Please reuse IE4.0 or above browser! Thank you! </ Font> </ td> </ tr> </ table> ")} </ script></p> <p></ body> </ html></p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-103230.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="103230" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.044</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'yDiIyiMAJUiHxCwFhkPSCgWEayahzbbHfPF7_2FCzdv7aICImB2tc22VciyKsoRCBt67qNG8n1qEJIAbvJ'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>