Psychtoolbox工具绘图实例

Screens(‘DrawTexture’)函数

Screen('DrawTexture', windowPointer, texturePointer [,sourceRect] [,destinationRect] [,rotationAngle] [, filterMode] [, globalAlpha] [, modulateColor] [, textureShader] [, specialFlags] [, auxParameters]);

Usage:
Draw the texture specified via 'texturePointer' into the target window specified via 'windowPointer'.
'sourceRect': specifies a rectangular subpart of the texture to be drawn (Defaults to full texture).
'destinationRect': defines the rectangular subpart of the window where the texture should be drawn. This defaultsto centered on the screen. 
'rotationAngle': Specifies a rotation angle in degree for rotated drawing of the texture (Defaults to 0 deg. = upright).

Screen(‘DrawDots’) 函数

 Screen('DrawDots', windowPtr, xy [,size] [,color] [,center] [,dot_type][, lenient]);

Usage:
Quickly draw an array of dots.  "xy" is a two-row vector containing the x and y coordinates of the dot centers, relative to "center" (default center is [0 0]).
"size": is the diameter of each dot in pixels (default is 1). Instead of a common size for all dots you can also provide a vector which defines a different dot size for each dot. Different graphics cards do have different limits on the maximum size of dots, 10 or 63 are typical limits.
"color": is the the clut index (scalar or [r g b a] vector) that you want to poke into each dot pixel (default is black).  Instead of a single "color" you can also provide a 3 or 4 row vector,which specifies an individual RGB or RGBA color for each corresponding point.
"dot_type": is a flag that determines what type of dot is drawn: 0 (default) and 4 draw square dots

一个实例:

screens=Screen('Screens');
screenNumber=max(screens);
[w, Screenrect] = Screen('OpenWindow', screenNumber, 128, [0 0 800 600]);
Screen(w,'BlendFunction',GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

load dotinfo;
png = imread('max.png');
pngtext = Screen('MakeTexture', w,  png);

Screen('DrawTexture', w, pngtext, [], CenterRectOnPoint([0 0 ISA(dn) ISA(dn)],Screenrect(3)/2+squeeze(xys{dn}(:,i,1)),Screenrect(4)/2+squeeze(xys{dn}(:,i,2))));

Screen('Flip', w);
imageArray=Screen('GetImage', w, CenterRect([0 0 224 224],Screenrect));
imwrite(imageArray,sprintf('stims/img_%02d_%03d.png',dot_number,i));
  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值