Advertisement
Guest User

Untitled

a guest
Jan 21st, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. <link href="style.css" rel="stylesheet" type="text/css" />
  7. <script type="text/javascript">
  8.     function drawRect(rectOptions){
  9.         var ctx = document.getElementById('canvas').getContext('2d');
  10.         ctx.fillStyle = rectOptions.colour;
  11.         ctx.fillRect(rectOptions.x,rectOptions.y,rectOptions.h,rectOptions.w);
  12.         ctx.font = '12px sans-serif';
  13.         ctx.fillText(rectOptions.name, rectOptions.w + rectOptions.x, rectOptions.h + rectOptions.y);
  14.     }
  15.     function drawConnector(rect1,rect2){
  16.         var ctx = document.getElementById('canvas').getContext('2d');
  17.         ctx.moveTo(70,70);
  18.         ctx.lineTo(240,70);
  19.         ctx.closePath();
  20.         ctx.stroke();
  21.        
  22.     }
  23. </script>
  24.  
  25. </head>
  26.  
  27. <body>
  28.  
  29. <canvas id="canvas" width="800" height="600"></canvas>
  30. <script type="text/javascript">
  31. var connector1 = new drawConnector(rect1,rect2);
  32.  
  33. var rect1 = new drawRect({
  34.             h: 100,
  35.             w: 100,
  36.             x: 20,
  37.             y: 20,
  38.             colour: '8CB5CF',
  39.             name: 'Office 1'
  40. }
  41. );
  42. var rect2 = new drawRect({
  43.             h: 100,
  44.             w: 100,
  45.             x: 280,
  46.             y: 20,
  47.             colour: '8CB5CF',
  48.             name: 'Office 2'
  49. }
  50. );
  51. alert(rect2[drawRect.h]);
  52. </script>
  53. </body>
  54. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement