I want to create a board class from the canvas, which will allow you to track the position of a click on it in such coordinates as A2, where A ... D is the Y coordinate on a certain scale and 1 ... 3 is the X coordinate
For example, see the image http://img.skitch.com/20091001-k6ybfehid6y8irad36tbsiif15.jpg
What I want to create is a kind of converter from canvas localX and localY to my new coordinates, such as A2.
I am thinking about using this condition
if (0.4 - x*size(from 1-3 here)/canvas.width <= X <= 0.4 + x*size(from 1-3 here)/canvas.width)
X = x;
That way, I can assign the necessary coordinates in the X range. For example 1, 2, 3, etc.
But what to do with the alphanumeric range. (if, for example, I want to make it extensible) ...
Maybe there is a way to convert ASCII to char? Pls. offer your solution
source
share