Friday, September 30, 2011

Re: [android-developers] DrawTextOnPath advice needed.

About your second question, 
Try enabling anti-alias on your paint object

On Fri, Sep 30, 2011 at 1:56 PM, Nathan <crittermap@crittermap.com> wrote:
Hi,

I'm using DrawtextOnPath. 

My first question is what does hOffset really mean? It says the distance along the path to add to the text's starting position. Is this Euclidean distance in pixels or what?

There is no Canvas.measurePath() command that I can tell, so I have estimated the total length of the path by summing the length of its line segments. 

lengthsquared+=(x-lastx)*(x-lastx) + (y-lasty)*(y-lasty);

totallength = Math.sqrt(lengthsquared)

I think, using my excellent math skills, that I should then be able to divide totallength by canvas.measureText() to get a number of times I should repeat the text along the path, evenly spaced.

But I am find that the totallength in most cases is smaller than it should be. So what should the true range of hOffset be?

public void drawTextOnPath (String text, Path path, float hOffset, float vOffset, Paint paint)

Since: API Level 1

Draw the text, with origin at (x,y), using the specified paint, along the specified path. The paint's Align setting determins where along the path to start the text.

Parameters
text The text to be drawn
path The path the text should follow for its baseline
hOffset The distance along the path to add to the text's starting position
vOffset The distance above(-) or below(+) the path to position the text
paint The paint used for the text (e.g. color, size, style)
Second Question. 
The other problem is that it doesn't look so great. 
It does look okay in APIDemos where you know both the size of the text and have control over the path. 
But when you are data driven and you are using the Path to draw a, well, path, as in walking path and trying to stretch a label on it, it tends to look like graffiti rather easily. When going around a convex curve or corner, it stretches letters as if there were an ink spill. When going around a concave curve, words overlap like a broken typewriter. 
 
Has anyone done something to make it look better?
I know some of this is art more than science. 

Nathan

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en



--
~ Jeremiah:9:23-24
Android 2D MMORPG: http://solrpg.com/http://www.youtube.com/user/revoltingx

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment