|
|
hi,
"Kima" <nomail@nomail> wrote:
> I align a text object as
>
> local MyText=text {ttf "timrom.ttf", "Some text",1,0 }
>
> object { MyText
> translate -(min_extent(MyText) + max_extent(MyText)) / 2
> }
>
> `Center_Trans` in transforms.inc is also based on the same approach.
>
> I wonder if there is a way to do so without defining the directive of `MyText`.
>
> I mean something like `min_extent()` of the current object.
not sure about objects in general, but with a text{} you could "cheat" using a
macro, eg:
#macro textLen(font_,s_)
#local t_ = text {ttf font_, s_, 1, 0};
(max_extent(t_).x - min_extent(t_).x)
#end
#declare txt_ = text {
ttf "timrom.ttf", "some more text", .1, 0
texture {texture_}
translate <-(textLen("timrom.ttf","some more text")) / 2,-2,0>
};
object {txt_}
regards, jr.
Post a reply to this message
|
|