View Full Version : Drawing and converting

01-06-2012, 07:33 PM
Hi, I was wondering - how can I convert something that a user draws inside canvas? Say, they draw a square, how could I convert that to print "You have drawn a square" - this would be posted to a text file.

Thanks in advance. :)

01-11-2012, 01:24 PM

01-13-2012, 04:09 AM
How did the user draw the square? Did s/he use your draw-a-square function or put in four separate line segments for you to recognize as a square?

01-16-2012, 08:39 PM
Thank you for your response.

It basically draws a square altogether (not 4 seperate lines).

Any advice would be greatly appreciaited. :)

01-16-2012, 09:56 PM
It basically draws a square altogether.
Whatever "it" is in that sentence (some kind of draw-a-square function?) can state, "You drew a square."

I expect that I'm not properly understanding the question.

01-20-2012, 01:49 PM
Yes exactly, I meant draw-a-square type function (using Canvas and JavaScript functions), would then give the user the option to state "You drew a square" - this would be posted to a .txt file.

Sorry if I haven't been too clear in asking my question.

01-20-2012, 02:22 PM
So basically you want to know how to store a text in a .txt file server side and how you initiate the store process from the client in Javascript?

client side Javascript

var mystring = "......"; // string to be posted to the server
var http = new XMLHttpRequest();
http.open('POST', 'StoreAsTxt.php', true);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.send('txt=' + encodeURIComponent(mystring));

The PHP side may be solved by someone else ... I am not much into PHP. The text will be available in PHP as $_POST["txt"]