purpose: sets the background color
usage: mglClearScreen(<color>)
argument | value |
---|---|
color | color to set background to, can be a grayscale value or an [r g b] value |
set to the level of gray (0-1)
mglClearScreen(gray)
set to the given [r g b]
mglClearScreen([r g b])
full example
mglOpen; mglClearScreen([0.7 0.2 0.5]); mglFlush();
purpose: plot 2D points on an OpenGL screen opened with mglOpen. For round dots, use mglGluDisk.
usage: mglPoints2(x,y,size,color)
argument | value |
---|---|
x,y | position of dots on screen |
size | size of dots (height of square in pixels) |
color | color of dots |
mglOpen; mglVisualAngleCoordinates(57,[16 12]); mglPoints2(16*rand(500,1)-8,12*rand(500,1)-6,2,1); mglFlush
purpose: plot 3D points on an OpenGL screen opened with mglOpen
usage: mglPoints2(x,y,z,size,color)
argument | value |
---|---|
x,y,z | position of dots on screen |
size | size of dots (in pixels) |
color | color of dots |
mglOpen; mglVisualAngleCoordinates(57,[16 12]); mglPoints3(16*rand(500,1)-8,12*rand(500,1)-6,zeros(500,1),2,1); mglFlush
purpose: mex function to plot lines on an OpenGL screen opened with glopen
usage: mglLines(x0, y0, x1, y1,size,color)
argument | value |
---|---|
x0,y0 | initial position of line |
x1,y1 | end position of line |
size | size of line (in pixels) |
color | color of line |
mglOpen mglVisualAngleCoordinates(57,[16 12]); mglLines2(-4, -4, 4, 4, 2, [1 0.6 1]); mglFlush
purpose: draw filled oval(s) centered at x,y with size [xsize ysize] and color [rgb]. the function is vectorized, so if you provide many x/y coordinates (identical) ovals will be plotted at all those locations.
usage: mglFillOval(x,y, size, color)
argument | value |
---|---|
x,y | center position of oval |
size | [width height] of oval |
color | color of oval |
mglOpen; mglVisualAngleCoordinates(57,[16 12]); x = [-1 -4 -3 0 3 4 1]; y = [-1 -4 -3 0 3 4 1]; sz = [1 1]; mglFillOval(x, y, sz, [1 0 0]); mglFlush();
purpose: draw filled rectangles(s) centered at x,y with size [xsize ysize] and color [rgb]. the function is vectorized, so if you provide many x/y coordinates (identical) ovals will be plotted at all those locations.
usage: [ ] = mglFillRect(x,y, size, color)
argument | value |
---|---|
x,y | center position of rectangle |
size | [width height] of rectangle |
color | color of rectangle |
mglOpen; mglVisualAngleCoordinates(57,[16 12]); x = [-1 -4 -3 0 3 4 1]; y = [-1 -4 -3 0 3 4 1]; sz = [1 1]; mglFillRect(x, y, sz, [1 1 0]); mglFlush();
purpose: draws a fixation cross. With no arguments, draws a fixation cross at origin (default width 0.2 with linewidth 1 in white at [0,0])
usage: mglFixationCross([width], [linewidth], [color], [origin]);
alternate usage: mglFixationCross( params )
argument | value |
---|---|
params | [width linewidth r g b x y] |
width | width in degrees of fixation cross |
linewidth | width in pixels on line |
color | color of fixation cross |
origin | center position of fixation (defaults to [0 0]) |
mglOpen; mglVisualAngleCoordinates(57,[16 12]); mglFixationCross; mglFlush;
purpose: for annuli and rings, e.g. for retinotopic stimuli. The function is vectorized, such that multiple annuli can be rendered in one call. In this case, x,y, isize, and osize need to have the same number of elements. Color is also vectorized.
usage: [ ] = mglGluAnnulus( x, y, isize, osize, color, [nslices], [nloops] )
argument | value |
---|---|
x,y | position of circle from which annulus/annuli is/are derived |
isize | inner radius/radii |
osize | outer radius/radii |
color | color of annuli, either [], 3-vector, or 3-row by n-column matrix |
nslices | number of wedges used in polygon→circle approximation [default 8] |
nloops | number of annuli used in polygon→circle approximation [default 1] |
mglOpen(0); mglVisualAngleCoordinates(57,[16 12]); x = zeros(4, 1); y = zeros(4, 1); isize = linspace(1, 8, 4); osize = isize+linspace(0.1, 2, 4); colors = jet(4)'; mglGluAnnulus(x, y, isize, osize,colors , 60, 2); mglFlush();
purpose: for plotting circular (rather than square dots), use this function. on slower machines, large number of dots may lead to dropped frames. there may be a way to speed this up a bit in future.
usage: [ ] = mglGluDisk( x, y, size, color, [nslices], [nloops] )
argument | value |
---|---|
x,y | position of dots |
size | size of dots (radius) |
color | color of dots |
nslices | number of wedges used in polygon→circle approximation [default 8] |
nloops | number of annuli used in polygon→circle approximation [default 1] |
mglOpen; mglVisualAngleCoordinates(57,[16 12]); x = 16*rand(100,1)-8; y = 12*rand(100,1)-6; mglGluDisk(x, y, 0.1, [0.1 0.6 1], 24, 2); mglFlush();
purpose: for segments and wedges, e.g. for retinotopic stimuli. The function is vectorized, such that multiple segments can be rendered in one call. In this case, x,y, isize, osize, startAngles, and sweepAngles need to have the same number of elements. Color is also vectorized (see mglGluAnnulus and the example below).
usage: [ ] = mglGluPartialDisk( x, y, isize, osize, startAngles, sweepAngles, color, [nslices], [nloops] )
argument | value |
---|---|
x,y | center position of circle from which segment is derived |
isize | innter radius of segment |
osize | outer radius of segment |
startAngles | angle at which segment(s) start |
sweepAngles | angle each segment(s) sweep(s) out |
color | color of segment |
nslices | number of wedges used in polygon→circle approximation [default 8] |
nloops | number of annuli used in polygon→circle approximation [default 2] |
mglOpen(0); mglVisualAngleCoordinates(57,[16 12]); x = zeros(10, 1); y = zeros(10, 1); isize = linspace(1, 5, 10); osize = 3+isize; startAngles = linspace(0,180, 10) sweepAngles = ones(1,10).*10; colors = jet(10)'; mglGluPartialDisk(x, y, isize, osize, startAngles, sweepAngles, colors, 60, 2); mglFlush();
purpose: mex function to draw a polygon in an OpenGL screen opened with mglOpen. x and y can be vectors (the polygon will be closed)
usage: mglPolygon(x, y, [color])
argument | value |
---|---|
x,y | position of vertices |
color | color of polygon |
mglOpen; mglVisualAngleCoordinates(57,[16 12]); x = [-5 -6 -3 4 5]; y = [ 5 1 -4 -2 3]; mglPolygon(x, y, [1 0 0]); mglFlush();
usage: mglQuad( vX, vY, rgbColor, [antiAliasFlag] );
purpose: mex function to draw a quad in an OpenGL screen opened with mglOpen
argument | value |
---|---|
vX | 4 row by N column matrix of 'X' coordinates |
vY | 4 row by N column matrix of 'Y' coordinates |
rgbColors | 3 row by N column of r-g-b specifing the color of each quad |
antiAliasFlag | turns on antialiasing to smooth the edges |
mglOpen; mglScreenCoordinates mglQuad([100; 600; 600; 100], [100; 200; 600; 100], [1; 1; 1], 1); mglFlush();