nrjs 0 Report post Posted August 22, 2014 There is a canvas ABCD .AB measures 400 ,BC measures 400 cm.The tiles are 80 cm long separated by a distance of 16 cm apart.When mouse comes on the tile the color of the tile should change red.When mouse moves out of the tile it should get unfilled with color and the new tile on which the mouse is in should be colored to red.This process should continue as the mouse moves over each tiles. Can you suggest an algorithm on how to implement this.Image shown in below link.Please help me.http://postimg.org/image/4ut3squ3d/ Quote Share this post Link to post Share on other sites
SebastianNette 68 Report post Posted August 23, 2014 var selected = null; // x = mouse x // y = mouse y var a = Math.floor(x/96); var b = Math.floor(y/96); if(x%96 >= 16 && y%96 >= 16) { if(selected) { // unselect } selected = tile a b } 1 Deban reacted to this Quote Share this post Link to post Share on other sites