function data = lineMotion();
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% COGENT: CONFIGURATION
% display parameters
screenMode = 0;                 % 0 for small window, 1 for full screen, 2 for second screen if attached
screenRes = 2;                  % 800 x 600 resolution
white = [1 1 1];                % foreground colour (optional)
black = [0 0 0];                % background colour (optional)
fontName = 'Helvetica';         % font parameters (optional)
fontSize = 20;
number_of_buffers = 5;          % how many offscreen buffers to create
rand('seed',sum(100*clock));    % seeds the random number generator with the clock time

% call config_... to set up cogent environment, before starting cogent
config_display(screenMode, screenRes, black ,white, fontName, fontSize, number_of_buffers);   % open graphics window
config_keyboard;                % this enables collection of keyboard responses
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc;

%
%
%
disp('Line motion illusion');
input('Press ENTER to go to example 5');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EXAMPLE One: Drawing lines and circles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
start_cogent
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
cgtext('Press any key to Start',0,0);
cgflip;
waitkeydown(inf);
cgflip(0,0,0);cgflip(0,0,0);
wait(500);

for i = 1 : 5
    cgpenwid(5);
    % assign a random location to the circle
    dotX = (rand .* 300)-150;
    dotY = (rand .* 300)-150;

    % assign end point of the line
    endLineX = (rand .* 500)-250;
    endLineY = (rand .* 500)-250;

    % draw circle
    cgellipse(dotX,dotY,10,10,[1 1 1], 'f');
    cgflip(0,0,0);
    wait(150);
    cgflip(0,0,0);

    % draw line
    cgdraw(dotX,dotY, endLineX,endLineY,[1 1 1]);
    cgflip(0,0,0);
    wait(100);
    cgflip(0,0,0);

    wait(1000);
    % go to next trial
    cgtext('Press any key to continue',0,0);
    cgflip;

    waitkeydown(inf);

    cgflip(0,0,0);cgflip(0,0,0);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
stop_cogent
clc;







disp('Line motion illusion - multiple elements');
input('Press ENTER to go to example 5');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EXAMPLE One: Drawing lines and circles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
start_cogent
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
cgtext('Press any key to Start',0,0);
cgflip;
waitkeydown(inf);
cgflip(0,0,0);cgflip(0,0,0);

n = 2;

for i = 1 : 5
    cgpenwid(5);
    % assign a random location to the circle
    dotX = (rand(n,1) .* 300)-150;
    dotY = (rand(n,1) .* 300)-150;

    % assign end point of the line
    endLineX = (rand(n,1) .* 500)-250;
    endLineY = (rand(n,1) .* 500)-250;

    circleWidth  = ones(n,1) * 10;
    circleHeight = ones(n,1) * 10;
    circleCol    = ones(n,3);
    lineCol      = ones(n,3);


    % draw circle
    cgellipse(dotX,dotY,circleWidth,circleHeight,circleCol,'f');
    cgflip(0,0,0);
    wait(150);
    cgflip(0,0,0);

    % draw line
    cgdraw(dotX,dotY,endLineX,endLineY,lineCol);
    cgflip(0,0,0);
    wait(100);
    cgflip(0,0,0);

    wait(1000);
    % go to next trial
    cgtext('Press any key to continue',0,0);
    cgflip;
    waitkeydown(inf);
    cgflip(0,0,0);cgflip(0,0,0);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
stop_cogent
clear DATA;
clc;