POV-Ray : Newsgroups : povray.text.tutorials : centering text Server Time
28 Mar 2024 20:45:16 EDT (-0400)
  centering text (Message 1 to 3 of 3)  
From: Thomas Lehmann
Subject: centering text
Date: 4 May 2000 08:13:58
Message: <391169D5.9C54F7F9@iez.com>
Hi,

is there any way to center a text of any font in a
bounding box ?

Thomas


Post a reply to this message

From: Warp
Subject: Re: centering text
Date: 4 May 2000 08:35:56
Message: <39116eac@news.povray.org>
Thomas Lehmann <tle### [at] iezcom> wrote:
: is there any way to center a text of any font in a
: bounding box ?

  Yes, using MegaPov.
http://nathan.kopp.com/patched.htm

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Jerry
Subject: Re: centering text
Date: 4 May 2000 15:11:05
Message: <jerry-2E8D77.12110604052000@news.povray.org>
In article <391169D5.9C54F7F9@iez.com>, Thomas Lehmann 
<tle### [at] iezcom> wrote:

>Hi,
>
>is there any way to center a text of any font in a
>bounding box ?

You need to use megapov, basically. There are two ways of doing it.

1. The font can be centered on itself. I believe this is only left-right 
centering, but then the center of the image is at x=0 and you can move 
it where you want. I think you simply add the keyword 'center', but 
check the docs.

2. If you want to center verticaly as well as horizontally, the megapov 
includes Ron Parker's "Object Bounds" which gives you the bounding box 
of an object. Create your text object and assign it to a variable:

myText = text { .... }
myTextMin = min_extent(myText);
myTextMax = max_extent(myText);
object { myText
   translate <(myTextMax.x-myTextMin.x)/2,
      (myTextMax.y-myTextMin.y)/2,
      0>
}

should center your object vertically and horizontally. From there, you 
can move it where you need it. You can also use the extents to scale 
your text object to a specific height and/or width, so as to fit exactly 
inside a desired object.

Jerry


Post a reply to this message

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