In last post, I implemented text(val). Today, I was working on text(val,x1,y1,width,height).
To wrap the text, the very first thing came into my mind was TextArea. TextArea allows the text wrap automatically. If I can use get the text of each line inside the TextArea, I can use the same technique as I used in my last post. Then, I went to search how to do that. And it wasted me almost 6 hours. What I got for that is it is impossible to let TextArea return only one line of text.
When I was going to stop, I wonder why I don't take a look at the canvas instruction again. I looked at HTML 5 canvas - the basics, and search how to draw the text in canvas, and I got this page - Drawing text using a canvas. There is a method called mozMeasureText() which can actually solve the problem of my last post (why didn't I see this earlier). Anyway, I implemented text(val,x1,y1,width,height) and upgrade the text(val). Now they both look very good.
The next thing I need to do is, do my best to make the code better, and reorganize the tests.
this is the preview (see this in Firefox):
Wednesday, February 10, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment