Jump to content

javacript as mouse moves over tile the color of tile changes


nrjs
 Share

Recommended Posts

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.

post-10253-0-86515200-1408710146.jpg

Link to comment
Share on other sites

  • 2 weeks later...

you can always use the mousemove event to pick up the x,y co-ordinates and then on the draw events see if the mouse pointer is over the current square.  If so,  draw a different colour.

 

Mouse point example: http://www.html5canvastutorials.com/advanced/html5-canvas-mouse-coordinates/

 

If you want a little more info, please feel free to ask.

 

Kelvin

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...