clc;
clear all;
close all;
rng('shuffle');

Screen('Preference', 'SkipSyncTests', 1); 
[window, window_size] = Screen('OpenWindow', 0, [0 0 0], [],32,2);

% lets define some variables
x_mid = window_size(3)/2;
y_mid = window_size(4)/2;
max_x_distance_from_middle = 400;
max_y_distance_from_middle = 400;
min_circle_size = 10;
max_circle_size = 50;
number_of_circles = 20;

for counter = 1:number_of_circles

    % randomly find a new circle locations
    x_pos = randi([(x_mid-max_x_distance_from_middle) (x_mid+max_x_distance_from_middle)],1);
    y_pos = randi([(y_mid-max_y_distance_from_middle) (y_mid+max_y_distance_from_middle)],1);
    
    % randomly get a circle size
    cur_size = randi([min_circle_size max_circle_size],1);
    
    % randomly get a circle colour
    colour1 = randi([0 255],1);
    colour2 = randi([0 255],1);
    colour3 = randi([0 255],1);
    
    % Now, lets draw some stuff
    Screen('FillOval', window , [colour1 colour2 colour3], [x_pos-cur_size y_pos-cur_size x_pos+cur_size y_pos+cur_size]);

    % and flip it to the screen
    Screen('Flip',window,0,1);

    % and wait for a bit
    WaitSecs(0.5);

end

% and close it all down
Screen('CloseAll');