POV-Ray : Newsgroups : povray.general : How arrange a few text objects Server Time
24 Nov 2024 08:29:35 EST (-0500)
  How arrange a few text objects (Message 1 to 4 of 4)  
From: Kima
Subject: How arrange a few text objects
Date: 6 Sep 2019 15:35:00
Message: <web.5d72b3cc91779769ecc0fada0@news.povray.org>
When we have a few separate text objects as

#local t1=text{ ttf "font.ttf", "First", 1, 0 texture{ pigment{ rgb <1,1,1> }}
#local t2=text{ ttf "font.ttf", "Second", 1, 0 texture{ pigment{ rgb <1,1,1> }}
#local t3=text{ ttf "font.ttf", "Third", 1, 0 texture{ pigment{ rgb <1,1,1> }}

union {t1 t2 t3}

how can we place the object after each other on the x-axis to read the text as
"First Second Third"?

I mean how to find the end of each element to place the next one.

I tried to use max_extent, but was confused where to use it to get the last
location of the previous element.


Post a reply to this message

From: Bald Eagle
Subject: Re: How arrange a few text objects
Date: 6 Sep 2019 19:30:00
Message: <web.5d72eacf85cf5efee87cbad00@news.povray.org>
"Kima" <nomail@nomail> wrote:
> When we have a few separate text objects as
>
> #local t1=text{ ttf "font.ttf", "First", 1, 0 texture{ pigment{ rgb <1,1,1> }}
> #local t2=text{ ttf "font.ttf", "Second", 1, 0 texture{ pigment{ rgb <1,1,1> }}
> #local t3=text{ ttf "font.ttf", "Third", 1, 0 texture{ pigment{ rgb <1,1,1> }}
>
> union {t1 t2 t3}
>
> how can we place the object after each other on the x-axis to read the text as
> "First Second Third"?
>
> I mean how to find the end of each element to place the next one.
>
> I tried to use max_extent, but was confused where to use it to get the last
> location of the previous element.

Don't use union.   All that does is treat them all as one compound object.

Use concat ("First", " ", "Second", " ", "Third")

I just put separate spaces in there to show you how to format the command, and
that it doesn't insert any for you.


So,

#local T = concat ("First", " ", "Second", " ", "Third");

object {T texture {pigment {rgb <1,1,1> } }


Post a reply to this message

From: Kima
Subject: Re: How arrange a few text objects
Date: 6 Sep 2019 19:50:00
Message: <web.5d72f06585cf5efeecc0fada0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Kima" <nomail@nomail> wrote:
> > When we have a few separate text objects as
> >
> > #local t1=text{ ttf "font.ttf", "First", 1, 0 texture{ pigment{ rgb <1,1,1> }}
> > #local t2=text{ ttf "font.ttf", "Second", 1, 0 texture{ pigment{ rgb <1,1,1> }}
> > #local t3=text{ ttf "font.ttf", "Third", 1, 0 texture{ pigment{ rgb <1,1,1> }}
> >
> > union {t1 t2 t3}
> >
> > how can we place the object after each other on the x-axis to read the text as
> > "First Second Third"?
> >
> > I mean how to find the end of each element to place the next one.
> >
> > I tried to use max_extent, but was confused where to use it to get the last
> > location of the previous element.
>
> Don't use union.   All that does is treat them all as one compound object.
>
> Use concat ("First", " ", "Second", " ", "Third")
>
> I just put separate spaces in there to show you how to format the command, and
> that it doesn't insert any for you.
>
>
> So,
>
> #local T = concat ("First", " ", "Second", " ", "Third");
>
> object {T texture {pigment {rgb <1,1,1> } }

I cannot combine the texts, as they are separate with different fonts.


Post a reply to this message

From: Bald Eagle
Subject: Re: How arrange a few text objects
Date: 6 Sep 2019 20:25:00
Message: <web.5d72f86e85cf5efee87cbad00@news.povray.org>
"Kima" <nomail@nomail> wrote:

> I cannot combine the texts, as they are separate with different fonts.

Ah.  Righto.

So if you use min_extent and max_extent, you can use those to align things.
http://wiki.povray.org/content/Knowledgebase:Language_Questions_and_Tips

So,

you have:

#local t1=text{ ttf "font.ttf", "First", 1, 0 texture{ pigment{ rgb <1,1,1> }}
#local t2=text{ ttf "font.ttf", "Second", 1, 0 texture{ pigment{ rgb <1,1,1> }}
#local t3=text{ ttf "font.ttf", "Third", 1, 0 texture{ pigment{ rgb <1,1,1> }}

Try:

#declare spacing = 1.0;
#local t1=text{ ttf "font.ttf", "First", 1, 0 texture{ pigment{ rgb <1,1,1> }}
#local t1x = max_extent (t1).x;


#local t2=text{ ttf "font.ttf", "Second", 1, 0 texture{ pigment{ rgb <1,1,1> }
     translate x*(t1x+spacing)}

#local t2x = max_extent (t2).x;
#local t3=text{ ttf "font.ttf", "Third", 1, 0 texture{ pigment{ rgb <1,1,1> }
translate x*(t2x+spacing)}

Not that by appending ".x" to max_extent, I'm selecting only the x component of
the <x, y, z> vector that the function returns.  That way I'm only translating
along x.

Then you can

union {
     object {t1}
     object {t2}
     object {t3}
}


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.