Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2013
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'></script>
  2.  
  3. <style>
  4. html, body {
  5.     margin:10px;
  6.     padding:10px;
  7. }
  8. #worker {
  9.     width: 100%;
  10.     background: #ccc;
  11.     height: 100%;
  12.     position: relative;
  13. }
  14. .block {
  15.     background: black;
  16.     opacity: 0.5;
  17.     width: 40px;
  18.     height: 40px;
  19. }
  20.  
  21. </style>
  22.  
  23. <script>
  24. $(function() {
  25.     var $worker = $('#worker')
  26.     ,   $canvas = $('#picture')
  27.     ,   ctx = $canvas[0].getContext('2d');
  28.    
  29.  
  30.    
  31.    
  32.     function onResize() {
  33.    
  34.  
  35.        
  36.         var width = $worker.width();
  37.         var height =  $worker.height();
  38.        
  39.         $canvas.attr({'width': width, 'height': height});
  40.        
  41.         /**
  42.          * all ok
  43.          */
  44.          
  45.         arc(ctx, 0, 0.1*height);
  46.         arc(ctx, 0.02*width, 0);
  47.         arc(ctx, 0.05*width, 0);
  48.         arc(ctx, 0.11*width, 0);
  49.         arc(ctx, 0.15*width, 0.5*height);
  50.         arc(ctx, 0.186*width, height);
  51.         arc(ctx, 0.3*width, height);
  52.         arc(ctx, 0.38*width, 1*height);
  53.         arc(ctx, 0.4*width, 0.7*height);
  54.         arc(ctx, 0.43*width, 0.3*height);
  55.  
  56.            
  57.         arc(ctx, 0.5*width, 0.3*height);
  58.         arc(ctx, 0.57*width, 0.3*height);
  59.         arc(ctx, 0.6*width, 0.7*height);
  60.         arc(ctx, 0.62*width, 1*height);
  61.         arc(ctx, 0.7*width, 1*height);
  62.         arc(ctx, 0.814*width, 1*height);
  63.         arc(ctx, 0.85*width, 0.5*height);
  64.         arc(ctx, 0.89*width, 0);
  65.         arc(ctx, 0.95*width, 0);
  66.         arc(ctx, 0.98*width, 0);
  67.         arc(ctx, width, 0.1*height);
  68.  
  69.         ctx.lineWidth = 3;
  70.         ctx.strokeStyle = "#000";
  71.            
  72.         ctx.beginPath();
  73.         ctx.moveTo(0, 0.1*height);
  74.        
  75.        
  76.         ctx.bezierCurveTo(
  77.             0, 0.1*height,
  78.             0.02*width, 0,
  79.             0.05*width, 0
  80.         );
  81.        
  82.         ctx.stroke();
  83.         ctx.strokeStyle = "#FF0000";
  84.         ctx.beginPath();
  85.        
  86.         ctx.bezierCurveTo(
  87.             0.05*width, 0,
  88.             0.11*width, 0,
  89.             0.15*width, 0.5*height
  90.         );
  91.        
  92.         ctx.stroke();
  93.         ctx.strokeStyle = "#336600";
  94.         ctx.beginPath();
  95.            
  96.         ctx.bezierCurveTo(
  97.             0.15*width, 0.5*height,
  98.             0.186*width, height,
  99.             0.3*width, height
  100.         );
  101.            
  102.         ctx.stroke();
  103.         ctx.strokeStyle = "#FF9933";
  104.         ctx.beginPath();
  105.            
  106.         ctx.bezierCurveTo(
  107.             0.3*width, height,
  108.             0.38*width, 1*height,
  109.             0.4*width, 0.7*height
  110.         );
  111.            
  112.         ctx.stroke();
  113.         ctx.strokeStyle = "#00FFFF";
  114.         ctx.beginPath();
  115.            
  116.         ctx.bezierCurveTo(
  117.             0.4*width, 0.7*height,
  118.             0.43*width, 0.3*height,
  119.             0.5*width, 0.3*height
  120.         );
  121.            
  122.         ctx.stroke();
  123.         ctx.strokeStyle = "#000";
  124.         ctx.beginPath();
  125.        
  126.         /**
  127.          *
  128.          */
  129.         ctx.bezierCurveTo(
  130.             0.5*width, 0.3*height,
  131.             0.57*width, 0.3*height,
  132.             0.6*width, 0.7*height
  133.         );     
  134.        
  135.         ctx.bezierCurveTo(
  136.             0.6*width, 0.7*height,
  137.             0.62*width, 1*height,
  138.             0.7*width, 1*height
  139.         );
  140.    
  141.         ctx.bezierCurveTo(
  142.             0.7*width, 1*height,
  143.             0.814*width, 1*height,
  144.             0.85*width, 0.5*height
  145.         );
  146.        
  147.         ctx.bezierCurveTo(
  148.             0.85*width, 0.5*height,
  149.             0.89*width, 0,
  150.             0.95*width, 0
  151.         );
  152.        
  153.         ctx.bezierCurveTo(
  154.             0.95*width, 0,
  155.             0.98*width, 0,
  156.             width, 0.1*height
  157.         );
  158.        
  159.         ctx.stroke();
  160.        
  161.         return onResize;
  162.     }
  163.    
  164.     function arc(ctx, x, y) {
  165.         ctx.strokeStyle="#999";
  166.         ctx.fillStyle="blue";
  167.         ctx.arc(x-1,y,1, 0,2*Math.PI);
  168.         ctx.stroke();
  169.     }
  170.  
  171.     $(window).resize(onResize());
  172. });
  173.  
  174. </script>
  175.  
  176.  
  177. <div id='worker'>
  178.     <canvas id="picture" style='position: absolute'></canvas>
  179.     <table width=100% height=100%>
  180.         <td width=16% align='right'>
  181.             <div class='block'></div>
  182.         </td>
  183.         <td width=34%>
  184.             <div class='block' style='margin-left: 75%'></div>
  185.         </td>
  186.         <td width=34%>
  187.             <div class='block' style='margin-left: 20%'></div>
  188.         </td>
  189.         <td width=16% align='left'>
  190.             <div class='block'></div>
  191.         </td>
  192.     </table>
  193. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement