Avoiding overlap of images on the screen

Hi,

I am designing an experiment in which I present a few items on the
screen for some amount of time and I add few more items while the
previous items continue to be on the screen.

I have not been able to avoid the overlap of these images. Could you
suggest a way to avoid already occupied locations?

Thanks in advance.

Setu
Couple of quick questions:
what are your items? textures(.jpgs) , drawings, text?
are they of uniform or different sizes?
are they always in the same locations?

I know that when I have to display an array of images (jpgs->textures),
I divide my total display area into a grid of equal sized blocks-- a
800x600 would be 4(four) 400x300 mini blocks, with centers at 200,150;
600,150; 200, 450; and 600,450 respectively if you had them arranged
like:

A B
C D

just specify the coordinates at the beginning of your script in some
meaningful manner so you can reference them appropriately for the
destrect(s) that you specify when you make your textures . You also
might want to specify your image size(s) (obviously to some size less
than your destrect so there is separation ;-)

I know that it helps me to sit down and do what I did when I was on the
yearbook (all those aeons ago): grab some graph paper and block out your
screen layout as if it were a page. That way you muck around with
pencil and eraser to get the layout right before you muddy your code.

Allisson





%%% This is my ugly code for my first experiment, where I had side by
side stimuli and a center only stimuli

Screen('Screens');
Screen('Preference','SkipSyncTests',0);% set to 0 for experiments!!!!
HideCursor;
ysize=350; %image size in pixels y-dim
xsize=350; %image size in pixels x-dim
ysize2=ysize; % this is if I need to have different sizes
xsize2=xsize;
x=0; % drawing position relative to center
y=0;
ang = 0; % rotation angle (degrees)

[w,rect]=Screen('OpenWindow',0, [25 25 50]);
Screen('TextSize', w ,14);
Screen('FillRect', w, [25 25 50]);
Screen('Flip', w);
priorityLevel = MaxPriority(w);
Priority(priorityLevel);

x0 = rect(3)/2; % screen center
y0 = rect(4)/2;
x3 = rect(3)/3; % 1/3 of screen
x4 = x3*2; %2/3 of screen
s1=.5; %this scales the stimuli to half size
s2=1;
destrectL = [x3-s1*xsize2+x, y0-s1*ysize2+y, x3+s1*xsize2+x, ...
y0+s1*ysize2+y]; % left position
destrectR = [x4-s1*xsize2+x, y0-s1*ysize2+y, x4+s1*xsize2+x, ...
y0+s1*ysize2+y]; %right position
destrect = [x0-s2*xsize/2+x, y0-s2*ysize/2+y, x0+s2*xsize/2+x, ...
y0+s2*ysize/2+y]; %center position


%%%% end ugly code



--- In psychtoolbox@yahoogroups.com, "setugh" <setugh@...> wrote:
>
> Hi,
>
> I am designing an experiment in which I present a few items on the
> screen for some amount of time and I add few more items while the
> previous items continue to be on the screen.
>
> I have not been able to avoid the overlap of these images. Could you
> suggest a way to avoid already occupied locations?
>
> Thanks in advance.
>
> Setu
>
Hi,

The items are bitmap images and they are of uniform size. And they are not in the same
locations across trials. But as I mentioned earlier I present few items on the screen and
they'll remain either in the same place or change their places a little bit (this is actually a
condition in my expt. change location and no change) when I add the new items.

For example, the first set of items is presented for 500ms and then new items are added.
The problem is I have hard-coded the locations for the first set of items because they
need to be in a particular configuration. But the other set needs to randomly distributed
over the screen (thus avoiding overlap with already present items).

Hope I have made my problem clear!

Thanks,
Setu







--- In psychtoolbox@yahoogroups.com, "konaketa" <hseiler@...> wrote:
>
>
> Couple of quick questions:
> what are your items? textures(.jpgs) , drawings, text?
> are they of uniform or different sizes?
> are they always in the same locations?
>
> I know that when I have to display an array of images (jpgs->textures),
> I divide my total display area into a grid of equal sized blocks-- a
> 800x600 would be 4(four) 400x300 mini blocks, with centers at 200,150;
> 600,150; 200, 450; and 600,450 respectively if you had them arranged
> like:
>
> A B
> C D
>
> just specify the coordinates at the beginning of your script in some
> meaningful manner so you can reference them appropriately for the
> destrect(s) that you specify when you make your textures . You also
> might want to specify your image size(s) (obviously to some size less
> than your destrect so there is separation ;-)
>
> I know that it helps me to sit down and do what I did when I was on the
> yearbook (all those aeons ago): grab some graph paper and block out your
> screen layout as if it were a page. That way you muck around with
> pencil and eraser to get the layout right before you muddy your code.
>
> Allisson
>
>
>
>
>
> %%% This is my ugly code for my first experiment, where I had side by
> side stimuli and a center only stimuli
>
> Screen('Screens');
> Screen('Preference','SkipSyncTests',0);% set to 0 for experiments!!!!
> HideCursor;
> ysize=350; %image size in pixels y-dim
> xsize=350; %image size in pixels x-dim
> ysize2=ysize; % this is if I need to have different sizes
> xsize2=xsize;
> x=0; % drawing position relative to center
> y=0;
> ang = 0; % rotation angle (degrees)
>
> [w,rect]=Screen('OpenWindow',0, [25 25 50]);
> Screen('TextSize', w ,14);
> Screen('FillRect', w, [25 25 50]);
> Screen('Flip', w);
> priorityLevel = MaxPriority(w);
> Priority(priorityLevel);
>
> x0 = rect(3)/2; % screen center
> y0 = rect(4)/2;
> x3 = rect(3)/3; % 1/3 of screen
> x4 = x3*2; %2/3 of screen
> s1=.5; %this scales the stimuli to half size
> s2=1;
> destrectL = [x3-s1*xsize2+x, y0-s1*ysize2+y, x3+s1*xsize2+x, ...
> y0+s1*ysize2+y]; % left position
> destrectR = [x4-s1*xsize2+x, y0-s1*ysize2+y, x4+s1*xsize2+x, ...
> y0+s1*ysize2+y]; %right position
> destrect = [x0-s2*xsize/2+x, y0-s2*ysize/2+y, x0+s2*xsize/2+x, ...
> y0+s2*ysize/2+y]; %center position
>
>
> %%%% end ugly code
>
>
>
> --- In psychtoolbox@yahoogroups.com, "setugh" <setugh@> wrote:
> >
> > Hi,
> >
> > I am designing an experiment in which I present a few items on the
> > screen for some amount of time and I add few more items while the
> > previous items continue to be on the screen.
> >
> > I have not been able to avoid the overlap of these images. Could you
> > suggest a way to avoid already occupied locations?
> >
> > Thanks in advance.
> >
> > Setu
> >
>