-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfsFigure.m
68 lines (59 loc) · 2.2 KB
/
fsFigure.m
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function figHan = fsFigure(sizeFraction,varargin)
%FSFIGURE creates a figure which takes up the whole screen or a specified fraction of it
%
% fsFigure
%
% figHan = fsFigure
% figHan = fsFigure(sizeFraction)
% figHan = fsFigure(sizeFraction,varargin)
%
% This will create a full-screen (or smaller) figure centered on the
% default display and returns the figure handle.
%
% Input:
%
% sizeFraction - Optional. Scalar or vector of length 2. The fraction
% of the screen dimensions to make the figure. That is,
% if your screen resolution is 1024x768 and
% sizeFraction is 1, the figure will also be 1024x768,
% whereas if sizeFraction is .5, the figure will be
% 512x384.
%
% If sizeFraction is a vector, the first elements
% specifies the fraction of the screen width to use, and
% the second element the fraction of the screen height.
%
% Optional. Default is 1 - that is, to make the figure
% the same size as the screen.
%
% varargin - Any additional arguments will be passed to the figure
% command
%
% Output:
%
% figHan - The handle to the newly created figure.
%
% Hunter Elliott, 10/2009
%
if nargin < 1 || isempty(sizeFraction)
sizeFraction = 1;
end
if length(sizeFraction(:)) > 2 || length(sizeFraction) < 1
error('The input sizeFraction must be a scalar or a vector of length 2!')
end
if length(sizeFraction(:)) == 1
sizeFraction = [sizeFraction(1) sizeFraction(1)];
end
%Check the input size fraction
if min(sizeFraction) <= 0 || max(sizeFraction) > 1
error('The size fraction must be greater than zero and less than or equal to one!!')
end
%Determine the screen resolution
sSize = get(0,'ScreenSize');
%Now use this to set the figure size
figSize = ceil([sSize(1) + sSize(3)*(1-sizeFraction(1))/2 ,...
sSize(2) + sSize(4)*(1-sizeFraction(2))/2,...
sSize(3)*sizeFraction(1),...
sSize(4)*sizeFraction(2)]);
%Make the figure!
figHan = figure('Position',figSize,varargin{:});