|
|
Wasn't it Bill who wrote:
>I'm trying to get a text object to align relative to the center of a
>sphere. The sphere is at <0,0,0>. Since text initially sits with the
>front-bottom-left corner at <0,0,0>, I've translated it to be just in
>front of the sphere.
>
>The challenge is to get the correct x-coordinate fot the text object so it
>is centered relative to the sphere. So far, all I know how to do is
>adjust the x coordinate by trial-and-error. Is there some way to obtain
>the size of the text programatically and set it's location using an
>expression?
You can centre text, or any other type of object, in one dimension with
Center_Object().
#declare T = text { ttf "crystal.ttf", "POV-Ray", 2, 0 pigment {rgb x}}
#include "shapes.inc"
Center_Object(T,x)
You can centre text, or any other type of object, in three dimensions
like this:
#declare T = text { ttf "crystal.ttf", "POV-Ray", 2, 0 pigment {rgb x}}
object {T translate -(min_extent(T) + max_extent(T))/2}
There's also Text_Space() and Text_Width() in "shapes.inc" that perform
the (max_extent(T).x-min_extent(T).x) calculation for you.
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
|