# Connecting Lines to Ovals

**URL:** <https://psychtoolbox.discourse.group/t/connecting-lines-to-ovals/1687>\
**Category:** Uncategorized\
**Created:** [September 8, 2006, 8:29pm UTC](https://psychtoolbox.discourse.group/t/connecting-lines-to-ovals/1687 "2006-09-08T20:29:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [September 8, 2006, 8:29pm UTC](https://psychtoolbox.discourse.group/t/connecting-lines-to-ovals/1687/1 "2006-09-08T20:29:30Z")

</div>

Hey -- I am fairly new to Psych toolbox. I am try to connect ovals   
with lines using the screen function so far I have:  
  
bits = 5;  
  
% Turn off warnings  
warning('off','all');  
  
% Open window  
[window,windowRect] = screen(0,'OpenWindow');  
  
% Fill background  
bgCol = [25 25 50];  
screen(window,'FillRect',bgCol,windowRect);  
  
% Dot rect  
dotRectSize = 40;  
minDistance = 70;  
dotRect = [0 0 dotRectSize dotRectSize];  
  
% Number of dots  
nDots = bits;  
  
% Dot random positions  
dotPos = rand(nDots,2) .\* expand([windowRect(3)-minDistance   
windowRect(4)-minDistance],1,nDots) + expand([minDistance/2   
minDistance/2],1,nDots);  
  
% Draw dots  
for iDots = 1:nDots  
 currDotRect = centerRectOnPoint(dotRect,dotPos(iDots,1),dotPos  
(iDots,2));  
 currDotCol = rand(1,3)\*200+55; % pick a random color  
 screen(window,'DrawOval',currDotCol,currDotRect);  
end  
  
% Close window when key pressed  
getChar;  
screen('closeall');
