Help with programming

i would like to create this in Pascal and MATLAB can anybody help...please refer to this website http://www.yorku.ca/eye/balls.htm

Comments

  • [b][red]This message was edited by Josh Code at 2004-5-2 11:21:22[/red][/b][hr]
    : i would like to create this in Pascal and MATLAB can anybody help...please refer to this website http://www.yorku.ca/eye/balls.htm
    :
    1. start a new project.
    2. put a timer on the form.
    3. copy and paste this code into the code editor.
    4. Go back to the form and double click the timer. (this is needed to link the OnTimer event with the procedure in the code)
    5. run the program.

    [code]
    [b]unit[/b] Unit1;

    [b]interface[/b]

    [b]uses[/b]
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    ExtCtrls;

    [b]type[/b]
    TForm1 = [b]class[/b](TForm)
    Timer1: TTimer;
    [b]procedure[/b] Timer1Timer(Sender: TObject);
    [b]private[/b]
    [italic][blue]{ Private declarations }[/italic][/blue]
    RightVisible: boolean;
    [italic][blue]// a flag to determine which of the top balls to show[/italic][/blue]
    [b]public[/b]
    [italic][blue]{ Public declarations }[/italic][/blue]
    [b]end[/b];

    [b]var[/b]
    Form1: TForm1;

    [b]implementation[/b]

    [italic][blue]{$R *.DFM}[/italic][/blue]

    [b]procedure[/b] TForm1.Timer1Timer(Sender: TObject);
    [b]var[/b]
    bitmap1: tbitmap;[italic][blue]
    // stores the graphics for a single frame for this interval
    // this is a buffer used to prevent flickering of the animation[/italic][/blue]
    [b]const[/b] BallSize = 12; [italic][blue]// radius of the balls[/italic][/blue]
    LeftSide = 60; [italic][blue]// pixels over to the left side[/italic][/blue]
    RightSide = 140; [italic][blue]// pixels over to the right side[/italic][/blue]
    TopSide = 40; [italic][blue]// pixels down to the top[/italic][/blue]
    BottomSide = 160; [italic][blue]// pixels down to the bottom[/italic][/blue]
    [b]begin[/b]
    bitmap1:=tbitmap.create; [italic][blue]// create an instance of a tbitmap[/italic][/blue]
    [b]with[/b] bitmap1 [b]do[/b] [italic][blue]// work with the properties and methods of bitmap1[/italic][/blue]
    [b]begin[/b]
    height:=200; [italic][blue]// set height to 200[/italic][/blue]
    width:=200; [italic][blue]// set width to 200[/italic][/blue]
    [b]with[/b] bitmap1.canvas [b]do[/b]
    [italic][blue]// work with the properties and methods of bitmap1's canvas[/italic][/blue]
    [b]begin[/b]
    Brush.Color := clblue;
    [italic][blue]// change the brush colour to blue for the ellipses[/italic][/blue]
    Ellipse(RightSide-BallSize,BottomSide-BallSize,RightSide+BallSize,BottomSide+BallSize);
    [italic][blue]// draw a circle in the bottom right part of the bitmap[/italic][/blue]
    Ellipse(LeftSide-BallSize,BottomSide-BallSize,LeftSide+BallSize,BottomSide+BallSize);
    [italic][blue]// draw a circle in the bottom left part of the bitmap[/italic][/blue]
    [b]if[/b] RightVisible [b]then[/b] [italic][blue]// condition varies from frame to frame[/italic][/blue]
    Ellipse(LeftSide-BallSize,TopSide-BallSize,LeftSide+BallSize,TopSide+BallSize)
    [italic][blue] // draw a circle in the upper left part of the bitmap[/italic][/blue]
    [b]else[/b]
    Ellipse(RightSide-BallSize,TopSide-BallSize,RightSide+BallSize,TopSide+BallSize);
    [italic][blue] // draw a circle in the upper right part of the bitmap[/italic][/blue]

    pen.width :=3; [italic][blue]// make the lines thick.[/italic][/blue]
    moveto(0,100); [italic][blue]// move pen to (x=0,y=100 pixels)[/italic][/blue]
    lineto(200,100); [italic][blue]// draw a horizontal line accross middle of frame[/italic][/blue]
    [b]end[/b];
    [b]end[/b];
    Canvas.Draw(0,0,bitmap1); [italic][blue]// draw the bitmap onto the form's canvas to be seen by the user[/italic][/blue]
    bitmap1.free; [italic][blue]// free the memory used to store the bitmap[/italic][/blue]
    RightVisible:=[b]not[/b] RightVisible;[italic][blue]// change from one frame to the next[/italic][/blue]
    [b]end[/b];

    [b]end.[/b]
    [/code]






  • thank you very much...one more question ...how can i change the timing of the balls....sometimes i want one to go on at 50 msec and the other one after a 50 msec delay to go on for 50 msec...and i want to use different kind of timing that are presented randomly....i also want after each presentation to get a response by a keypress...and i want to record the response and at the end of the experiment i want to get the mean of responses....i know i am asking too much but i am still trying to learn and i need help!!!

    : [b][red]This message was edited by Josh Code at 2004-5-2 11:21:22[/red][/b][hr]
    : : i would like to create this in Pascal and MATLAB can anybody help...please refer to this website http://www.yorku.ca/eye/balls.htm
    : :
    : 1. start a new project.
    : 2. put a timer on the form.
    : 3. copy and paste this code into the code editor.
    : 4. Go back to the form and double click the timer. (this is needed to link the OnTimer event with the procedure in the code)
    : 5. run the program.
    :
    : [code]
    : [b]unit[/b] Unit1;
    :
    : [b]interface[/b]
    :
    : [b]uses[/b]
    : Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    : ExtCtrls;
    :
    : [b]type[/b]
    : TForm1 = [b]class[/b](TForm)
    : Timer1: TTimer;
    : [b]procedure[/b] Timer1Timer(Sender: TObject);
    : [b]private[/b]
    : [italic][blue]{ Private declarations }[/italic][/blue]
    : RightVisible: boolean;
    : [italic][blue]// a flag to determine which of the top balls to show[/italic][/blue]
    : [b]public[/b]
    : [italic][blue]{ Public declarations }[/italic][/blue]
    : [b]end[/b];
    :
    : [b]var[/b]
    : Form1: TForm1;
    :
    : [b]implementation[/b]
    :
    : [italic][blue]{$R *.DFM}[/italic][/blue]
    :
    : [b]procedure[/b] TForm1.Timer1Timer(Sender: TObject);
    : [b]var[/b]
    : bitmap1: tbitmap;[italic][blue]
    : // stores the graphics for a single frame for this interval
    : // this is a buffer used to prevent flickering of the animation[/italic][/blue]
    : [b]const[/b] BallSize = 12; [italic][blue]// radius of the balls[/italic][/blue]
    : LeftSide = 60; [italic][blue]// pixels over to the left side[/italic][/blue]
    : RightSide = 140; [italic][blue]// pixels over to the right side[/italic][/blue]
    : TopSide = 40; [italic][blue]// pixels down to the top[/italic][/blue]
    : BottomSide = 160; [italic][blue]// pixels down to the bottom[/italic][/blue]
    : [b]begin[/b]
    : bitmap1:=tbitmap.create; [italic][blue]// create an instance of a tbitmap[/italic][/blue]
    : [b]with[/b] bitmap1 [b]do[/b] [italic][blue]// work with the properties and methods of bitmap1[/italic][/blue]
    : [b]begin[/b]
    : height:=200; [italic][blue]// set height to 200[/italic][/blue]
    : width:=200; [italic][blue]// set width to 200[/italic][/blue]
    : [b]with[/b] bitmap1.canvas [b]do[/b]
    : [italic][blue]// work with the properties and methods of bitmap1's canvas[/italic][/blue]
    : [b]begin[/b]
    : Brush.Color := clblue;
    : [italic][blue]// change the brush colour to blue for the ellipses[/italic][/blue]
    : Ellipse(RightSide-BallSize,BottomSide-BallSize,RightSide+BallSize,BottomSide+BallSize);
    : [italic][blue]// draw a circle in the bottom right part of the bitmap[/italic][/blue]
    : Ellipse(LeftSide-BallSize,BottomSide-BallSize,LeftSide+BallSize,BottomSide+BallSize);
    : [italic][blue]// draw a circle in the bottom left part of the bitmap[/italic][/blue]
    : [b]if[/b] RightVisible [b]then[/b] [italic][blue]// condition varies from frame to frame[/italic][/blue]
    : Ellipse(LeftSide-BallSize,TopSide-BallSize,LeftSide+BallSize,TopSide+BallSize)
    : [italic][blue] // draw a circle in the upper left part of the bitmap[/italic][/blue]
    : [b]else[/b]
    : Ellipse(RightSide-BallSize,TopSide-BallSize,RightSide+BallSize,TopSide+BallSize);
    : [italic][blue] // draw a circle in the upper right part of the bitmap[/italic][/blue]
    :
    : pen.width :=3; [italic][blue]// make the lines thick.[/italic][/blue]
    : moveto(0,100); [italic][blue]// move pen to (x=0,y=100 pixels)[/italic][/blue]
    : lineto(200,100); [italic][blue]// draw a horizontal line accross middle of frame[/italic][/blue]
    : [b]end[/b];
    : [b]end[/b];
    : Canvas.Draw(0,0,bitmap1); [italic][blue]// draw the bitmap onto the form's canvas to be seen by the user[/italic][/blue]
    : bitmap1.free; [italic][blue]// free the memory used to store the bitmap[/italic][/blue]
    : RightVisible:=[b]not[/b] RightVisible;[italic][blue]// change from one frame to the next[/italic][/blue]
    : [b]end[/b];
    :
    : [b]end.[/b]
    : [/code]
    :
    :
    :
    :
    :
    :
    :

  • : thank you very much...one more question ...how can i change the timing of the balls....sometimes i want one to go on at 50 msec and the other one after a 50 msec delay to go on for 50 msec...and i want to use different kind of timing that are presented randomly....i also want after each presentation to get a response by a keypress...and i want to record the response and at the end of the experiment i want to get the mean of responses....i know i am asking too much but i am still trying to learn and i need help!!!
    [hr]

    Set the timer interval property to 50. Maybe that will do what you want. You could also update it each OnTimer event to some random number, if you wanted it to keep changing randomly.

    What are the responses from the keyboard? If they are keys, for example 'f', 'd', 's'... how are you supposed to find the mean of these qualitative values? Are they numbers from the keyboard?

    Does the user click a button to end it? What happens to end the experiment?

  • i would like the responces to be the keys 1 or 2 or 3 or 4 or 5 or for motion and 1 or 2 for direction...so right after one presentation the subject has to respond with a motion indication and a direction indication and then the next trial will come up...i want 192 trials and after those are completed the experiment to end..
    As far as the means are conserned i was thinking the mean of motion and direction after each trial...for example out of 192 trials how many times the pressed on for motion or 2 and so on...


    : : thank you very much...one more question ...how can i change the timing of the balls....sometimes i want one to go on at 50 msec and the other one after a 50 msec delay to go on for 50 msec...and i want to use different kind of timing that are presented randomly....i also want after each presentation to get a response by a keypress...and i want to record the response and at the end of the experiment i want to get the mean of responses....i know i am asking too much but i am still trying to learn and i need help!!!
    : [hr]
    :
    : Set the timer interval property to 50. Maybe that will do what you want. You could also update it each OnTimer event to some random number, if you wanted it to keep changing randomly.
    :
    : What are the responses from the keyboard? If they are keys, for example 'f', 'd', 's'... how are you supposed to find the mean of these qualitative values? Are they numbers from the keyboard?
    :
    : Does the user click a button to end it? What happens to end the experiment?
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories