javascript - HTML 5 Canvas - Grid Block Fill-In - Stack Overflow

I've created a Canvas and have written out a grid(resembles graph paper) with the X & Y coordi

I've created a Canvas and have written out a grid(resembles graph paper) with the X & Y coordinates successfully. What I'm looking to do now is the following:

-When someone clicks with a mouse a square in the grid will change to a different color
-Once a block is selected that data will not change

I've created a Canvas and have written out a grid(resembles graph paper) with the X & Y coordinates successfully. What I'm looking to do now is the following:

-When someone clicks with a mouse a square in the grid will change to a different color
-Once a block is selected that data will not change

Share Improve this question asked May 12, 2012 at 15:31 Matthew LancasterMatthew Lancaster 5193 gold badges12 silver badges22 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

You need a separate 2D array that maintains the state for each (x, y) grid position.

When a click happens, check that state array to see if the cell was clicked before, and update the canvas as appropriate.

I created a little demo to show you: http://jsfiddle/alnitak/xN45K/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745569907a4633618.html

相关推荐

  • javascript - HTML 5 Canvas - Grid Block Fill-In - Stack Overflow

    I've created a Canvas and have written out a grid(resembles graph paper) with the X & Y coordi

    1天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信