POV-Ray : Newsgroups : povray.advanced-users : Multiline Text : Re: Multiline Text Server Time
28 May 2024 19:36:03 EDT (-0400)
  Re: Multiline Text  
From: Alain
Date: 21 Feb 2014 14:25:11
Message: <5307a817@news.povray.org>

> I have searched everywhere, but could not find anything about this topic.
> I want to create a Multiline text object.that I can use for further  use as a
> whole.
> How can I create such an object? Is it possible to get the text lines centered
> within that object?
> Thanks in advance for your help.
> Regards, Didiw
>
>
>
>

Define an array containing your lines of text, one per element.
#declare your text objects normaly. Once placed, you can reuse the 
identifier.
Use max_extent to find the top right point of your lines. The text start 
at <0,0,0> and extend toward +X with the front along the X-Y plane. The 
thickness extend toward +Z.

To center your text, use translate -max_extent(Your_Text)/2*x or 
-max_extent(Your_Text).x/2

To place the lines verticaly, you use the y component returned my 
max_extent. Using a given font, all lines should have the same hight.

I recomend creating a macro to create and place your lines.

Next, bind all individual lines into an union.
That way, you can manipulate them all as a single object. If all text is 
to have the same texture, apply the texture to the union, not to each 
individual lines.


Sample:

#declare My_Text= array[2]
{"First line of text"
,"and a somewhat longer text for the second line"
,"The last line."
}

#declare The_Text= union{
  #declare Line=0;
  #while(Line<3)
   #declare One_line= text{"arial.ttf" My_Text[Line], 1, 0}
   #decalre Size= max_extent(One_Line);
   object{One_line translate <-Size.x/2, (Size.y*2-Size.y*Line), 0>}
   #declare Line=Line+1;
  #end
  texture{Your_Texture}
}

This will create a 3 lines of text object, with the bottom line on the 
X-Z plane centered relative to the Y axis.



Alain


Post a reply to this message

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