Center Strings inside two separate rectangles

Hi,
I'd like to display two strings inside two separate rectangles on the same screen. How to center each string inside each rectangle ? I tried DrawFormatedText but this uses the whole screen to center in.

Thank you
Read the help file associated with DrawFormattedText, you can position text anywhere on the screen.

--- In psychtoolbox@yahoogroups.com, "Veneree" <vrakotomalala@...> wrote:
>
> Hi,
> I'd like to display two strings inside two separate rectangles on the same screen. How to center each string inside each rectangle ? I tried DrawFormatedText but this uses the whole screen to center in.
>
> Thank you
>
Hi,

there are a handful of functions to help you.

To compute the size or center of a rectangle:
RectSize
CenterRect
CenterRectOnPoint

To compute the size of a text string:
TextBounds
Screen('TextBounds', …)

Be aware that those functions differ in which text 'area' is defined. Their help is worth a look.

Best,

Matthieu



--- In psychtoolbox@yahoogroups.com, "Veneree" <vrakotomalala@...> wrote:
>
> Hi,
> I'd like to display two strings inside two separate rectangles on the same screen. How to center each string inside each rectangle ? I tried DrawFormatedText but this uses the whole screen to center in.
>
> Thank you
>
I think having the ability to center or layout strings within an arbitrary target rectangle as requested by the OP would be generally useful, so i added a new optional 11th parameter 'rect' to DrawFormattedText(), which will allow to specify this. Default behaviour is to use the whole target window or texture, as in the past.

-> UpdatePsychtoolbox

-mario

--- In psychtoolbox@yahoogroups.com, "Matthieu Dubois" <matthdub@...> wrote:
>
> Hi,
>
> there are a handful of functions to help you.
>
> To compute the size or center of a rectangle:
> RectSize
> CenterRect
> CenterRectOnPoint
>
> To compute the size of a text string:
> TextBounds
> Screen('TextBounds', …)
>
> Be aware that those functions differ in which text 'area' is defined. Their help is worth a look.
>
> Best,
>
> Matthieu
>
>
>
> --- In psychtoolbox@yahoogroups.com, "Veneree" <vrakotomalala@> wrote:
> >
> > Hi,
> > I'd like to display two strings inside two separate rectangles on the same screen. How to center each string inside each rectangle ? I tried DrawFormatedText but this uses the whole screen to center in.
> >
> > Thank you
> >
>