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.translate(x, y);
     16   canvasContext.rotate(angle);
     17   canvasContext.drawImage(ballImage, -ballRadius, -ballRadius, ballDiameter,
     18       ballDiameter);
     19   canvasContext.restore();
     20 }
     21