Home | History | Annotate | Download | only in canvas2d_balls_common
      1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 var ballImage;
      6 var ballRadius;
      7 
      8 function drawBallInit(diameter) {
      9   ballRadius = diameter / 2;
     10   ballImage = document.getElementById('ballImage');
     11 }
     12 
     13 function drawBall(x, y, angle) {
     14   canvasContext.save();
     15   canvasContext.shadowColor = 'black';
     16   canvasContext.shadowOffsetX = -ballRadius;
     17   canvasContext.shadowOffsetY = ballRadius;
     18   canvasContext.shadowBlur = ballRadius;
     19   canvasContext.translate(x, y);
     20   canvasContext.rotate(angle);
     21   canvasContext.drawImage(ballImage, -ballRadius, -ballRadius, ballDiameter,
     22       ballDiameter);
     23   canvasContext.restore();
     24 }
     25