File: DrawingStuffTest.m

package info (click to toggle)
psychtoolbox-3 3.0.19.14.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,796 kB
  • sloc: ansic: 176,245; cpp: 20,103; objc: 5,393; sh: 2,753; python: 1,397; php: 384; makefile: 193; java: 113
file content (40 lines) | stat: -rw-r--r-- 1,283 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
% DrawingStuffTest
% 
% Exercises FrameRect, DrawLine,  FillPoly and FramePoly on OS X.  

% 7/24/03   awi     Wrote it. 

s=max(Screen('Screens'));
w=Screen('OpenWindow', s,[],[],[],[],[],0);
Screen('FillRect', w, 0);

% Test drawing some frame rects
r1=[0 0 100 100];
r2=OffsetRect(r1, 200,200);
r3=OffsetRect(r1, 250,250);
r4=OffsetRect(r1, 300,300);
Screen('FrameRect',w, [255 255 0], r2, 1);
Screen('FrameRect',w, [255 0 0], r3, 4);
Screen('FrameRect',w, [0 255 0], r4, 9);
Screen('FrameRect',w, [255 0 255], r4, 1);

% Test drawing a line
Screen('DrawLine', w, 255, 100,100, 400,400, 3);

% Test drawing filled and framed polygons.  Note that polygons must be convex.  This is a
% requirement made by GL.  Choosing vertices on the perimeter of a  circle
% is guaranteed to specify a convex polygon.  
polyCenterX=500;
polyCenterY=300;
numPoints=15;
polyRadius=50;
ClockRandSeed;
angles=sort(rand(1,numPoints) * 2 * pi);
polyPoints=round([ [cos(angles)*polyRadius+polyCenterX]', [sin(angles)*polyRadius+polyCenterY]']);
Screen('FillPoly', w, [0 0 255], polyPoints);
polyCenterY=150;
polyPoints=round([ [cos(angles)*polyRadius+polyCenterX]', [sin(angles)*polyRadius+polyCenterY]']);
Screen('FramePoly', w, [0 0 255], polyPoints,2);
Screen('Flip', w);
KbWait;
Screen('CloseAll');