views:

1898

answers:

2

Hi!

I want to create a board class from canvas, which will allow to track click position on it in coordinates like A2, where A...D is Y coordinate in some scale and 1...3 is X coordinate

For example see image http://img.skitch.com/20091001-k6ybfehid6y8irad36tbsiif15.jpg

What I want to create is a kind of convertor from canvas localX and localY to my new coordinates like A2.

I am thinking of implementing if condition this way

if   (0.4 - x*size(from 1-3 here)/canvas.width <= X <= 0.4 + x*size(from 1-3 here)/canvas.width)
       X = x;

This way I can assigned needed coordinates in X range. e.g. 1, 2 ,3 etc

But what to do with alphanumeric range. (if for example I want to make it extensible)...

Maybe there is a way to convert ASCII to char? Pls. suggest your solution

+4  A: 

The same way as in JavaScript: fromCharCode. If y is an integer starting at 1 for A:

String.fromCharCode(64+y)+x
bobince
A: 

you can use the function fromCharCode in String class to do that.

for example: String.fromCharCode(ascii code);

Tuan Nguyen