|
|
On 19/04/2023 14:49, jr wrote:
> 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_}
Following jr's good idea and even if you have to use macro, you might as
well make a "complete" one :
#macro MakeCentetText (pText, pFont, pThickness, pOffset, pTexture)
#local _t = text { ttf pFont pText pThickness, pOffset }
#local _l = (max_extent(_t).x-min_extent(_t).x)*0.50;
object { _t translate -_l*x texture { pTexture } }
#end
and using it like this :
object {
MakeCentetText("some more text", "timrom.ttf", 0.10, 0, myTexture )
}
--
Kurtz le pirate
Compagnie de la Banquise
Post a reply to this message
|
|