%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% .m script of web demo "Insert title here" 
% Written for GNU Octave
% 
% INSTITUTE OF TELECOMMUNICATIONS  
% University of Stuttgart 
% www.inue-uni-stuttgart.de 
% author: Your Name   
% date: DD.MM.YYYY   
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% This function creats animationNumberOfPictures frames and prints the values
% of the parameters that have been passed as well as an increasing frame number.
% Make sure that the function prototype matches the prototype defined
% in the XML config file. (Parameter names are arbitrary but should be the same
% for better readability) 

function [] = demo_4_fun(text1, enum1, checkbox1, range1, select1, animationNumberOfPictures, filename)
% define formats
landscape = "-S930,350";
portrait  = "-S640,480";

% select format
output_format = landscape;

img_index = 0;
for k=1:animationNumberOfPictures
	% The frames must be numbered from 0 to animationNumberOfPictures - 1
	new_filename = [filename '_' num2str(img_index)];
	img_index = img_index + 1;

	% Create an invisible figure.
	fh = figure(1);
	set(fh, "visible", "off");
	
	% define style
  set(0, "defaultlinelinewidth", 2);
  set(0, "defaultaxesfontsize", 8);
  set(0, "defaultaxesfontname", "Helvetica");
  set(0, "defaulttextfontsize", 8);
  set(0, "defaulttextfontname", "Helvetica");

	% Plot into the figure
	welcome = ["Hi there! Change the values on the right\nand press [Create Animation]!\n"];
	text(0.1, 0.8, welcome, "fontsize", 8, "color", "red"); 
	str = ["value of text1: " num2str(text1) "\n"];
	str = [str "value of enum1: " enum1 "\n"];
	str = [str "value of checkbox1: " num2str(checkbox1) "\n"];
	str = [str "value of range1: " num2str(range1) "\n"];
	str = [str "value of select1: " select1 "\n"]; 
	text(0.1, 0.5, str);
	frame_str = ["Frame no.:" num2str(k)];
	text(0.7, 0.5, frame_str, "color", "blue");

	% Create an image file. This png image is displayed on the webpage. Its size 
	% must be 930x350.
	print(new_filename, "-dpng", output_format);
	clf;
end
end
