Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Making an image scale mouse over on HTM5 <canvas>
To make an image scale on mouse over, use Vanilla JavaScript library.
On mouse move, set it like the following:
function move(e) {
var pos = getMousePos(myCanvas, e);
context.drawImage(img, -pos.x, -pos.y, img.width, img.height);
}
For canvas:
//add event listener we need
myCanvas.addEventListener('mouseout', display, false);
myCanvas.addEventListener('mousemove', move, false);
function display() {
context.drawImage(img, 0, 0, img.width>>1, img.height>>1);
} Advertisements
