By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,796 Members | 1,240 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,796 IT Pros & Developers. It's quick & easy.

Drawing circuit in Javascript

P: 2
Am new to javaScript.
Am trying to draw circuits in JavaScript.
I have problem with drawing the arcs in the AND & OR logic gates

Can any body help me to do this?
Am using IE6.0. it's not supporting canvas.
fillArc() method of JavaScript is also not working.
Expand|Select|Wrap|Line Numbers
  1.  
  2. <HTML>
  3. <head>
  4. <script type="text/javascript" src="wz_jsgraphics.js"></script> 
  5.  
  6. </head>
  7. <body> 
  8.  
  9. <div id="first"></div>
  10. <script type="text/javascript">
  11. function d()
  12. {
  13. a.drawLine(105,120,105,400);// LINE FOR A
  14. a.drawString("A'",120,100); 
  15. a.drawLine(105,130,125,130);//LINE CONNECTING A AND A'
  16. a.drawLine(125,130,125,140);// LINE from A' PROCEEDING TO NOT GATE
  17. a.drawLine(115,140,135,140);// STRAIGHT LINE PART OF NOT GATE
  18. a.drawLine(115,140,125,150);//LEFT LINE OF NOT
  19. a.drawLine(125,150,135,140);// RIGHT LINE OF NOT
  20. a.drawEllipse(120,150,10,10);
  21. a.drawLine(125,160,125,400); // LINE FOR A'
  22. a.drawString("B",160,100);
  23. a.drawLine(165,120,165,400);// LINE FOR B
  24. a.drawString("B'",180,100); 
  25. a.drawLine(165,130,185,130);//LINE CONNECTING B AND B'
  26. a.drawLine(185,130,185,140);// LINE from B' PROCEEDING TO NOT GATE
  27. a.drawLine(175,140,195,140);// STRAIGHT LINE PART OF NOT GATE
  28. a.drawLine(175,140,185,150);//LEFT LINE OF NOT
  29. a.drawLine(185,150,195,140);// RIGHT LINE OF NOT
  30. a.drawEllipse(180,150,10,10);
  31. a.drawLine(185,160,185,400); // LINE FOR B'
  32. a.drawLine(105,170,230,170);//line extending from A for AB
  33. a.fillEllipse(104,169,4,4);//point denoting A in AB(and gate)
  34. a.drawLine(165,190,230,190);//line extending from B for AB
  35. a.fillEllipse(164,189,4,4);//point denoting B in AB(AND gate)
  36. a.drawLine(230,165,230,195);//line joining A and B in AND gate
  37. //a.fillArc(230,165,30,30,0,60);
  38. a.drawRect(230,165,30,30);
  39. var Xpoints = new Array(10,30,20,10);
  40. var YPoints = new Array(10,10,20,10);
  41. a.drawPolyline(Xpoints,YPoints);
  42. var Xpoints1 = new Array(300,320,310,300);
  43. var YPoints1 = new Array(300,300,310,300);
  44. a.drawPolyline(Xpoints1,YPoints1);
  45. var a1=500;
  46. var b1=500;
  47. var c,d=0;
  48. /*for(c=1;c<=20;c++)
  49. {
  50. a.drawEllipse(a1,b1,1,1);
  51. if (c<10)
  52. {
  53. a1=a1+5;
  54. b1=b1+5;
  55. }
  56. if(c==10)
  57. {
  58. if(d<=8))
  59. {
  60. a1=a1-1;
  61. b1=b1;
  62. d=d+1;
  63. }
  64. }
  65. else
  66. {
  67. a1=a1-1;
  68. b1=b1+1;
  69. }
  70. c=c+1;
  71. }*/
  72. a.paint();
  73. }
  74. var a=new jsGraphics();
  75. var b=new jsGraphics("first");
  76. d();
  77. </script>
  78. </body>
  79. </html>
  80.  
Thanking u in anticipation
Maha
Oct 6 '08 #1
Share this Question
Share on Google+
3 Replies


acoder
Expert Mod 15k+
P: 16,027
Have you tested in other browsers?

Is it just the arcs that you can't get working?
Oct 6 '08 #2

P: 2
NO i just tried in IE6.0.
This is for my examination sake. My college lab computers have only IE6.0. Hence am forced to do in IE6.0

If there is no such restriction, then I can use any other browser such as opera. I tried to use canvas (HTML5). IE6 is not supporting canvas.
Oct 7 '08 #3

acoder
Expert Mod 15k+
P: 16,027
That is very poor on the part of the college for not offering a choice, not teaching students to program cross-browser, and at the very least not upgrading.

Try the examples on the website where you got the library script from. Do they work in IE6?
Oct 7 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.