|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"jr" <cre### [at] gmailcom> 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_}
>
>
> regards, jr.
Your solution works like a charm. My problem was exactly the text. It is easier
to find the middle point for an object as we design them, but for texts, we rely
on font metrics.
Thanks!
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
hi,
"Kima" <nomail@nomail> wrote:
> ...
> Your solution works like a charm. My problem was exactly the text. It is easier
> to find the middle point for an object as we design them, but for texts, we rely
> on font metrics.
>
> Thanks!
great :-) pleasure.
regards, jr.
Post a reply to this message
|
|
| |
| |
|
|
From: kurtz le pirate
Subject: Re: Centring a text object declaring a directive
Date: 23 Apr 2023 04:13:04
Message: <6444e890@news.povray.org>
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
|
|