Py

Psychotoolboxで遊ぼう!

まあサンプルだけのっけるだけですが…
このプログラムは時計を表示するのですが、なんとなくかっこいい感じになってます。
これを実行するにはPsychotoolboxが必要です。3ではなく2用のコードです。
MATLABも必要です。不親切で、すいません。
まあ視覚やろうとしてた人が勉強がてらに作成したものなので、無駄がたくさんあるかも知れませんが、それは愛嬌ということで

clear all;
[window, winrect]=Screen(0,'OpenWindow',0);
HideCursor;

RGB=255*rand;
Screen(window,'TextFont','Arial');
i=0;
while 1   
    i=i+1;
    Screen(window,'WaitBlanking',2);
    
%     Screen(window,'FillRect',[255*sin(i/40.0+RGB/2)/2+255/2 255*cos(i/60.0+1.4*RGB/2)/2+255/2 255*sin(i/32.0+2*RGB/2+pi/3)/2+255/2]);
%     Screen(window,'FillRect',0);
    
    Rgb=255*sin(i/40.0+RGB)/2+255/2;
    rGb=255*cos(i/60.0+1.4*RGB)/2+255/2;
    rgB=255*sin(i/32.0+2*RGB+pi/3)/2+255/2;
    
%     Screen(window,'FillRect',[Rgb/3 rGb/3 rgB/3]);
    Screen(window,'DrawLine',[Rgb rGb rgB]./3,mod(10*i,winrect(3)),0,mod(-10*i,winrect(3)),winrect(4),40,1,'patCopy');
    Screen(window,'DrawLine',[Rgb/4 rGb/4 rgB/4],0,mod(11*i,winrect(4)),winrect(3),0,20,1,'patCopy');
    Screen(window,'DrawLine',[Rgb/4 rGb/4 rgB/4],0,winrect(4),winrect(3),mod(11*i,winrect(4)),20,1,'patCopy');
    
    
    PLAY_TIME           = clock;
    text=sprintf('%04d/%02d/%02d',PLAY_TIME(1),PLAY_TIME(2),PLAY_TIME(3));
    Screen(window,'TextSize',winrect(4)/8);
    Screen(window,'DrawText',text,(winrect(RectRight)-Screen(window,'TextWidth',text))/2,winrect(4)/3.2,[Rgb rGb rgB]);

    text=sprintf('%02d:%02d',PLAY_TIME(4),PLAY_TIME(5));  
    Screen(window,'TextSize',winrect(4)/4);
    x=Screen(window,'TextWidth',text);
    text=sprintf('%05.2f',PLAY_TIME(6));
    Screen(window,'TextSize',winrect(4)/6);
    x=x+Screen(window,'TextWidth',text);
    Screen(window,'TextSize',winrect(4)/4);
    text1=sprintf('%02d:%02d',PLAY_TIME(4),PLAY_TIME(5));
    Screen(window,'DrawText',text1,(winrect(RectRight)-x)/2,(winrect(RectBottom)+winrect(4)/4*0.75)/2,[Rgb rGb rgB]);
    y=Screen(window,'TextWidth',text1);
    
    text=sprintf('%05.2f',PLAY_TIME(6));
    Screen(window,'TextSize',winrect(4)/6);
    Screen(window,'DrawText',text,(winrect(RectRight)-x)/2+y,(winrect(RectBottom)+winrect(4)/4*0.75)/2,[Rgb rGb rgB]);
    
    [a,b,keyCode] = KbCheck;
    if keyCode(KbName('esc'))
        break;
    end
end

ShowCursor;
Screen('CloseAll');