Skip to content

Add docs to Problem #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions toolbox/+otp/+utils/+movie/+recorder/FileRecorder.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ function stop(obj)
obj.VideoWriter.close();
end

function h = play(obj)
h = implay(fullfile(obj.VideoWriter.Path, obj.VideoWriter.Filename), obj.VideoWriter.FrameRate);
function play(obj)
implay(fullfile(obj.VideoWriter.Path, obj.VideoWriter.Filename), obj.VideoWriter.FrameRate);
end
end
end
8 changes: 6 additions & 2 deletions toolbox/+otp/+utils/+movie/+recorder/MemoryRecorder.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ function stop(~)
% Nothing to do
end

function h = play(obj)
h = implay(obj.Mov, obj.FrameRate);
function play(obj)
if exist('implay', 'file')
implay(obj.Mov, obj.FrameRate);
else
movie(obj.Mov, 1, obj.FrameRate);
end
end
end
end
5 changes: 2 additions & 3 deletions toolbox/+otp/+utils/+movie/+recorder/NullRecorder.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ function stop(~)
% Nothing to do
end

function h = play(~)
h = 'Movie not saved for playback';
error('OTP:movieNotSaved', h);
function play(~)
error('OTP:movieNotSaved', 'Movie not saved for playback');
end
end
end
18 changes: 9 additions & 9 deletions toolbox/+otp/+utils/+movie/Movie.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
p = inputParser;
p.addParameter('Save', false);
p.addParameter('FrameRate', otp.utils.movie.Movie.DefaultFramerate);
p.addParameter('TargetDuration', [], @(d) d > 0);
p.addParameter('Duration', [], @(d) d > 0);
p.addParameter('Size', [], @(s) length(s) == 2 && all(s > 0));
p.addParameter('Smooth', true, @islogical);
p.parse(varargin{:});
Expand Down Expand Up @@ -46,27 +46,27 @@ function record(obj, t, y)
totalSteps = length(t);
[state.numVars, state.totalSteps] = size(y);
if length(t) ~= state.totalSteps
error('OTP:invalidSolution', ...
'Expected y to have %d columns but has %d', ...
length(t), state.totalSteps);
error('OTP:invalidSolution', 'Expected y to have %d columns but has %d', length(t), state.totalSteps);
end

state.t = t;
state.y = y;
state.step = 0;
state.frame = 0;

if isempty(obj.Config.TargetDuration)
if isempty(obj.Config.Duration)
state.totalFrames = totalSteps;
else
state.totalFrames = round(obj.Config.TargetDuration * obj.FrameRate);
state.totalFrames = round(obj.Config.Duration * obj.FrameRate);
end

[t0, tEnd] = bounds(t);

fig = figure;
if ~isempty(obj.Config.Size)
fig.Position = [0; 0; obj.Config.Size(:)];
pos = get(fig, 'position');
pos(3:4) = obj.Config.Size;
set(fig, 'position', pos);
end

obj.init(fig, state);
Expand Down Expand Up @@ -97,8 +97,8 @@ function record(obj, t, y)
obj.Recorder.stop();
end

function h = play(obj)
h = obj.Recorder.play();
function play(obj)
obj.Recorder.play();
end
end

Expand Down
Loading